Loading cloudcontrol/server/clients/cli.py +69 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ from cloudcontrol.common.tql.db.tag import StaticTag MIGRATION_TYPES = {'cold': ColdMigrationJob, 'hot': HotMigrationJob,} RESCUE_SCRIPT = 'rescue' class CliHandler(RegisteredCCHandler): Loading Loading @@ -231,6 +232,74 @@ class CliHandler(RegisteredCCHandler): return errs.get_dict() @listed def rescue(self, query): """ Enable rescue mode on selected virtual machines. :param query: the tql query to select objects. """ objects = self.client.list(query, show=('r', 'p', 'h', 'status'), method='rescue') if objects: # Load the script: sha1_hash, _ = self.server.scripts.load(RESCUE_SCRIPT) errs = Reporter() for obj in objects: if obj['r'] != 'vm': errs.error(obj['id'], 'bad role') continue elif obj['status'] != 'stopped': errs.error(obj['id'], 'VM must be stopped') continue try: hvcon = self.server.get_client(obj['p']) except KeyError: errs.error(obj['id'], 'hypervisor not connected') else: args = (None, obj['h']) job_id = hvcon.script_run(sha1_hash, RESCUE_SCRIPT, self.client.login, *args) output = hvcon.job_poll(job_id) errs.success(obj['id'], output) return errs.get_dict() @listed def unrescue(self, query): """ Disable rescue mode on selected virtual machines. :param query: the tql query to select objects. """ objects = self.client.list(query, show=('r', 'p', 'h', 'status'), method='rescue') if objects: # Load the script: sha1_hash, _ = self.server.scripts.load(RESCUE_SCRIPT) errs = Reporter() for obj in objects: if obj['r'] != 'vm': errs.error(obj['id'], 'bad role') continue elif obj['status'] != 'stopped': errs.error(obj['id'], 'VM must be stopped') continue try: hvcon = self.server.get_client(obj['p']) except KeyError: errs.error(obj['id'], 'hypervisor not connected') else: args = (None, '-u', obj['h']) job_id = hvcon.script_run(sha1_hash, RESCUE_SCRIPT, self.client.login, *args) output = hvcon.job_poll(job_id) errs.success(obj['id'], output) return errs.get_dict() # # Account management: # Loading Loading
cloudcontrol/server/clients/cli.py +69 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ from cloudcontrol.common.tql.db.tag import StaticTag MIGRATION_TYPES = {'cold': ColdMigrationJob, 'hot': HotMigrationJob,} RESCUE_SCRIPT = 'rescue' class CliHandler(RegisteredCCHandler): Loading Loading @@ -231,6 +232,74 @@ class CliHandler(RegisteredCCHandler): return errs.get_dict() @listed def rescue(self, query): """ Enable rescue mode on selected virtual machines. :param query: the tql query to select objects. """ objects = self.client.list(query, show=('r', 'p', 'h', 'status'), method='rescue') if objects: # Load the script: sha1_hash, _ = self.server.scripts.load(RESCUE_SCRIPT) errs = Reporter() for obj in objects: if obj['r'] != 'vm': errs.error(obj['id'], 'bad role') continue elif obj['status'] != 'stopped': errs.error(obj['id'], 'VM must be stopped') continue try: hvcon = self.server.get_client(obj['p']) except KeyError: errs.error(obj['id'], 'hypervisor not connected') else: args = (None, obj['h']) job_id = hvcon.script_run(sha1_hash, RESCUE_SCRIPT, self.client.login, *args) output = hvcon.job_poll(job_id) errs.success(obj['id'], output) return errs.get_dict() @listed def unrescue(self, query): """ Disable rescue mode on selected virtual machines. :param query: the tql query to select objects. """ objects = self.client.list(query, show=('r', 'p', 'h', 'status'), method='rescue') if objects: # Load the script: sha1_hash, _ = self.server.scripts.load(RESCUE_SCRIPT) errs = Reporter() for obj in objects: if obj['r'] != 'vm': errs.error(obj['id'], 'bad role') continue elif obj['status'] != 'stopped': errs.error(obj['id'], 'VM must be stopped') continue try: hvcon = self.server.get_client(obj['p']) except KeyError: errs.error(obj['id'], 'hypervisor not connected') else: args = (None, '-u', obj['h']) job_id = hvcon.script_run(sha1_hash, RESCUE_SCRIPT, self.client.login, *args) output = hvcon.job_poll(job_id) errs.success(obj['id'], output) return errs.get_dict() # # Account management: # Loading