Toggle the power button of server.

        :param power: 'ON' or 'OFF'
        :raises: IloError, on an error from iLO.
540055
def set_host_power(self, power):
        
        power = power.upper()
        if (power is not None) and (power not in POWER_STATE):
            msg = ("Invalid input '%(pow)s'. "
                   "The expected input is ON or OFF." %
                   {'pow': power})
            raise exception.IloInvalidInputError(msg)

        # Check current power status, do not act if it's in requested state.
        cur_status = self.get_host_power_status()

        if cur_status == power:
            LOG.debug(self._("Node is already in '%(power)s' power state."),
                      {'power': power})
            return
        if power == 'ON' and 'PROLIANT BL' in self.get_product_name().upper():
            self._retry_until_powered_on(power)
        else:
            self._perform_power_op(POWER_STATE[power])
589347
def power_on(self, id): # pylint: disable=invalid-name,redefined-builtin
        
        schema = PowerCmdSchema()
        resp = self.service.post(self.base+str(id)+'/power/on/')
        return self.service.decode(schema, resp)
4733
def power_off(self):
        """"""
        try:
            if self.send_get_command(self._urls.command_power_standby):
                self._power = POWER_STANDBY
                self._state = STATE_OFF
                return True
            else:
                return False
        except requests.exceptions.RequestException:
            _LOGGER.error("Connection error: power off command not sent.")
            return False
762197
def on_power_source_notification(self):
        
        for weak_observer in self._weak_observers:
            observer = weak_observer()
            if observer:
                observer.on_power_sources_change(self)
                observer.on_time_remaining_change(self)
368509
def set_power_state(self, is_on, bulb=ALL_BULBS, timeout=None):
        
        with _blocking(self.lock, self.power_state, self.light_state_event,
                       timeout):
            self.send(REQ_SET_POWER_STATE,
                      bulb, '2s', '\x00\x01' if is_on else '\x00\x00')
            self.send(REQ_GET_LIGHT_STATE, ALL_BULBS, '')
        return self.power_state
78851
def turn_on(options = {})
      _check_server!
      return unless enabled?

      fail "Already active!" if active?

      _turn_on_notifiers(options)
      _env.notify_active = true
    end
990873
def _retry_until_powered_on(self, power):
        
        # If the system is in the same power state as
        # requested by the user, it gives the error
        # InvalidOperationForSystemState. To avoid this error
        # the power state is checked before power on
        # operation is performed.
        status = self.get_host_power_status()
        if (status != power):
            self._perform_power_op(POWER_STATE[power])
            return self.get_host_power_status()
        else:
            return status
449148
def reboot(env, identifier, hard):
    """"""

    hardware_server = env.client['Hardware_Server']
    mgr = SoftLayer.HardwareManager(env.client)
    hw_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'hardware')
    if not (env.skip_confirmations or
            formatting.confirm('This will power off the server with id %s. '
                               'Continue?' % hw_id)):
        raise exceptions.CLIAbort('Aborted.')

    if hard is True:
        hardware_server.rebootHard(id=hw_id)
    elif hard is False:
        hardware_server.rebootSoft(id=hw_id)
    else:
        hardware_server.rebootDefault(id=hw_id)
571507
def switch_on(self, *args):
        
        if self.on_check(*args):
            return self._switch.switch(True)
        else:
            return False
71614
def switch_off(self):
        """"""
        success = self.set_status(CONST.STATUS_OFF_INT)

        if success:
            self._json_state['status'] = CONST.STATUS_OFF

        return success
305093
def toggle_service_status(self, service_id):
        

        svc = self.client['Network_Application_Delivery_Controller_'
                          'LoadBalancer_Service']
        return svc.toggleStatus(id=service_id)
900866
def _on_power_state(self, header, payload, rest, addr):
        
        with self.lock:
            self.power_state[header.mac] = payload
            if len(self.power_state) >= self.num_bulbs:
                self.power_state_event.set()

        self.callbacks.put(EVENT_POWER_STATE, self.get_bulb(header.mac),
                           is_on=bool(payload['is_on']))
404308
def switch_off(self):
        """"""
        success = self.set_status(CONST.STATUS_CLOSED_INT)

        if success:
            self._json_state['status'] = CONST.STATUS_CLOSED

        return success
780386
def inject_nmi(self):
        
        cur_status = self.get_host_power_status()
        if cur_status != 'ON':
            raise exception.IloError("Server is not in powered on state.")

        self._perform_power_op("Nmi")
600358
def power_off(env, identifier, hard):
    """"""

    virtual_guest = env.client['Virtual_Guest']
    vsi = SoftLayer.VSManager(env.client)
    vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS')
    if not (env.skip_confirmations or
            formatting.confirm('This will power off the VS with id %s. '
                               'Continue?' % vs_id)):
        raise exceptions.CLIAbort('Aborted.')

    if hard:
        virtual_guest.powerOff(id=vs_id)
    else:
        virtual_guest.powerOffSoft(id=vs_id)
553580
def on_click(self, event):
        
        button = event["button"]
        if button == self.button_toggle:
            self.toggled = True
            if self.mode == "ip":
                self.mode = "status"
            else:
                self.mode = "ip"
        elif button == self.button_refresh:
            self.idle_time = 0
        else:
            self.py3.prevent_refresh()
320361
def switch(self, gen_mode:bool=None):
        ""
        self.gen_mode = (not self.gen_mode) if gen_mode is None else gen_mode