Get the IOS XE device's current running config.

        :return: Current IOS running config as multiline string
546713
def _get_running_config(self, split=True):
        
        conn = self._get_connection()
        config = conn.get_config(source="running")
        if config:
            root = ET.fromstring(config._raw)
            running_config = root[0][0]
            if split is True:
                rgx = re.compile("\r*\n+")
                ioscfg = rgx.split(running_config.text)
            else:
                ioscfg = running_config.text
            return ioscfg
1247697
def get_default_config(self):
        
        config = super(HostedGraphiteHandler, self).get_default_config()

        config.update({
            'apikey': '',
            'host': 'carbon.hostedgraphite.com',
            'port': 2003,
            'proto': 'tcp',
            'timeout': 15,
            'batch': 1,
            'max_backlog_multiplier': 5,
            'trim_backlog_multiplier': 4,
        })

        return config
1165792
def get_config(self):
        
        if not self._config:
            namespace = {}
            if os.path.exists(self.config_path):
                execfile(self.config_path, namespace)
            self._config = namespace.get('config') or Configuration()
        return self._config
1087941
def info(device):
    '''
    
    '''
    out = __salt__['cmd.run_all']("xfs_info {0}".format(device))
    if out.get('stderr'):
        raise CommandExecutionError(out['stderr'].replace("xfs_info:", "").strip())
    return _parse_xfs_info(out['stdout'])
767812
def getIfConfig(self):
        
        conf = {}
        try:
            out = subprocess.Popen([ipCmd, "addr", "show"], 
                                   stdout=subprocess.PIPE).communicate()[0]
        except:
            raise Exception('Execution of command %s failed.' % ipCmd)
        for line in out.splitlines():
            mobj = re.match('^\d+: (\S+):\s+<(\S*)>\s+(\S.*\S)\s*$', line)
            if mobj:
                iface = mobj.group(1)
                conf[iface] = {}
                continue
            mobj = re.match('^\s{4}link\/(.*\S)\s*$', line)
            if mobj:
                arr = mobj.group(1).split()
                if len(arr) > 0:
                    conf[iface]['type'] = arr[0]
                if len(arr) > 1:
                    conf[iface]['hwaddr'] = arr[1]
                continue
            mobj = re.match('^\s+(inet|inet6)\s+([\d\.\:A-Za-z]+)\/(\d+)($|\s+.*\S)\s*$', line)
            if mobj:
                proto = mobj.group(1)
                if not conf[iface].has_key(proto):
                    conf[iface][proto] = []
                addrinfo = {}
                addrinfo['addr'] = mobj.group(2).lower()
                addrinfo['mask'] = int(mobj.group(3))
                arr = mobj.group(4).split()
                if len(arr) > 0 and arr[0] == 'brd':
                    addrinfo['brd'] = arr[1]
                conf[iface][proto].append(addrinfo)
                continue
        return conf
504054
def get_device_configs():
    '''
    
    '''
    frames = []

    for i in range(2):
        for device in get_video_sources():
            df_device_i = get_configs(device)
            df_device_i.insert(0, 'device', str(device))
            frames.append(df_device_i)

    device_configs = pd.concat(frames).drop_duplicates()
    device_configs['label'] = device_configs.device.map(
        lambda x: x.split('/')[-1].split('-')[1].split('_')[0])
    device_configs['bitrate'] = device_configs.height.map(get_bitrate)
    return device_configs
