Usage: tunnel open
               tunnel change
               tunnel status
516101
def do_tunnel(self, arg):
        
        if arg['open']:
            self.tunnel_open()
        elif arg['change']:
            self.tunnel_change()
        elif arg['status']:
            self.tunnel_status()
77933
public void open() throws JSchException {
        if ( isOpen() ) {
            return;
        }
        session = sessionFactory.newSession();

        logger.debug( "connecting session" );
        session.connect();

        for ( Tunnel tunnel : tunnels ) {
            int assignedPort = 0;
            if ( tunnel.getLocalAlias() == null ) {
                assignedPort = session.setPortForwardingL(
                        tunnel.getLocalPort(),
                        tunnel.getDestinationHostname(),
                        tunnel.getDestinationPort() );
            }
            else {
                assignedPort = session.setPortForwardingL(
                        tunnel.getLocalAlias(),
                        tunnel.getLocalPort(),
                        tunnel.getDestinationHostname(),
                        tunnel.getDestinationPort() );
            }
            tunnel.setAssignedLocalPort( assignedPort );
            logger.debug( "added tunnel {}", tunnel );
        }
        logger.info( "forwarding {}", this );
    }
456574
def set_status(self, enabled):
        """"""
        self.__manual_update_time = time.time()
        if enabled:
            data = self._controller.command(self._id,
                                            'auto_conditioning_start',
                                            wake_if_asleep=True)
            if data['response']['result']:
                self.__is_auto_conditioning_on = True
                self.__is_climate_on = True
        else:
            data = self._controller.command(self._id,
                                            'auto_conditioning_stop',
                                            wake_if_asleep=True)
            if data['response']['result']:
                self.__is_auto_conditioning_on = False
                self.__is_climate_on = False
        self.update()
850374
def __update_state(self):
    """"""
    # Only if the job was not in a terminal state.
    if self._state.active:
      self._state = self.__get_state_by_id(self.job_config.job_id)
512397
def open
      status = system(env, *Shellwords.split(command_path))
      return status if status
      fail CommandInvocationError,
           "`#{command_path}` failed with status: #{$? ? $?.exitstatus : nil}"
    end
138972
def change_status(self, bucket, key, status, cond):
        
        resource = entry(bucket, key)
        if cond and isinstance(cond, dict):
            condstr = ""
            for k, v in cond.items():
                condstr += "{0}={1}&".format(k, v)
            condstr = urlsafe_base64_encode(condstr[:-1])
            return self.__rs_do('chstatus', resource, 'status/{0}'.format(status), 'cond', condstr)
        return self.__rs_do('chstatus', resource, 'status/{0}'.format(status))
1076513
def set_state_from_exit_status(self, status, notif_period, hosts, services):
        
        now = time.time()

        # we should put in last_state the good last state:
        # if not just change the state by an problem/impact
        # we can take current state. But if it's the case, the
        # real old state is self.state_before_impact (it's the TRUE
        # state in fact)
        # but only if the global conf have enable the impact state change
        cls = self.__class__
        if cls.enable_problem_impacts_states_change \
                and self.is_impact \
                and not self.state_changed_since_impact:
            self.last_state = self.state_before_impact
        else:  # standard case
            self.last_state = self.state

        # The last times are kept as integer values rather than float... no need for ms!
        if status == 0:
            self.state = u'OK'
            self.state_id = 0
            self.last_time_ok = int(self.last_state_update)
            # self.last_time_ok = self.last_state_update
            state_code = 'o'
        elif status == 1:
            self.state = u'WARNING'
            self.state_id = 1
            self.last_time_warning = int(self.last_state_update)
            # self.last_time_warning = self.last_state_update
            state_code = 'w'
        elif status == 2:
            self.state = u'CRITICAL'
            self.state_id = 2
            self.last_time_critical = int(self.last_state_update)
            # self.last_time_critical = self.last_state_update
            state_code = 'c'
        elif status == 3:
            self.state = u'UNKNOWN'
            self.state_id = 3
            self.last_time_unknown = int(self.last_state_update)
            # self.last_time_unknown = self.last_state_update
            state_code = 'u'
        elif status == 4:
            self.state = u'UNREACHABLE'
            self.state_id = 4
            self.last_time_unreachable = int(self.last_state_update)
            # self.last_time_unreachable = self.last_state_update
            state_code = 'x'
        else:
            self.state = u'CRITICAL'  # exit code UNDETERMINED
            self.state_id = 2
            self.last_time_critical = int(self.last_state_update)
            # self.last_time_critical = self.last_state_update
            state_code = 'c'

        if state_code in self.flap_detection_options:
            self.add_flapping_change(self.state != self.last_state)
            # Now we add a value, we update the is_flapping prop
            self.update_flapping(notif_period, hosts, services)
        if self.state != self.last_state:
            self.last_state_change = self.last_state_update

        self.duration_sec = now - self.last_state_change
641999
private void setStatus(ConnectionStatus status){
        if(LOGGER.isDebugEnabled()){
            LOGGER.debug("Set status to - " + status);
        }
        if(! this.status.equals(status)){
            ConnectionStatus pre = this.status;
            this.status = status;
            eventThread.queueClientEvent(new ClientStatusEvent(pre, status));
        }
    }
