Ejemplo n.º 1
0
    def message_park_hypervisor(self, msg):
        """
        Handle the park message.
        @type msg: xmmp.Protocol.Message
        @param msg: the message
        @rtype: string
        @return: the answer
        """
        try:
            tokens = msg.getBody().split()
            if len(tokens) < 2:
                return "I'm sorry, you use a wrong format. You can type 'help' to get help."
            uuids = tokens[1].split(",")
            vms_info = []
            for vmuuid in uuids:
                vms_info.append({"uuid": vmuuid, "hypervisor": "None", "parker": str(msg.getFrom())})

            self.park(vms_info)

            if len(uuids) == 1:
                return "Virtual machine is parking."
            else:
                return "Virtual machines are parking."

        except Exception as ex:
            return build_error_message(self, ex, msg)
Ejemplo n.º 2
0
    def message_park_hypervisor(self, msg):
        """
        Handle the park message.
        @type msg: xmmp.Protocol.Message
        @param msg: the message
        @rtype: string
        @return: the answer
        """
        try:
            tokens = msg.getBody().split()
            if len(tokens) < 2:
                return "I'm sorry, you use a wrong format. You can type 'help' to get help."
            uuids = tokens[1].split(",")
            vms_info = []
            for vmuuid in uuids:
                vms_info.append({"uuid": vmuuid, "hypervisor": "None", "parker": str(msg.getFrom())})

            self.park(vms_info)

            if len(uuids) == 1:
                return "Virtual machine is parking."
            else:
                return "Virtual machines are parking."

        except Exception as ex:
            return build_error_message(self, ex, msg)
Ejemplo n.º 3
0
    def message_unpark(self, msg):
        """
        Handle the unpark message.
        @type msg: xmmp.Protocol.Message
        @param msg: the message
        @rtype: string
        @return: the answer
        """
        try:
            tokens = msg.getBody().split()
            if len(tokens) < 2:
                return "I'm sorry, you use a wrong format. You can type 'help' to get help."
            itemids = tokens[1].split(",")
            vms_info = []
            for itemid in itemids:
                vms_info.append({"uuid": itemid, "start": False, "status": ARCHIPEL_PARKING_STATUS_NOT_PARKED, "parker": str(msg.getFrom())})

            self.unpark(vms_info)

            if len(itemids) == 1:
                return "Virtual machine is unparking."
            else:
                return "Virtual machines are unparking."
        except Exception as ex:
            return build_error_message(self, ex, msg)
Ejemplo n.º 4
0
 def message_detach(self, msg):
     """
     detach the current attached appliance
     """
     try:
         tokens = msg.getBody().split()
         if not len(tokens) == 2:
             return "I'm sorry, you use a wrong format. You can type 'help' to get help."
         self.detach()
         return "Appliance is now detached"
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 5
0
 def message_capabilities(self, msg):
     """
     Process the capabilities message request.
     @type msg: xmpp.Protocol.Message
     @param msg: the received message
     @rtype: xmpp.Protocol.Message
     @return: a ready to send Message containing the result of the action
     """
     try:
         return str(self.capabilities)
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 6
0
 def message_ip(self, msg):
     """
     Process the IP message request.
     @type msg: xmpp.Protocol.Message
     @param msg: the received message
     @rtype: xmpp.Protocol.Message
     @return: a ready to send Message containing the result of the action
     """
     try:
         return "Sure, my IP is %s" % self.ipaddr
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 7
0
 def message_libvirt_uri(self, msg):
     """
     process the libvirt URI message request
     @type msg: xmpp.Protocol.Message
     @param iq: the received message
     @rtype: xmpp.Protocol.Message
     @return: a ready to send Message containing the result of the action
     """
     try:
         return "Sure, my libvirt URI is %s" % self.local_libvirt_uri.replace("///", "//%s/" % self.resource)
     except Exception as ex:
         return build_error_message(self, ex)
