Formats output from _get_routers and returns a table.
182913
def get_router_table(routers):
    
    table = formatting.Table(['Datacenter', 'Hostname', 'Backend Router Id'], "Available Routers")
    for router in routers:
        datacenter = router['topLevelLocation']['longName']
        table.add_row([datacenter, router['hostname'], router['id']])
    return table
264539
def table_output(data):
    ''''''
    if type(data) == DictType:
        data = data.items()
    headings = [ item[0] for item in data ]
    rows = [ item[1] for item in data ]
    columns = zip(*rows)
    if len(columns):
        widths = [ max([ len(str(y)) for y in row ]) for row in rows ]
    else:
        widths = [ 0 for c in headings ]
    for c, heading in enumerate(headings):
        widths[c] = max(widths[c], len(heading))
    column_count = range(len(rows))
    table = [ ' '.join([ headings[c].ljust(widths[c]) for c in column_count ]) ]
    table.append(' '.join([ '=' * widths[c] for c in column_count ]))
    for column in columns:
        table.append(' '.join([ str(column[c]).ljust(widths[c]) for c in column_count ]))
    return '\n'.join(table)
132732
def get_routertypes(self, context, filters=None, fields=None,
                        sorts=None, limit=None, marker=None,
                        page_reverse=False):
        """"""
        pass
26725
def get_resources(cls):
        """"""
        exts = []
        parent = dict(member_name=ciscohostingdevicemanager.DEVICE,
                      collection_name=ciscohostingdevicemanager.DEVICES)
        controller = resource.Resource(
            RouterHostingDeviceSchedulerController(), cb_faults.FAULT_MAP)
        exts.append(extensions.ResourceExtension(
            DEVICE_L3_ROUTERS, controller, parent, path_prefix="/dev_mgr"))
        parent = dict(member_name="router",
                      collection_name=l3_const.ROUTERS)
        controller = resource.Resource(
            HostingDevicesHostingRouterController(), cb_faults.FAULT_MAP)
        exts.append(extensions.ResourceExtension(L3_ROUTER_DEVICES, controller,
                                                 parent))
        return exts
802166
def list_l3_agent_hosting_routers(self, router, **_params):
        """"""
        return self.get((self.router_path + self.L3_AGENTS) % router,
                        params=_params)
1268279
def route_tables_list_all(**kwargs):
    '''
    

    '''
    result = {}
    netconn = __utils__['azurearm.get_client']('network', **kwargs)
    try:
        tables = __utils__['azurearm.paged_object_to_list'](netconn.route_tables.list_all())

        for table in tables:
            result[table['name']] = table
    except CloudError as exc:
        __utils__['azurearm.log_cloud_error']('network', str(exc), **kwargs)
        result = {'error': str(exc)}

    return result
1048360
def _fetch_router_chunk_data(self, router_ids=None):

        

        curr_router = []
        if len(router_ids) > self.sync_routers_chunk_size:
            # fetch routers by chunks to reduce the load on server and
            # to start router processing earlier
            for i in range(0, len(router_ids),
                           self.sync_routers_chunk_size):
                routers = self.plugin_rpc.get_routers(
                                self.context, (router_ids[i:i +
                                               self.sync_routers_chunk_size]))
                LOG.debug('Processing :%r', routers)
                for r in routers:
                    curr_router.append(r)
        else:
            curr_router = self.plugin_rpc.get_routers(
                self.context, router_ids=router_ids)
        return curr_router
776219
def table(self):
        """"""
        if self._table is None:
            self._table = list(self._iter_rows())

        return self._table
532672
def get_urls(self):
        
        ret = super(SimpleRouter, self).get_urls()
        for router in self.nested_routers:
            ret.extend(router.get_urls())
        return ret
868689
def parse_routing_info(cls, records):
        
        if len(records) != 1:
            raise RoutingProtocolError("Expected exactly one record")
        record = records[0]
        routers = []
        readers = []
        writers = []
        try:
            servers = record["servers"]
            for server in servers:
                role = server["role"]
                addresses = []
                for address in server["addresses"]:
                    addresses.append(SocketAddress.parse(address, DEFAULT_PORT))
                if role == "ROUTE":
                    routers.extend(addresses)
                elif role == "READ":
                    readers.extend(addresses)
                elif role == "WRITE":
                    writers.extend(addresses)
            ttl = record["ttl"]
        except (KeyError, TypeError):
            raise RoutingProtocolError("Cannot parse routing info")
        else:
            return cls(routers, readers, writers, ttl)
