Commit ef3e542b authored by Antoine Millet's avatar Antoine Millet Committed by Sébastien Luttringer
Browse files

Added migrate2 command (new style migrations)

parent 2538e091
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -97,3 +97,30 @@ class Command_migrate(TqlCommand):
        '''Print a list of migration type'''
        for t in self.etypes.keys():
            self.printer.out("migrate -t %s -a %s"%(t, ",".join(self.etypes[t])))


class Command_migrate2(TqlCommand):
    '''New generation VM migration.'''

    def __init__(self, cli, argv0):
        TqlCommand.__init__(self, cli, argv0)
        self.set_usage("%prog [options] <source tql> <dest tql>")
        self.add_option("-l", "--live", action="store_true", default=False,
            help="Do a live migration")
        self.add_option("-b", "--batch", help="Name of this batch")
        self.add_option("-f", "--flag", action="append",
            help="Migration or allocation flags")

    def __call__(self, argv):
        self.parse_args(argv)
        if self.options.live:
            self.tql_filter += "&r=vm&status=running"
        else:
            self.tql_filter += "&r=vm&status=stopped"
        if len(self.args) != 2:
            raise cmdBadArgument()
        self.rpccall("migrate2", self.args[0], self.args[1],
            live=self.options.live, flags=self.options.flag)

    def remote_functions(self):
        return set(("migrate2",))