Get Instance State value for Agent type

 === Parameters
 opts[:conn](EM::Connection):: Connection used to send reply

 === Return
 true:: Always return true
161984
def get_instance_state_agent_command(opts)
      result = RightScale::InstanceState.value
      CommandIO.instance.reply(opts[:conn], JSON.dump({ :result => result }) )
    rescue Exception => e
      CommandIO.instance.reply(opts[:conn], JSON.dump({ :error => e.message }) )
    end
653018
def select(self, cls, **kwargs):
        
        name = qualname(cls)
        id = first_reply(
            self.scatter('select', {'cls': name}, limit=1), cls)
        return ActorProxy(name, id, agent=self,
                          connection=self.connection, **kwargs)
1243509
def verify_policy(opts)
      result = policy.constantize.call(opts)
    rescue NameError
      result = true
    ensure
      return result
    end
1364065
def send_connection_preface
      return unless @state == :waiting_connection_preface
      @state = :connected
      emit(:frame, CONNECTION_PREFACE_MAGIC)

      payload = @local_settings.reject { |k, v| v == SPEC_DEFAULT_CONNECTION_SETTINGS[k] }
      settings(payload)
    end
270881
def alive(opts):
    '''
    
    '''

    dev = conn()

    thisproxy['conn'].connected = ping()

    if not dev.connected:
        __salt__['event.fire_master']({}, 'junos/proxy/{}/stop'.format(
            opts['proxy']['host']))
    return dev.connected
22770
def connection
      return @connection if defined? @connection

      options = {
        request: {
          timeout: Nominatim.config.timeout
        }
      }

      @connection = Faraday.new Nominatim.config.endpoint, options do |builder|
        builder.use Nominatim::Response::ParseJson
        builder.adapter Faraday.default_adapter
      end

      @connection.params[:format] = 'json'
      @connection.params[:email] = Nominatim.config.email if Nominatim.config.email
      @connection.params[:key] = Nominatim.config.key if Nominatim.config.key

      @connection.headers[:user_agent] = Nominatim.config.user_agent
      @connection.headers[:"accept-language"] = Nominatim.config.accept_language

      @connection
    end
487265
def get_monitor_info(pe, opts={})
      obj = {}

      # Common plugin information
      obj['plugin_id'] = pe.plugin_id
      obj['plugin_category'] = plugin_category(pe)
      obj['type'] = pe.config['@type']
      obj['config'] = pe.config if opts[:with_config]

      # run MONITOR_INFO in plugins' instance context and store the info to obj
      MONITOR_INFO.each_pair {|key,code|
        begin
          catch(:skip) do
            obj[key] = pe.instance_exec(&code)
          end
        rescue NoMethodError => e
          unless @first_warn
            log.error "NoMethodError in monitoring plugins", key: key, plugin: pe.class, error: e
            log.error_backtrace
            @first_warn = true
          end
        rescue => e
          log.warn "unexpected error in monitoring plugins", key: key, plugin: pe.class, error: e
        end
      }

      obj['retry'] = get_retry_info(pe.retry) if opts[:with_retry] and pe.instance_variable_defined?(:@retry)

      # include all instance variables if :with_debug_info is set
      if opts[:with_debug_info]
        iv = {}
        pe.instance_eval do
          instance_variables.each {|sym|
            next if IGNORE_ATTRIBUTES.include?(sym)
            key = sym.to_s[1..-1]  # removes first '@'
            iv[key] = instance_variable_get(sym)
          }
        end
        obj['instance_variables'] = iv
      elsif ivars = opts[:ivars]
        iv = {}
        ivars.each {|name|
          iname = "@#{name}"
          iv[name] = pe.instance_variable_get(iname) if pe.instance_variable_defined?(iname)
        }
        obj['instance_variables'] = iv
      end

      obj
    end
455371
def is_instance_running(self, instance_id):
        
        self._init_az_api()
        # Here, it's always better if we update the instance.
        vm = self._get_vm(instance_id, force_reload=True)
        # FIXME: should we rather check `vm.instance_view.statuses`
        # and search for `.code == "PowerState/running"`? or
        # `vm.instance_view.vm_agent.statuses` and search for `.code
        # == 'ProvisioningState/suceeded'`?
        return vm.provisioning_state == u'Succeeded'