1205993
def get_environment(self):
        
        environment = {}
        cpu_cmd = 'show proc cpu'
        mem_cmd = 'show memory statistics'
        temp_cmd = 'show env temperature status'

        output = self._send_command(cpu_cmd)
        environment.setdefault('cpu', {})
        environment['cpu'][0] = {}
        environment['cpu'][0]['%usage'] = 0.0
        for line in output.splitlines():
            if 'CPU utilization' in line:
                # CPU utilization for five seconds: 2%/0%; one minute: 2%; five minutes: 1%
                cpu_regex = r'^.*one minute: (\d+)%; five.*$'
                match = re.search(cpu_regex, line)
                environment['cpu'][0]['%usage'] = float(match.group(1))
                break

        output = self._send_command(mem_cmd)
        for line in output.splitlines():
            if 'Processor' in line:
                _, _, _, proc_used_mem, proc_free_mem = line.split()[:5]
            elif 'I/O' in line or 'io' in line:
                _, _, _, io_used_mem, io_free_mem = line.split()[:5]
        used_mem = int(proc_used_mem) + int(io_used_mem)
        free_mem = int(proc_free_mem) + int(io_free_mem)
        environment.setdefault('memory', {})
        environment['memory']['used_ram'] = used_mem
        environment['memory']['available_ram'] = free_mem

        environment.setdefault('temperature', {})
        # The 'show env temperature status' is not ubiquitous in Cisco IOS
        output = self._send_command(temp_cmd)
        if '% Invalid' not in output:
            for line in output.splitlines():
                if 'System Temperature Value' in line:
                    system_temp = float(line.split(':')[1].split()[0])
                elif 'Yellow Threshold' in line:
                    system_temp_alert = float(line.split(':')[1].split()[0])
                elif 'Red Threshold' in line:
                    system_temp_crit = float(line.split(':')[1].split()[0])
            env_value = {'is_alert': system_temp >= system_temp_alert,
                         'is_critical': system_temp >= system_temp_crit, 'temperature': system_temp}
            environment['temperature']['system'] = env_value
        else:
            env_value = {'is_alert': False, 'is_critical': False, 'temperature': -1.0}
            environment['temperature']['invalid'] = env_value

        # Initialize 'power' and 'fan' to default values (not implemented)
        environment.setdefault('power', {})
        environment['power']['invalid'] = {'status': True, 'output': -1.0, 'capacity': -1.0}
        environment.setdefault('fans', {})
        environment['fans']['invalid'] = {'status': True}

        return environment
1052734
def get_default_config(self):
        
        config = super(EximCollector, self).get_default_config()
        config.update({
            'path':            'exim',
            'bin':              '/usr/sbin/exim',
            'use_sudo':         False,
            'sudo_cmd':         '/usr/bin/sudo',
            'sudo_user':        'root',
        })
        return config
1092568
def show_run():
    '''
    
    '''
    try:
        enable()
        configure_terminal()
        ret = sendline('show running-config')
        configure_terminal_exit()
        disable()
    except TerminalException as e:
        log.error(e)
        return 'Failed to show running-config on switch'
    return ret
506290
def get_config(cli_args=None, config_path=None):
    
    config = Config(app_name="MYAPP",
                    cli_args=cli_args,
                    config_path=config_path)
    config_dict = config.get_config()
    return config_dict
1040114
def get_configuration(self):
        
        mapping = {}
        settings = self.get_settings()
        for service in self.context.getService():
            uid = api.get_uid(service)
            setting = settings.get(uid, {})
            config = {
                "hidden": setting.get("hidden", False),
            }
            mapping[uid] = config
        return mapping
554996
def get_default_config(self):
        
        config = super(GraphiteHandler, self).get_default_config()

        config.update({
            'host': 'localhost',
            'port': 2003,
            'proto': 'tcp',
            'timeout': 15,
            'batch': 1,
            'max_backlog_multiplier': 5,
            'trim_backlog_multiplier': 4,
            'keepalive': 0,
            'keepaliveinterval': 10,
            'flow_info': 0,
            'scope_id': 0,
            'reconnect_interval': 0,
        })

        return config
542673
def get_config(self):
        ''
        return (self.bus.read_byte_data(self.address, self.CONTROL_PORT0), self.bus.read_byte_data(self.address, self.CONTROL_PORT1));
103383
def get_default_config(self):
        
        config = super(MemoryLxcCollector, self).get_default_config()
        config.update({
            "path":     "lxc",
            "sys_path": "/sys/fs/cgroup/lxc",
        })
        return config
1086812
def get_default_config(self):
        
        config = super(CPUCollector, self).get_default_config()
        config.update({
            'path':     'cpu',
            'percore':  'True',
            'xenfix':   None,
            'simple':   'False',
            'normalize': 'False',
        })
        return config
1321370
def compare_config(self):
        """"""
        diff = self.device.cu.diff()

        if diff is None:
            return ''
        else:
            return diff.strip()
1200063
def get_default_config(self):
        
        config = super(zmqHandler, self).get_default_config()

        config.update({
            'port': 1234,
        })

        return config