Exemplo n.º 1
0
 def set_boot_device(self, bootdevice):
     LOG.debug(
         "Set boot device called for %(vm)s with boot "
         'device "%(bootdev)s"',
         {
             "vm": self.vm_name,
             "bootdev": bootdevice
         },
     )
     device = SET_BOOT_DEVICES_MAP.get(bootdevice)
     if device is None:
         # Invalid data field in request
         return IPMI_INVALID_DATA
     try:
         with utils.viserver_open(**self._conn_args) as conn:
             vm = utils.get_viserver_vm(conn, self.vm_name)
             utils.set_boot_device(conn, vm, device)
     except Exception as e:
         LOG.error(
             "Failed setting the boot device %(bootdev)s for vm %(vm)s."
             "Error: %(error)s",
             {
                 "bootdev": device,
                 "vm": self.vm_name,
                 "error": e
             },
         )
         # Command failed, but let client to retry
         return IPMI_COMMAND_NODE_BUSY
Exemplo n.º 2
0
 def power_reset(self):
     LOG.debug("Power reset called for vm %(vm)s", {"vm": self.vm_name})
     try:
         with utils.viserver_open(**self._conn_args) as conn:
             vm = utils.get_viserver_vm(conn, self.vm_name)
             if "poweredOn" == vm.runtime.powerState:
                 vm.Reset()
     except Exception as e:
         LOG.error(
             "Error reseting the vm %(vm)s. " "Error: %(error)s",
             {"vm": self.vm_name, "error": e},
         )
         # Command not supported in present state
         return IPMI_COMMAND_NODE_BUSY
Exemplo n.º 3
0
 def power_shutdown(self):
     LOG.debug("Soft power off called for vm %(vm)s", {"vm": self.vm_name})
     try:
         with utils.viserver_open(**self._conn_args) as conn:
             vm = utils.get_viserver_vm(conn, self.vm_name)
             if "poweredOn" == vm.runtime.powerState:
                 vm.ShutdownGuest()
     except Exception as e:
         LOG.error(
             "Error soft powering off the vm %(vm)s. " "Error: %(error)s",
             {"vm": self.vm_name, "error": e},
         )
         # Command failed, but let client to retry
         return IPMI_COMMAND_NODE_BUSY
Exemplo n.º 4
0
    def get_power_state(self):
        LOG.debug("Get power state called for vm %(vm)s", {"vm": self.vm_name})
        try:
            with utils.viserver_open(**self._conn_args) as conn:
                vm = utils.get_viserver_vm(conn, self.vm_name)
                if "poweredOn" == vm.runtime.powerState:
                    return POWERON
        except Exception as e:
            msg = "Error getting the power state of vm %(vm)s. " "Error: %(error)s" % {
                "vm": self.vm_name,
                "error": e,
            }
            LOG.error(msg)
            raise exception.VirtualBMCError(message=msg)

        return POWEROFF
Exemplo n.º 5
0
 def pulse_diag(self):
     LOG.debug("Power diag called for vm %(vm)s", {"vm": self.vm_name})
     try:
         with utils.viserver_open(**self._conn_args) as conn:
             vm = utils.get_viserver_vm(conn, self.vm_name)
             utils.send_nmi(conn, vm)
         LOG.debug(
             "The NMI will be sent to the vm %(vm)s 60 seconds later",
             {"vm": self.vm_name},
         )
     except Exception as e:
         LOG.error(
             "Error powering diag the vm %(vm)s. " "Error: %(error)s",
             {"vm": self.vm_name, "error": e},
         )
         # Command failed, but let client to retry
         return IPMI_COMMAND_NODE_BUSY
Exemplo n.º 6
0
 def get_boot_device(self):
     LOG.debug("Get boot device called for %(vm)s", {"vm": self.vm_name})
     try:
         with utils.viserver_open(**self._conn_args) as conn:
             vm = utils.get_viserver_vm(conn, self.vm_name)
             boot_element = vm.config.bootOptions.bootOrder
             boot_dev = None
             if boot_element:
                 boot_dev = utils.get_bootable_device_type(conn, boot_element[0])
             LOG.debug("Boot device is: %s" % boot_dev)
             return GET_BOOT_DEVICES_MAP.get(boot_dev, 0)
         return IPMI_COMMAND_NODE_BUSY
     except Exception as e:
         msg = "Error getting boot device of vm %(vm)s. " "Error: %(error)s" % {
             "vm": self.vm_name,
             "error": e,
         }
         LOG.error(msg)
         raise exception.VirtualBMCError(message=msg)