Ejemplo n.º 8
0
 def message_ip(self, msg):
     """
     Process the IP message request.
     @type msg: xmpp.Protocol.Message
     @param msg: the received message
     @rtype: xmpp.Protocol.Message
     @return: a ready to send Message containing the result of the action
     """
     try:
         return "Sure, my IP is %s" % self.ipaddr
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 9
0
 def message_migration_info(self, msg):
     """
     Process the libvirt URI message request.
     @type msg: xmpp.Protocol.Message
     @param msg: the received message
     @rtype: xmpp.Protocol.Message
     @return: a ready to send Message containing the result of the action
     """
     try:
         return "Sure, my libvirt URI is %s" % self.migration_info()["libvirt_uri"]
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 10
0
 def message_detach(self, msg):
     """
     detach the current attached appliance
     """
     try:
         tokens = msg.getBody().split()
         if not len(tokens) == 2:
             return "I'm sorry, you use a wrong format. You can type 'help' to get help."
         self.detach()
         return "Appliance is now detached"
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 11
0
 def message_capabilities(self, msg):
     """
     Process the capabilities message request.
     @type msg: xmpp.Protocol.Message
     @param msg: the received message
     @rtype: xmpp.Protocol.Message
     @return: a ready to send Message containing the result of the action
     """
     try:
         return str(self.capabilities)
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 12
0
 def message_display(self, msg):
     """
     handle message vnc display order
     @type msg: xmpp.Protocol.Message
     @param msg: the request message
     @rtype: string
     @return: the answer
     """
     try:
         ports = self.display()
         return "you can connect to my screen at %s:%s" % (self.entity.ipaddr, ports["direct"])
     except Exception as ex:
         return build_error_message(self, ex)