1203744
def set_status(self, status, origin=None, force=False):
        

        if not self.slave and origin not in self.program_stack:
            raise ValueError('Status cannot be changed directly')

        with self._actuator_status_lock:
            self.logger.debug("set_status got through, program: %s", origin)
            self.logger.debug("Set_status %s %s %s", self.name, origin, status)

            if self.slave:
                return self._do_change_status(status, force)

            self.logger.debug("Sets status %s for %s", status, origin.name)

            with self._program_lock:
                self.program_status[origin] = status

                if self.program == origin:
                    return self._do_change_status(status, force)
468330
def update_state(self):
        """"""
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.settimeout(self._timeout)
        try:
            if sock.connect_ex((self._ip, self._port['state'])) == 0:
                self.state = True
            else:
                self.state = False
            sock.close()
        except socket.error:
            raise
138449
def updateRouterStatus(self):
        """"""
        print '%s call updateRouterStatus' % self.port
        cmd = 'state'
        while True:
            state = self.__sendCommand(cmd)[0]
            if state == 'detached':
                continue
            elif state == 'child':
                break
            else:
                return False

        cmd = 'state router'
        return self.__sendCommand(cmd)[0] == 'Done'
1002509
function commit_tunnel() {
            tunnel.onstatechange = chained_tunnel.onstatechange;
            tunnel.oninstruction = chained_tunnel.oninstruction;
            tunnel.onerror = chained_tunnel.onerror;
            chained_tunnel.uuid = tunnel.uuid;
            committedTunnel = tunnel;
        }
892496
def update_connected(self, status):
        """"""
        self._client['connected'] = status
        _LOGGER.info('updated connected status to %s on %s', status, self.friendly_name)
        self.callback()
996345
def update_ipsec_site_connection(self, ipsecsite_conn, body=None):
        """"""
        return self.put(
            self.ipsec_site_connection_path % (ipsecsite_conn), body=body
        )
590705
def set_status(self, status):
        

        text = ""
        colour = "#FFFFFF"
        if status == 0:
            text = "OFFLINE"
            colour = "#EF9A9A"
        elif status == 1:
            text = "STARTING"
            colour = "#FFE082"
        elif status == 2:
            text = "ONLINE"
            colour = "#A5D6A7"

        self.status.set(text)
        self.statusbar.config(background=colour)
733479
private void initChannelStatus() {
        String path = null;
        try {
            path = StagePathUtils.getChannel(getPipelineId());
            byte[] bytes = zookeeper.readData(path);
            initChannelStatus(bytes);
        } catch (ZkNoNodeException e) {
            channelStatus = ChannelStatus.STOP;
            permitSem();
        } catch (ZkException e) {
            logger.error(path, e);
        }
    }
1033544
def openssh_tunnel(self, lport, rport, server, remoteip='127.0.0.1',
                   keyfile=None, password=None, timeout=0.4):
    
    ssh = "ssh "
    if keyfile:
        ssh += "-i " + keyfile

    if ':' in server:
        server, port = server.split(':')
        ssh += " -p %s" % port

    cmd = "%s -O check %s" % (ssh, server)
    (output, exitstatus) = pexpect.run(cmd, withexitstatus=True)
    if not exitstatus:
        pid = int(output[output.find("(pid=")+5:output.find(")")])
        cmd = "%s -O forward -L 127.0.0.1:%i:%s:%i %s" % (
            ssh, lport, remoteip, rport, server)
        (output, exitstatus) = pexpect.run(cmd, withexitstatus=True)
        if not exitstatus:
            atexit.register(_stop_tunnel, cmd.replace("-O forward",
                                                      "-O cancel",
                                                      1))
            return pid
    cmd = "%s -f -S none -L 127.0.0.1:%i:%s:%i %s sleep %i" % (
                                  ssh, lport, remoteip, rport, server, timeout)

    # pop SSH_ASKPASS from env
    env = os.environ.copy()
    env.pop('SSH_ASKPASS', None)

    ssh_newkey = 'Are you sure you want to continue connecting'
    tunnel = pexpect.spawn(cmd, env=env)
    failed = False
    while True:
        try:
            i = tunnel.expect([ssh_newkey, '[Pp]assword:'], timeout=.1)
            if i == 0:
                host = server.split('@')[-1]
                question = _("The authenticity of host <b>%s</b> can't be "
                             "established. Are you sure you want to continue "
                             "connecting?") % host
                reply = QMessageBox.question(self, _('Warning'), question,
                                             QMessageBox.Yes | QMessageBox.No,
                                             QMessageBox.No)
                if reply == QMessageBox.Yes:
                    tunnel.sendline('yes')
                    continue
                else:
                    tunnel.sendline('no')
                    raise RuntimeError(
                       _("The authenticity of the host can't be established"))
            if i == 1 and password is not None:
                tunnel.sendline(password)
        except pexpect.TIMEOUT:
            continue
        except pexpect.EOF:
            if tunnel.exitstatus:
                raise RuntimeError(_("Tunnel '%s' failed to start") % cmd)
            else:
                return tunnel.pid
        else:
            if failed or password is None:
                raise RuntimeError(_("Could not connect to remote host"))
                # TODO: Use this block when pyzmq bug #620 is fixed
                # # Prompt a passphrase dialog to the user for a second attempt
                # password, ok = QInputDialog.getText(self, _('Password'),
                #             _('Enter password for: ') + server,
                #             echo=QLineEdit.Password)
                # if ok is False:
                #      raise RuntimeError('Could not connect to remote host.')
            tunnel.sendline(password)
            failed = True