def set_power_state(self, desired_state): """Set power state of this node :param node: Ironic node one of :class:`ironic.db.models.Node` :raises: InvalidParameterValue if required seamicro parameters are missing. :raises: UcsOperationError on an error from UcsHandle Client. :returns: Power state of the given node """ rn_array = [ self.helper.service_profile, ManagedObject(NamingId.LS_POWER).MakeRn() ] try: ls_power = ucs_helper.get_managed_object( self.helper.handle, LsPower.ClassId(), {LsPower.DN: UcsUtils.MakeDn(rn_array)}) if not ls_power: raise exception.UcsOperationError( "set_power_state", "Failed to get power MO," " configure valid service-profile.") else: ls_power_set = self.helper.handle.SetManagedObject( ls_power, LsPower.ClassId(), {LsPower.STATE: desired_state}, dumpXml=YesOrNo.TRUE) if ls_power_set: power = ls_power_set.pop() return power.getattr(LsPower.STATE) else: return states.ERROR except Exception as ex: raise exception.UcsOperationError( "set_power_state", "Failed to get power MO," "configure valid servie-profile.")
def get_power_state(self): """Get current power state of this node :param node: Ironic node one of :class:`ironic.db.models.Node` :raises: InvalidParameterValue if required Ucs parameters are missing :raises: UcsOperationError: on an error from Ucs. :returns: Power state of the given node """ rn_array = [ self.helper.service_profile, ManagedObject(NamingId.LS_POWER).MakeRn() ] try: ls_power = ucs_helper.get_managed_object( self.helper.handle, LsPower.ClassId(), {LsPower.DN: UcsUtils.MakeDn(rn_array)}) if not ls_power: raise exception.UcsOperationError( "get_power_state", "Failed to get LsPower MO, configure valid " "service-profile") return ls_power[0].getattr(LsPower.STATE) except UcsException as ex: raise exception.UcsOperationError(message=ex)
def set_power_state(self, desired_state): """Set power state of this node :param node: Ironic node one of :class:`ironic.db.models.Node` :raises: InvalidParameterValue if required seamicro parameters are missing. :raises: UcsOperationError on an error from UcsHandle Client. :returns: Power state of the given node """ rn_array = [self.helper.service_profile, ManagedObject(NamingId.LS_POWER).MakeRn()] try: ls_power = ucs_helper.get_managed_object(self.helper.handle, LsPower.ClassId(), {LsPower.DN: UcsUtils.MakeDn(rn_array)}) if not ls_power: raise exception.UcsOperationError("set_power_state", "Failed to get power MO," " configure valid service-profile.") else: ls_power_set = self.helper.handle.SetManagedObject( ls_power, LsPower.ClassId(), {LsPower.STATE: desired_state}, dumpXml=YesOrNo.TRUE ) if ls_power_set: power = ls_power_set.pop() return power.getattr(LsPower.STATE) else: return states.ERROR except Exception as ex: raise exception.UcsOperationError("set_power_state", "Failed to get power MO," "configure valid servie-profile.")
def get_boot_device(self): """Get the current boot device for the node. Provides the current boot device of the node. Be aware that not all drivers support this. :raises: InvalidParameterValue if any connection parameters are incorrect. :raises: MissingParameterValue if a required parameter is missing :returns: a dictionary containing: :boot_device: the boot device, one of :mod:`ironic.common.boot_devices` or None if it is unknown. :persistent: Whether the boot device will persist to all future boots or not, None if it is unknown. """ operation = 'get_boot_device' try: boot_device = None ls_server = ucs_helper.get_managed_object( self.helper.handle, LsServer.ClassId(), {LsServer.DN: self.helper.service_profile}) if not ls_server: raise exception.UcsOperationError(operation=operation, error="Failed to get power MO, " "configure valid service-profile.") for server in ls_server: in_filter = ucs_helper.create_dn_in_filter( LsbootDef.ClassId(), "%s/" % server.getattr(LsServer.PN_DN), self) lsboot_def = ucs_helper.get_resolve_class( self.helper.handle, LsbootDef.ClassId(), in_filter, in_heir=True) if lsboot_def.errorCode == 0: for boot_def in lsboot_def.OutConfigs.GetChild(): boot_orders = boot_def.GetChild() for boot_order in boot_orders: if boot_order.getattr("Order") == "1": boot_device = boot_order.getattr("Type") break return {'boot_device': boot_device, 'persistent': None} except UcsException as ex: print(_("Cisco client exception: %(msg)s."), {'msg': ex}) raise exception.UcsOperationError(operation=operation, error=ex)
def get_power_state(self): """Get current power state of this node :param node: Ironic node one of :class:`ironic.db.models.Node` :raises: InvalidParameterValue if required Ucs parameters are missing :raises: UcsOperationError: on an error from Ucs. :returns: Power state of the given node """ rn_array = [self.helper.service_profile, ManagedObject(NamingId.LS_POWER).MakeRn()] try: ls_power = ucs_helper.get_managed_object( self.helper.handle, LsPower.ClassId(), {LsPower.DN: UcsUtils.MakeDn(rn_array)}) if not ls_power: raise exception.UcsOperationError("get_power_state", "Failed to get LsPower MO, configure valid " "service-profile") return ls_power[0].getattr(LsPower.STATE) except UcsException as ex: raise exception.UcsOperationError(message=ex)