799321
def _generate_route_objects_m(self, route_schema, namespace):
        """"""
        output_path = 'Routes/RouteObjects/{}.m'.format(
            fmt_route_obj_class(namespace.name))

        with self.output_to_relative_path(output_path):
            self.emit_raw(base_file_comment)

            import_classes = [
                fmt_route_obj_class(namespace.name),
                'DBStoneBase',
                'DBRequestErrors',
            ]

            for auth_type in self.namespace_to_has_route_auth_list[namespace]:
                import_classes.append(
                    fmt_routes_class(namespace.name, auth_type))

            imports_classes_m = import_classes + \
                self._get_imports_m(
                    self._get_namespace_route_imports(namespace, include_route_args=False), [])
            self._generate_imports_m(imports_classes_m)

            with self.block_m(fmt_route_obj_class(namespace.name)):
                for route in namespace.routes:
                    route_name = fmt_route_var(namespace.name, route)
                    self.emit('static DBRoute *{};'.format(route_name))
                self.emit()

                for route in namespace.routes:
                    route_name = fmt_route_var(namespace.name, route)
                    if route.version == 1:
                        route_path = route.name
                    else:
                        route_path = '{}_v{}'.format(route.name, route.version)

                    if route.deprecated:
                        deprecated = '@{}'.format('YES')
                    else:
                        deprecated = '@{}'.format('NO')

                    if not is_void_type(route.result_data_type):
                        caller = fmt_class_type(
                            route.result_data_type, suppress_ptr=True)
                        result_type = fmt_func_call(
                            caller=caller, callee='class')
                    else:
                        result_type = 'nil'

                    if not is_void_type(route.error_data_type):
                        caller = fmt_class_type(
                            route.error_data_type, suppress_ptr=True)
                        error_type = fmt_func_call(
                            caller=caller, callee='class')
                    else:
                        error_type = 'nil'

                    if is_list_type(route.arg_data_type) or is_map_type(route.arg_data_type):
                        dataStructSerialBlock = '^id(id dataStruct) {{ return {}; }}'.format(
                            self._fmt_serialization_call(
                                route.result_data_type, 'dataStruct', True))
                    else:
                        dataStructSerialBlock = 'nil'

                    if is_list_type(route.result_data_type) or is_map_type(route.result_data_type):
                        dataStructDeserialBlock = '^id(id dataStruct) {{ return {}; }}'.format(
                            self._fmt_serialization_call(
                                route.result_data_type, 'dataStruct', False))
                    else:
                        dataStructDeserialBlock = 'nil'

                    with self.block_func(
                            func=route_name,
                            args=[],
                            return_type='DBRoute *',
                            class_func=True):
                        with self.block('if (!{})'.format(route_name)):
                            with self.block(
                                    '{} = [[DBRoute alloc] init:'.format(
                                        route_name),
                                    delim=(None, None),
                                    after='];'):
                                self.emit('@\"{}\"'.format(route_path))
                                self.emit('namespace_:@\"{}\"'.format(
                                    namespace.name))
                                self.emit('deprecated:{}'.format(deprecated))
                                self.emit('resultType:{}'.format(result_type))
                                self.emit('errorType:{}'.format(error_type))

                                attrs = []
                                for field in route_schema.fields:
                                    attr_key = field.name
                                    attr_val = ("@\"{}\"".format(route.attrs
                                            .get(attr_key)) if route.attrs
                                        .get(attr_key)
                                        else 'nil')
                                    attrs.append('@\"{}\": {}'.format(
                                        attr_key, attr_val))

                                self.generate_multiline_list(
                                    attrs,
                                    delim=('attrs:@{', '}'),
                                    compact=True)

                                self.emit('dataStructSerialBlock:{}'.format(
                                    dataStructSerialBlock))
                                self.emit('dataStructDeserialBlock:{}'.format(
                                    dataStructDeserialBlock))

                        self.emit('return {};'.format(route_name))
                    self.emit()
296765
def getRoutes(self):
        
        routes = []
        try:
            out = subprocess.Popen([routeCmd, "-n"], 
                                   stdout=subprocess.PIPE).communicate()[0]
        except:
            raise Exception('Execution of command %s failed.' % ipCmd)
        lines = out.splitlines()
        if len(lines) > 1:
            headers = [col.lower() for col in lines[1].split()]
            for line in lines[2:]:
                routes.append(dict(zip(headers, line.split())))
        return routes
863639
def cli(env):
    """"""
    mgr = SoftLayer.LoadBalancerManager(env.client)

    routing_methods = mgr.get_routing_methods()
    table = formatting.KeyValueTable(['ID', 'Name'])
    table.align['ID'] = 'l'
    table.align['Name'] = 'l'
    table.sortby = 'ID'
    for routing_method in routing_methods:
        table.add_row([routing_method['id'], routing_method['name']])

    env.fout(table)
1367634
def get_data():
    

    output = []
    tables = get_tables()
    for table in tables:
        columns = get_columns(table)

        for column in columns:
            if column['name'] == 'tenant_id':
                output.append((table, column))

    return output
439281
def get_network():
    """"""
    meta = SoftLayer.MetadataManager()
    network_tables = []
    for network_func in [meta.public_network, meta.private_network]:
        network = network_func()

        table = formatting.KeyValueTable(['name', 'value'])
        table.align['name'] = 'r'
        table.align['value'] = 'l'
        table.add_row(['mac addresses',
                       formatting.listing(network['mac_addresses'],
                                          separator=',')])
        table.add_row(['router', network['router']])
        table.add_row(['vlans',
                       formatting.listing(network['vlans'], separator=',')])
        table.add_row(['vlan ids',
                       formatting.listing(network['vlan_ids'], separator=',')])
        network_tables.append(table)

    return network_tables
243410
def cli(env):
    """"""
    mgr = SoftLayer.LoadBalancerManager(env.client)

    routing_types = mgr.get_routing_types()
    table = formatting.KeyValueTable(['ID', 'Name'])
    table.align['ID'] = 'l'
    table.align['Name'] = 'l'
    table.sortby = 'ID'
    for routing_type in routing_types:
        table.add_row([routing_type['id'], routing_type['name']])
    env.fout(table)
800495
def getHostOffsets(self, hosts):
        
        info_dict = {}
        output = util.exec_command([ntpdateCmd, '-u', '-q'] + list(hosts))
        for line in output.splitlines():
            mobj = re.match('server\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}),'
                            '\s*stratum\s+(\d),.*offset\s+([\d\.-]+),'
                            '.*delay\s+([\d\.]+)\s*$', line)
            if mobj:
                host_dict = {}
                host = mobj.group(1)
                host_dict['stratum'] = int(mobj.group(2))
                host_dict['delay'] = float(mobj.group(4))
                host_dict['offset'] = float(mobj.group(3))
                info_dict[host] = host_dict
        return info_dict