1244368
def get_connection(backend=None, fail_silently=False, **kwargs):
    
    klass = perform_import(backend or active_config.EMAIL_BACKEND)
    return klass(fail_silently=fail_silently, **kwargs)
725409
def connection
        return @connection unless @connection.nil?

        options = {}
        options[:proxy] = proxy unless proxy.nil?
        options[:scheme], options[:host], options[:port]=url.scan(/(.*):\/\/(.*):([0-9]*)/).first

        @connection ||= Excon::Connection.new(options)
        #:read_timeout => self.class.read_timeout,
        #:write_timeout => self.class.write_timeout,
        #:connect_timeout => self.class.connect_timeout
      end
1013162
def show_instance(name, call=None):
    '''
    
    '''
    if call != 'action':
        raise SaltCloudSystemExit(
            'The show_instance action must be called with -a or --action.'
        )

    conn = get_conn()
    node = conn.show_instance(name).__dict__
    __utils__['cloud.cache_node'](node, __active_provider_name__, __opts__)
    return node
477803
def session_exist?
      sessions = Diplomat::Session.list
      sessions.any? { |s| s['ID'] == id }
    end
1208768
def get instance_reference, keys = nil
    if keys
      uri = Openwsman.epr_uri_for "", instance_reference
      instance_reference = Openwsman::EndPointReference.new(uri, nil, keys)
    end
    puts "@client.get #{instance_reference.class}..." if Wbem.debug
    case instance_reference
    when Openwsman::EndPointReference
      get_by_epr instance_reference
    when String
      get_by_epr Openwsman::EndPointReference.new(instance_reference)
    else
      raise "Unsupported Wbem::get #{instance_reference.class}"
    end
  end
672268
def _update(self, **kwargs):
        
        if 'value' in kwargs and self.protocol_agent_values.get('value') != \
            kwargs.get('value'):
            self.protocol_agent_values.update(value=kwargs['value'])
            return True
        return False
433252
def state(self, value):
        
        if value.upper() == ON:
            return self.SOAPAction('SetSocketSettings', 'SetSocketSettingsResult', self.controlParameters("1", "true"))
        elif value.upper() == OFF:
            return self.SOAPAction('SetSocketSettings', 'SetSocketSettingsResult', self.controlParameters("1", "false"))
        else:
            raise TypeError("State %s is not valid." % str(value))
169654
function Client (opts) {
  var self = this

  typeforce({
    url: 'String',
    otrKey: 'DSA',
    // byRootHash: 'Function',
    instanceTag: '?String',
    autoconnect: '?Boolean' // defaults to true
  }, opts)

  EventEmitter.call(this)
  this.setMaxListeners(0)

  this._url = parseURL(opts.url)
  this._autoconnect = opts.autoconnect !== false
  this._onmessage = this._onmessage.bind(this)
  this._sessions = {}
  this._otrKey = opts.otrKey
  this._fingerprint = opts.otrKey.fingerprint()
  this._connected = false
  this._instanceTag = opts.instanceTag
  this._backoff = backoff.exponential({ initialDelay: 100 })
  if (this._autoconnect) this.connect()
}
1247125
function(opts) {
  EventEmitter.call(this);
  this.opts = opts;
  this.servers = {}; // remote server info map, key: server id, value: info
  this.serversMap = {}; // remote server info map, key: serverType, value: servers array
  this.onlines = {}; // remote server online map, key: server id, value: 0/offline 1/online
  this.mailboxFactory = opts.mailboxFactory || defaultMailboxFactory;

  // filters
  this.befores = [];
  this.afters = [];

  // pending request queues
  this.pendings = {};
  this.pendingSize = opts.pendingSize || constants.DEFAULT_PARAM.DEFAULT_PENDING_SIZE;

  // connecting remote server mailbox map
  this.connecting = {};

  // working mailbox map
  this.mailboxes = {};

  this.state = STATE_INITED;
}