Perform requested power operation.

        :param oper: Type of power button press to simulate.
                     Supported values: 'ON', 'ForceOff', 'ForceRestart' and
                     'Nmi'
        :raises: IloError, on an error from iLO.
14244
def _perform_power_op(self, oper):
        

        power_settings = {"Action": "Reset",
                          "ResetType": oper}
        systems_uri = "/rest/v1/Systems/1"

        status, headers, response = self._rest_post(systems_uri, None,
                                                    power_settings)
        if status >= 300:
            msg = self._get_extended_error(response)
            raise exception.IloError(msg)
394300
def _simulate_unitary(self, op: ops.Operation, data: _StateAndBuffer,
            indices: List[int]) -> None:
        """"""
        result = protocols.apply_unitary(
                op,
                args=protocols.ApplyUnitaryArgs(
                        data.state,
                        data.buffer,
                        indices))
        if result is data.buffer:
            data.buffer = data.state
        data.state = result
954931
def _op(self, line, op=None, offset=0):
        
        if op is None:
            op = self.op_count[line]
        return "line{}_gate{}".format(line, op + offset)
863278
def _port_op(op_name, port, protocol="TCP"):
    """"""
    _args = [op_name]
    icmp = protocol.upper() == "ICMP"
    if icmp:
        _args.append(protocol)
    else:
        _args.append('{}/{}'.format(port, protocol))
    try:
        subprocess.check_call(_args)
    except subprocess.CalledProcessError:
        # Older Juju pre 2.3 doesn't support ICMP
        # so treat it as a no-op if it fails.
        if not icmp:
            raise
475051
function operate(op, left, right){
  utils.assertType(op, 'string', 'op');
  utils.assertPresent(left, 'left');
  utils.assertPresent(right, 'right');
  return left.operate(op.val, right);
}
813186
def set_power_state(state)
      new_action = { 'Action' => 'Reset', 'ResetType' => state }
      response = rest_post('/redfish/v1/Systems/1/', body: new_action)
      response_handler(response)
      true
    end
280464
async def power(dev: Device, cmd, target, value):
    
    async def try_turn(cmd):
        state = True if cmd == "on" else False
        try:
            return await dev.set_power(state)
        except SongpalException as ex:
            if ex.code == 3:
                err("The device is already %s." % cmd)
            else:
                raise ex

    if cmd == "on" or cmd == "off":
        click.echo(await try_turn(cmd))
    elif cmd == "settings":
        settings = await dev.get_power_settings()
        print_settings(settings)
    elif cmd == "set" and target and value:
        click.echo(await dev.set_power_settings(target, value))
    else:
        power = await dev.get_power()
        click.echo(click.style(str(power), bold=power))
631908
def perform_op(method, req_hash, options={}, &blk)
      set_defaults(options)
      max_retries = options[:max_retries] || 5
      max_follows = options[:max_follows] || 10
      if options[:follow_count] && options[:follow_count] >= max_follows
        raise Rest::RestError, "Too many follows. #{options[:follow_count]}"
      end
      current_retry = 0
      current_follow = 0
      success = false
      tries = 0
      res = nil
      #  todo: typhoeus does retries in the library so it shouldn't do retries here. And we should use the max_retries here as a parameter to typhoeus
      while current_retry < max_retries && current_follow < max_follows do
        tries += 1
        begin
          res = yield blk
          res.tries = tries
          if res.code >= 300 && res.code < 400
            # try new location
            #p res.headers
            loc = res.headers["location"]
            @logger.debug "#{res.code} Received. Trying new location: #{loc}"
            if loc.nil?
              raise InvalidResponseError.new("No location header received with #{res.code} status code!")
            end
            # options.merge({:max_follows=>options[:max_follows-1]}
            options[:follow_count] ||= 0
            options[:follow_count] += 1
            res = perform_op(method, req_hash, options) do
              res = @wrapper.send(method, loc, req_hash)
            end
            #puts 'X: ' + res.inspect
            return res
          end
          # If it's here, then it's all good
          break
        rescue Rest::HttpError => ex
          if ex.code == 503
            raise ex if current_retry == max_retries - 1

            pow = (4 ** (current_retry)) * 100 # milliseconds
            #puts 'pow=' + pow.to_s
            s = rand * pow
            #puts 's=' + s.to_s
            sleep_secs = 1.0 * s / 1000.0
            #puts 'sleep for ' + sleep_secs.to_s
            current_retry += 1
            @logger.debug "#{ex.code} Received. Retrying #{current_retry} out of #{max_retries} max in #{sleep_secs} seconds."
            sleep sleep_secs
          else
            raise ex
          end
        end
      end
      res
    end
713700
def pullup(self, pin, enabled):
        
        self._validate_channel(pin)
        if enabled:
            self.gppu[int(pin/8)] |= 1 << (int(pin%8))
        else:
            self.gppu[int(pin/8)] &= ~(1 << (int(pin%8)))
        self._write_gppu()
602501
def set_host_power(self, power):
        
        if power.upper() in POWER_STATE:
            dic = {'HOST_POWER': POWER_STATE[power.upper()]}
            data = self._execute_command(
                'SET_HOST_POWER', 'SERVER_INFO', 'write', dic)
            return data
        else:
            raise exception.IloInvalidInputError(
                "Invalid input. The expected input is ON or OFF.")
919032
def set_power(self, power):
        """"""
        req_url = ENDPOINTS["setPower"].format(self.ip_address, self.zone_id)
        params = {"power": "on" if power else "standby"}
        return request(req_url, params=params)
304444
def set_power(self, sid, state):
    """"""
    sid_mask = 0x01 << (sid - 1)
    return self.set_power_mask(sid_mask, state)
1222557
def getOperation(self, ps, action):
        '''
        '''
        opName = self.getOperationName(ps, action)
        return getattr(self, opName)
224709
def powerUp(self):
        """"""
        print '%s call powerUp' % self.port
        if not self.handle:
            self._connect()

        self.isPowerDown = False

        if not self.__isOpenThreadRunning():
            self.__startOpenThread()
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)
608688
def get_power(self):
        
        response = self.raw_command(netfn=0, command=1)
        if 'error' in response:
            raise exc.IpmiException(response['error'])
        assert (response['command'] == 1 and response['netfn'] == 1)
        powerstate = 'on' if (response['data'][0] & 1) else 'off'
        return {'powerstate': powerstate}
620764
def call(self, op, args):
        
        converted = self.convert_list(args)
        return self._call(op, converted)