Commit d1dece12 authored by Anael Beutot's avatar Anael Beutot Committed by Sébastien Luttringer
Browse files

Implemented autostart command



Set autostart flag on VMs.

Signed-off-by: default avatarSébastien Luttringer <sebastien.luttringer@smartjog.com>
parent cc0320ed
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -120,6 +120,27 @@ class Command_disablevirtiocache(TqlCommand):
    def remote_functions(self):
        return set(("disablevirtiocache",))

class Command_autostart(TqlCommand):
    '''Set autostart flag on VMs'''

    def __init__(self, cli, argv0):
        TqlCommand.__init__(self, cli, argv0)
        self.tql_filter += "&r=vm"
        self.add_option("-D", action="store_false", dest="flag", help="Disable"
                        " autostart")
        self.add_option("-e", default=True, action="store_true", dest="flag",
                       help="Enable autostart")

    def __call__(self, argv):
        # arg parse
        self.parse_args(argv)
        if len(self.args) != 1:
            raise cmdBadArgument()
        # rpc call
        self.rpccall("autostart", self.args[0], self.options.flag)

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

class Command_undefine(TqlCommand):
    '''Undefine a stopped vm'''