Returns the state of a container.

    path
        path to the container parent directory (default: /var/lib/lxc)

        .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt '*' lxc.state name
760945
def state(name, path=None):
    '''
    
    '''
    # Don't use _ensure_exists() here, it will mess with _change_state()

    cachekey = 'lxc.state.{0}{1}'.format(name, path)
    try:
        return __context__[cachekey]
    except KeyError:
        if not exists(name, path=path):
            __context__[cachekey] = None
        else:
            cmd = 'lxc-info'
            if path:
                cmd += ' -P {0}'.format(pipes.quote(path))
            cmd += ' -n {0}'.format(name)
            ret = __salt__['cmd.run_all'](cmd, python_shell=False)
            if ret['retcode'] != 0:
                _clear_context()
                raise CommandExecutionError(
                    'Unable to get state of container \'{0}\''.format(name)
                )
            c_infos = ret['stdout'].splitlines()
            c_state = None
            for c_info in c_infos:
                stat = c_info.split(':')
                if stat[0].lower() == 'state':
                    c_state = stat[1].strip().lower()
                    break
            __context__[cachekey] = c_state
    return __context__[cachekey]
84662
def get_parent_path(index=2):  # type: (int) -> str
    
    try:
        path = _caller_path(index)
    except RuntimeError:
        path = os.getcwd()
    path = os.path.abspath(os.path.join(path, os.pardir))
    return path
984412
def get_state_id_for_port(port):
    
    parent = port.parent
    from rafcon.gui.mygaphas.items.state import StateView
    if isinstance(parent, StateView):
        return parent.model.state.state_id
1233033
def transition_to(path, current_state=self.current_state)
      path = path.to_s
      state = current_state || self
      exit_states = []

      # Find the nearest parent state on the path of the current state which
      # has a sub-state at the given path
      new_states = state.find_states(path)
      while(!new_states) do
        exit_states << state
        state = state.parent_state
        raise(StateNotFound, transition_error(path)) unless state
        new_states = state.find_states(path)
      end

      # The first time we enter a state, the state_manager gets entered as well
      new_states.unshift(self) unless has_state?

      # Can only transition to leaf states
      # TODO: transition to the initial_state of the state?
      raise(InvalidTransition, transition_error(path)) unless new_states.last.leaf?

      enter_states = new_states - exit_states
      exit_states = exit_states - new_states

      from_state = current_state
      # TODO: does it make more sense to throw an error instead of allowing
      # a transition to the current state?
      to_state = enter_states.last || from_state

      run_before_callbacks(from_state, to_state, current_event, enter_states, exit_states)

      # Set the state on the underlying resource
      self.current_state = to_state

      run_after_callbacks(from_state, to_state, current_event, enter_states, exit_states)
    end
360595
@Nonnull
    public InstallState getInstallState() {
        if (installState != null) {
            installStateName = installState.name();
            installState = null;
        }
        InstallState is = installStateName != null ? InstallState.valueOf(installStateName) : InstallState.UNKNOWN;
        return is != null ? is : InstallState.UNKNOWN;
    }
428662
def version():
    '''
    

    '''
    k = 'lxc.version'
    if not __context__.get(k, None):
        cversion = __salt__['cmd.run_all']('lxc-info --version')
        if not cversion['retcode']:
            ver = _LooseVersion(cversion['stdout'])
            if ver < _LooseVersion('1.0'):
                raise CommandExecutionError('LXC should be at least 1.0')
            __context__[k] = "{0}".format(ver)
    return __context__.get(k, None)
750541
def _make_container_root(name):
    '''
    
    '''
    path = _root(name)
    if os.path.exists(path):
        __context__['retcode'] = salt.defaults.exitcodes.SALT_BUILD_FAIL
        raise CommandExecutionError(
            'Container {0} already exists'.format(name)
        )
    else:
        try:
            os.makedirs(path)
            return path
        except OSError as exc:
            raise CommandExecutionError(
                'Unable to make container root directory {0}: {1}'
                .format(name, exc)
            )
941860
def command_path(self):
        
        rv = ''
        if self.info_name is not None:
            rv = self.info_name
        if self.parent is not None:
            rv = self.parent.command_path + ' ' + rv
        return rv.lstrip()
252548
def get_state_paths(cls, impl, working_dir):
        
        return super(BlockstackDB, cls).get_state_paths(impl, working_dir) + [
                os.path.join(working_dir, 'atlas.db'), 
                os.path.join(working_dir, 'subdomains.db'),
                os.path.join(working_dir, 'subdomains.db.queue')
            ]
852507
def state(self):
        
        return Emitter(weakref.proxy(self.lib), self.lib.jit_new_state())
965055
def ensure_container(self, name=None):
        """"""
        if get_lxc_version() < pkg_resources.parse_version('2.0.0'):
            # Nothing to do for old versions of LXC
            return

        if name is None:
            name = self.container_name

        args = [
            'lxc-create',
            '--name', name,
            '--template', 'none',
            '>', '/dev/null', '2>&1',
        ]
        os.system(' '.join(args))
901878
def wait(state)
      if !LXC::Shell.valid_state?(status.state)
        raise ArgumentError, "Invalid container state: #{state}"
      end

      run("wait", "-s", state)
    end
938735
def restoreState(self):
        
        if os.path.exists(self._stateFile):
            try:
                fp = open(self._stateFile,  'r')
                stateObj = pickle.load(fp)
            except:
                raise IOError("Failure in reading plugin state from file: %s" 
                              % self._stateFile)
            return stateObj
        return None
926667
def list_states(self, saltenv):
        '''
        
        '''
        states = set()
        for path in self.file_list(saltenv):
            if salt.utils.platform.is_windows():
                path = path.replace('\\', '/')
            if path.endswith('.sls'):
                # is an sls module!
                if path.endswith('/init.sls'):
                    states.add(path.replace('/', '.')[:-9])
                else:
                    states.add(path.replace('/', '.')[:-4])
        return sorted(states)
204653
def base_path(self):
        """"""
        return os.path.join(self.container.base_path, self.name)
925962
def wait(self, state, timeout=-1):
        

        if isinstance(state, str):
            state = state.upper()

        return _lxc.Container.wait(self, state, timeout)
16769
function(state) {
            // Check if state has explicit parent OR we try guess parent from its name
            var parent = state.parent || (/^(.+)\.[^.]+$/.exec(state.name) || [])[1];
            var isObjectParent = typeof parent === "object";
            // if parent is a object reference, then extract the name
            return isObjectParent ? parent.name : parent;
        }