Ejemplo n.º 13
0
 def message_migration_info(self, msg):
     """
     Process the libvirt URI message request.
     @type msg: xmpp.Protocol.Message
     @param msg: the received message
     @rtype: xmpp.Protocol.Message
     @return: a ready to send Message containing the result of the action
     """
     try:
         return "Sure, my libvirt URI is %s" % self.migration_info(
         )["libvirt_uri"]
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 14
0
 def message_display(self, msg):
     """
     Handle message vnc display order.
     @type msg: xmpp.Protocol.Message
     @param msg: the request message
     @rtype: string
     @return: the answer
     """
     try:
         ports = self.display()
         return "You can connect to my screen at %s:%s" % (
             self.entity.ipaddr, ports["direct"])
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 15
0
 def message_roster(self, msg):
     """
     Process the roster message request.
     @type msg: xmpp.Protocol.Message
     @param msg: the received message
     @rtype: xmpp.Protocol.Message
     @return: a ready to send Message containing the result of the action
     """
     try:
         ret = "Here is the content of my roster:\n"
         for uuid, vm in self.virtualmachines.iteritems():
             ret += " - %s (%s)\n" % (vm.name, vm.jid)
         return ret
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 16
0
 def message_roster(self, msg):
     """
     Process the roster message request.
     @type msg: xmpp.Protocol.Message
     @param msg: the received message
     @rtype: xmpp.Protocol.Message
     @return: a ready to send Message containing the result of the action
     """
     try:
         ret = "Here is the content of my roster:\n"
         for uuid, vm in self.virtualmachines.iteritems():
             ret += " - %s (%s)\n" % (vm.name, vm.jid)
         return ret
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 17
0
 def message_park_vm(self, msg):
     """
     Handle the park message for vm.
     @type msg: xmmp.Protocol.Message
     @param msg: the message
     @rtype: string
     @return: the answer
     """
     try:
         tokens = msg.getBody().split()
         if not len(tokens) == 1:
             return "I'm sorry, you use a wrong format. You can type 'help' to get help."
         self.entity.hypervisor.get_plugin("vmparking").park(self.entity.uuid, msg.getFrom())
         return "I'm parking."
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 18
0
 def message_getnics(self, msg):
     """
     Get all the nics of the hypervisor.
     @type msg: xmpp.Protocol.Message
     @param msg: the message containing the request
     @rtype: string
     @return: the answer
     """
     try:
         nics = self.getnics()
         ret = "Sure. Here are my current available network interfaces:\n"
         for n in nics:
             ret += "    - %s\n" % n
         return ret
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 19
0
 def message_get(self, msg):
     """
     Create the message response to list appliances.
     @type msg: xmpp.Protocol.Message
     @param msg: the message containing the request
     @rtype: string
     @return: the answer
     """
     try:
         appliances = self.get()
         ret = "Sure. Here are available appliances:\n"
         for app in appliances:
             ret += "    - %s (%s)\n" % (app["name"], app["uuid"])
         return ret
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 20
0
 def message_getnics(self, msg):
     """
     Get all the nics of the hypervisor.
     @type msg: xmpp.Protocol.Message
     @param msg: the message containing the request
     @rtype: string
     @return: the answer
     """
     try:
         nics = self.getnics()
         ret = "Sure. Here are my current available network interfaces:\n"
         for n in nics:
             ret += "    - %s\n" % n
         return ret
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 21
0
 def message_get(self, msg):
     """
     Create the message response to list appliances.
     @type msg: xmpp.Protocol.Message
     @param msg: the message containing the request
     @rtype: string
     @return: the answer
     """
     try:
         appliances = self.get()
         ret = "Sure. Here are available appliances:\n"
         for app in appliances:
             ret += "    - %s (%s)\n" % (app["name"], app["uuid"])
         return ret
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 22
0
 def message_health_info(self, msg):
     """
     Handle the health info request message.
     @type msg: xmmp.Protocol.Message
     @param msg: the message
     @rtype: string
     @return: the answer
     """
     try:
         tokens = msg.getBody().split()
         if len(tokens) == 1 :   limit = 1
         elif len(tokens) == 2 : limit = int(tokens[1])
         else: return "I'm sorry, you use a wrong format. You can type 'help' to get help."
         stats = self.collector.get_collected_stats(limit)
         return str(stats)
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 23
0
 def message_park_vm(self, msg):
     """
     Handle the park message for vm.
     @type msg: xmmp.Protocol.Message
     @param msg: the message
     @rtype: string
     @return: the answer
     """
     try:
         tokens = msg.getBody().split()
         if not len(tokens) == 1:
             return "I'm sorry, you use a wrong format. You can type 'help' to get help."
         vms_info = [{"uuid": self.entity.uuid, "status": ARCHIPEL_PARKING_STATUS_PARKED, "parker": str(msg.getFrom())}]
         self.entity.hypervisor.get_plugin("vmparking").park(vms_info)
         return "I'm parking."
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 24
0
 def message_park_vm(self, msg):
     """
     Handle the park message for vm.
     @type msg: xmmp.Protocol.Message
     @param msg: the message
     @rtype: string
     @return: the answer
     """
     try:
         tokens = msg.getBody().split()
         if not len(tokens) == 1:
             return "I'm sorry, you use a wrong format. You can type 'help' to get help."
         self.entity.hypervisor.get_plugin("vmparking").park(
             self.entity.uuid, msg.getFrom())
         return "I'm parking."
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 25
0
 def message_health_info(self, msg):
     """
     Handle the health info request message.
     @type msg: xmmp.Protocol.Message
     @param msg: the message
     @rtype: string
     @return: the answer
     """
     try:
         tokens = msg.getBody().split()
         if len(tokens) == 1 :   limit = 1
         elif len(tokens) == 2 : limit = int(tokens[1])
         else: return "I'm sorry, you use a wrong format. You can type 'help' to get help."
         stats = self.collector.get_collected_stats(limit)
         return str(stats)
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 26
0
 def message_create(self, msg):
     """
     Handle the creation request message.
     @type msg: xmpp.Protocol.Message
     @param msg: the received message
     @rtype: xmpp.Protocol.Message
     @return: a ready to send Message containing the result of the action
     """
     try:
         tokens = msg.getBody().split()
         if not len(tokens) == 3:
             return "I'm sorry, you use a wrong format. You can type 'help' to get help."
         identifier = tokens[-1:][0]
         self.create(identifier)
         return "Starting network %s" % identifier
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 27
0
 def message_destroy(self, msg):
     """
     Handle the destroying request message.
     @type msg: xmpp.Protocol.Message
     @param msg: the message containing the request
     @rtype: string
     @return: the answer
     """
     try:
         tokens = msg.getBody().split()
         if not len(tokens) == 3:
             return "I'm sorry, you use a wrong format. You can type 'help' to get help."
         identifier = tokens[-1:][0]
         self.destroy(identifier)
         return "Destroying network %s" % identifier
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 28
0
 def message_create(self, msg):
     """
     Handle the creation request message.
     @type msg: xmpp.Protocol.Message
     @param msg: the received message
     @rtype: xmpp.Protocol.Message
     @return: a ready to send Message containing the result of the action
     """
     try:
         tokens = msg.getBody().split()
         if not len(tokens) == 3:
             return "I'm sorry, you use a wrong format. You can type 'help' to get help."
         identifier = tokens[-1:][0]
         self.create(identifier)
         return "Starting network %s" % identifier
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 29
0
 def message_destroy(self, msg):
     """
     Handle the destroying request message.
     @type msg: xmpp.Protocol.Message
     @param msg: the message containing the request
     @rtype: string
     @return: the answer
     """
     try:
         tokens = msg.getBody().split()
         if not len(tokens) == 3:
             return "I'm sorry, you use a wrong format. You can type 'help' to get help."
         identifier = tokens[-1:][0]
         self.destroy(identifier)
         return "Destroying network %s" % identifier
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 30
0
 def message_get_logs(self, msg):
     """
     Handle the log info request message.
     @type msg: xmpp.Protocol.Iq
     @param msg: the sender request IQ
     @rtype: xmpp.Protocol.Iq
     @return: a ready-to-send IQ containing the results
     """
     try:
         tokens = msg.getBody().split()
         if len(tokens) == 1 :   limit = 1
         elif len(tokens) == 2 : limit = int(tokens[1])
         else: return "I'm sorry, you use a wrong format. You can type 'help' to get help."
         output = commands.getoutput("tail -n %d %s" % (limit, self.logfile))
         return output
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 31
0
 def message_get_logs(self, msg):
     """
     Handle the log info request message.
     @type msg: xmpp.Protocol.Iq
     @param msg: the sender request IQ
     @rtype: xmpp.Protocol.Iq
     @return: a ready-to-send IQ containing the results
     """
     try:
         tokens = msg.getBody().split()
         if len(tokens) == 1 :   limit = 1
         elif len(tokens) == 2 : limit = int(tokens[1])
         else: return "I'm sorry, you use a wrong format. You can type 'help' to get help."
         output = commands.getoutput("tail -n %d %s" % (limit, self.logfile))
         return output
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 32
0
 def message_attach(self, msg):
     """
     Attach the appliance identified by UUID from the given msg
     @type msg: xmpp.Protocol.Message
     @param msg: the message containing the request
     @rtype: string
     @return: the answer
     """
     try:
         tokens = msg.getBody().split()
         if not len(tokens) == 3:
             return "I'm sorry, you use a wrong format. You can type 'help' to get help."
         uuid = tokens[-1:][0]
         requester = msg.getFrom()
         self.attach(uuid, requester)
         return "Appliance installation as started"
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 33
0
 def message_attach(self, msg):
     """
     Attach the appliance identified by UUID from the given msg
     @type msg: xmpp.Protocol.Message
     @param msg: the message containing the request
     @rtype: string
     @return: the answer
     """
     try:
         tokens = msg.getBody().split()
         if not len(tokens) == 3:
             return "I'm sorry, you use a wrong format. You can type 'help' to get help."
         uuid = tokens[-1:][0]
         requester = msg.getFrom()
         self.attach(uuid, requester)
         return "Appliance installation as started"
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 34
0
 def message_display(self, msg):
     """
     Handle message vnc display order.
     @type msg: xmpp.Protocol.Message
     @param msg: the request message
     @rtype: string
     @return: the answer
     """
     if not self.entity.domain:
         return "You need to first define the virtual machine"
     if not self.entity.domain.info()[0] == libvirt.VIR_DOMAIN_RUNNING and not self.domain.info()[0] == libvirt.VIR_DOMAIN_BLOCKED:
         return "Virtual machine must be running."
     try:
         ports = self.display()
         ssl_support = "SSL connexion only" if ports["supportssl"] and ports["onlyssl"] else "SSL connexion supported" if ports["supportssl"] and not ports["onlyssl"] else "SSL connexion not supported"
         return "You can connect to my screen at %s:%s (%s)" % (self.entity.ipaddr, ports["proxy"],ssl_support)
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 35
0
 def message_clone(self, msg):
     """
     Handle the clone request message.
     @type msg: xmpp.Protocol.Message
     @param msg: the received message
     @rtype: xmpp.Protocol.Message
     @return: a ready to send Message containing the result of the action
     """
     try:
         tokens = msg.getBody().split(None, 1)
         if not len(tokens) == 2: return "I'm sorry, you use a wrong format. You can type 'help' to get help"
         identifier = tokens[1]
         vm = self.get_vm_by_identifier(identifier)
         if not vm: return "It seems that vm with identifer %s doesn't exists." % identifier
         self.clone(vm.uuid, msg.getFrom())
         return "Cloning of virtual machine %s has started." % (vm.jid)
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 36
0
 def message_get(self, msg):
     """
     Create the message response to list network.
     @type msg: xmpp.Protocol.Message
     @param msg: the message containing the request
     @rtype: string
     @return: the answer
     """
     try:
         networks = self.get()
         ret = "Sure. Here are my current active networks:\n"
         for net in networks["active"]:
             ret += "    - %s\n" % net
         ret += "\n and my unactive network:\n"
         for net in networks["inactive"]:
             ret += "    - %s\n" % net
         return ret
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 37
0
 def message_alloc(self, msg):
     """
     Handle the allocation request message.
     @type msg: xmpp.Protocol.Message
     @param msg: the received message
     @rtype: xmpp.Protocol.Message
     @return: a ready to send Message containing the result of the action
     """
     try:
         tokens = msg.getBody().split(None, 1)
         name = None
         if len(tokens) == 2:
             name = tokens[1]
         else:
             name = None
         vm = self.alloc(msg.getFrom(), name)
         return "Archipel VM with name %s has been allocated using JID %s" % (vm.name, vm.jid)
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 38
0
 def message_get(self, msg):
     """
     Create the message response to list network.
     @type msg: xmpp.Protocol.Message
     @param msg: the message containing the request
     @rtype: string
     @return: the answer
     """
     try:
         networks = self.get()
         ret = "Sure. Here are my current active networks:\n"
         for net in networks["active"]:
             ret += "    - %s\n" % net
         ret += "\n and my unactive network:\n"
         for net in networks["inactive"]:
             ret += "    - %s\n" % net
         return ret
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 39
0
 def message_clone(self, msg):
     """
     Handle the clone request message.
     @type msg: xmpp.Protocol.Message
     @param msg: the received message
     @rtype: xmpp.Protocol.Message
     @return: a ready to send Message containing the result of the action
     """
     try:
         tokens = msg.getBody().split(None, 1)
         if not len(tokens) == 2:
             return "I'm sorry, you use a wrong format. You can type 'help' to get help"
         identifier = tokens[1]
         vm = self.get_vm_by_identifier(identifier)
         if not vm:
             return "It seems that vm with identifer %s doesn't exists." % identifier
         self.clone(vm.uuid, msg.getFrom())
         return "Cloning of virtual machine %s has started." % (vm.jid)
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 40
0
 def message_free(self, msg):
     """
     handle the free request message
     @type msg: xmpp.Protocol.Message
     @param iq: the received message
     @rtype: xmpp.Protocol.Message
     @return: a ready to send Message containing the result of the action
     """
     try:
         tokens = msg.getBody().split(None, 1)
         if not len(tokens) == 2:
             return "I'm sorry, you use a wrong format. You can type 'help' to get help"
         identifier = tokens[1]
         vm = self.get_vm_by_identifer(identifier)
         if not vm:
             return "It seems that vm with identifer %s doesn't exists." % identifier
         self.free(vm.jid)
         return "Archipel VM with JID %s has been freed" % (vm.jid)
     except Exception as ex:
         return build_error_message(self, ex)
