Commit 109732ad authored by Antoine Millet's avatar Antoine Millet
Browse files

Rewrote rescue handler to use ones on cc-node

parent f755d686
Loading
Loading
Loading
Loading
+16 −20
Original line number Diff line number Diff line
@@ -241,11 +241,7 @@ class CliHandler(RegisteredCCHandler):
        :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)
        objects = self.client.list(query, show=('r', 'p', 'h', 'n', 'status'), method='rescue')

        errs = Reporter()
        for obj in objects:
@@ -260,11 +256,12 @@ class CliHandler(RegisteredCCHandler):
            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)
                try:
                    hvcon.proxy.vm_rescue(obj['h'])
                except Exception as err:
                    errs.error(obj['id'], 'Unexpected exception: %s' % str(err))
                else:
                    errs.success(obj['id'], 'vm now in rescue mode')

        return errs.get_dict()

@@ -275,11 +272,7 @@ class CliHandler(RegisteredCCHandler):
        :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)
        objects = self.client.list(query, show=('r', 'p', 'h', 'n', 'status'), method='rescue')

        errs = Reporter()
        for obj in objects:
@@ -294,14 +287,17 @@ class CliHandler(RegisteredCCHandler):
            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)
                try:
                    hvcon.proxy.vm_unrescue(obj['h'])
                except Exception as err:
                    errs.error(obj['id'], 'Unexpected exception: %s' % str(err))
                else:
                    errs.success(obj['id'], 'vm now in normal mode')

        return errs.get_dict()



    #
    # Account management:
    #