Ejemplo n.º 41
0
 def message_alloc(self, msg):
     """
     Handle the allocation request message.
     @type msg: xmpp.Protocol.Message
     @param msg: the received message
     @rtype: xmpp.Protocol.Message
     @return: a ready to send Message containing the result of the action
     """
     try:
         tokens = msg.getBody().split(None, 1)
         name = None
         if len(tokens) == 2:
             name = tokens[1]
         else:
             name = None
         vm = self.alloc(msg.getFrom(), name)
         return "Archipel VM with name %s has been allocated using JID %s" % (
             vm.name, vm.jid)
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 42
0
 def message_unpark(self, msg):
     """
     Handle the unpark message.
     @type msg: xmmp.Protocol.Message
     @param msg: the message
     @rtype: string
     @return: the answer
     """
     try:
         tokens = msg.getBody().split()
         if len(tokens) < 2:
             return "I'm sorry, you use a wrong format. You can type 'help' to get help."
         itemids = tokens[1].split(",")
         for itemid in itemids:
             self.unpark(itemid)
         if len(itemids) == 1:
             return "Virtual machine is unparking."
         else:
             return "Virtual machines are unparking."
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 43
0
 def message_unpark(self, msg):
     """
     Handle the unpark message.
     @type msg: xmmp.Protocol.Message
     @param msg: the message
     @rtype: string
     @return: the answer
     """
     try:
         tokens = msg.getBody().split()
         if len(tokens) < 2:
             return "I'm sorry, you use a wrong format. You can type 'help' to get help."
         itemids = tokens[1].split(",")
         for itemid in itemids:
             self.unpark(itemid)
         if len(itemids) == 1:
             return "Virtual machine is unparking."
         else:
             return "Virtual machines are unparking."
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 44
0
 def message_list(self, msg):
     """
     Handle the parking list message.
     @type msg: xmmp.Protocol.Message
     @param msg: the message
     @rtype: string
     @return: the answer
     """
     try:
         tokens = msg.getBody().split()
         if not len(tokens) == 2:
             return "I'm sorry, you use a wrong format. You can type 'help' to get help."
         parked_vms = self.list()
         resp = "Sure! Here is the virtual machines parked:\n"
         for info in parked_vms:
             ticket = info["info"]["itemid"]
             name = info["domain"].getTag("name").getData()
             uuid = info["domain"].getTag("uuid").getData()
             resp = "%s - [%s]: %s (%s)\n" % (resp, ticket, name, uuid)
         return resp
     except Exception as ex:
         return build_error_message(self, ex, msg)
Ejemplo n.º 45
0
 def message_list(self, msg):
     """
     Handle the parking list message.
     @type msg: xmmp.Protocol.Message
     @param msg: the message
     @rtype: string
     @return: the answer
     """
     try:
         tokens = msg.getBody().split()
         if not len(tokens) == 2:
             return "I'm sorry, you use a wrong format. You can type 'help' to get help."
         parked_vms = self.list()
         resp = "Sure! Here is the virtual machines parked:\n"
         for info in parked_vms:
             ticket = info["info"]["itemid"]
             name = info["domain"].getTag("name").getData()
             uuid = info["domain"].getTag("uuid").getData()
             resp = "%s - [%s]: %s (%s)\n" % (resp, ticket, name, uuid)
         return resp
     except Exception as ex:
         return build_error_message(self, ex, msg)