def take_action(self, parsed_args):
        client = self.app.client_manager.nuageclient
        neutronclient = self.app.client_manager.neutronclient

        attrs = {}
        if parsed_args.for_subnet:
            subnet_id = neutronclient.find_resource(
                'subnet', parsed_args.for_subnet)['id']
            attrs['for_subnet'] = subnet_id
        elif parsed_args.for_port:
            port_id = neutronclient.find_resource('port',
                                                  parsed_args.for_port)['id']
            attrs['for_port'] = port_id
        elif parsed_args.ports:
            attrs['ports'] = parsed_args.ports

        nuage_policy_groups = (client.list_nuage_policy_groups(
            **attrs)['nuage_policy_groups'])

        headers, columns = column_util.get_column_definitions(
            _attr_map, long_listing=False)
        return (headers, (utils.get_dict_properties(obj,
                                                    columns,
                                                    formatters=_formatters)
                          for obj in nuage_policy_groups))
 def take_action(self, parsed_args):
     client = self.app.client_manager.neutronclient
     obj = client.list_ipsec_site_connections()['ipsec_site_connections']
     headers, columns = column_util.get_column_definitions(
         _attr_map, long_listing=parsed_args.long)
     return (headers, (utils.get_dict_properties(
         s, columns, formatters=_formatters) for s in obj))
 def take_action(self, parsed_args):
     client = self.app.client_manager.neutronclient
     obj = client.list_fwaas_firewall_groups()[const.FWGS]
     headers, columns = column_util.get_column_definitions(
         _attr_map, long_listing=parsed_args.long)
     return (headers, (utils.get_dict_properties(
         s, columns, formatters=_formatters) for s in obj))
Esempio n. 4
0
 def take_action(self, parsed_args):
     client = self.app.client_manager.neutronclient
     data = client.list_sfc_port_chains()
     headers, columns = column_util.get_column_definitions(
         _attr_map, long_listing=parsed_args.long)
     return (headers, (utils.get_dict_properties(s, columns)
                       for s in data['port_chains']))
Esempio n. 5
0
 def take_action(self, parsed_args):
     client = self.app.client_manager.neutronclient
     obj = client.list_fwaas_firewall_policies()[const.FWPS]
     headers, columns = column_util.get_column_definitions(
         _attr_map, long_listing=parsed_args.long)
     return (headers, (utils.get_dict_properties(
         s, columns, formatters=_formatters) for s in obj))
Esempio n. 6
0
 def take_action(self, parsed_args):
     client = self.app.client_manager.neutronclient
     obj = client.list_network_logs()['logs']
     obj_extend = self._extend_list(obj, parsed_args)
     headers, columns = column_util.get_column_definitions(
         _attr_map, long_listing=parsed_args.long)
     return (headers, (utils.get_dict_properties(s, columns)
                       for s in obj_extend))
 def take_action(self, parsed_args):
     client = self.app.client_manager.neutronclient
     data = client.list_sfc_service_graphs()
     headers, columns = column_util.get_column_definitions(
         _attr_map, long_listing=parsed_args.long)
     return (headers,
             (utils.get_dict_properties(s, columns)
              for s in data['service_graphs']))
 def take_action(self, parsed_args):
     client = self.app.client_manager.neutronclient
     obj = client.list_sfc_flow_classifiers()
     obj_extend = self.extend_list(obj, parsed_args)
     headers, columns = column_util.get_column_definitions(
         _attr_map, long_listing=parsed_args.long)
     return (headers, (utils.get_dict_properties(
         s, columns) for s in obj_extend))
    def take_action(self, parsed_args):
        client = self.app.client_manager.nuageclient

        net_partitions = client.list_net_partitions()['net_partitions']

        headers, columns = column_util.get_column_definitions(
            _attr_map, long_listing=True)
        return (headers, (utils.get_dict_properties(obj, columns)
                          for obj in net_partitions))
Esempio n. 10
0
    def take_action(self, _):
        client = self.app.client_manager.nuageclient

        items = client.list_switchport_bindings()[RESOURCE_NAME_PLURAL]

        headers, columns = column_util.get_column_definitions(
            _attr_map, long_listing=True)
        return (headers, (utils.get_dict_properties(obj, columns)
                          for obj in items))
Esempio n. 11
0
 def take_action(self, parsed_args):
     client = self.app.client_manager.neutronclient
     obj = client.list_ipsec_site_connections()['ipsec_site_connections']
     headers, columns = column_util.get_column_definitions(
         _attr_map, long_listing=parsed_args.long)
     return (headers, (utils.get_dict_properties(s,
                                                 columns,
                                                 formatters=_formatters)
                       for s in obj))
Esempio n. 12
0
 def test_get_column_definitions_long(self):
     attr_map = (
         ('id', 'ID', column_utils.LIST_BOTH),
         ('tenant_id', 'Project', column_utils.LIST_LONG_ONLY),
         ('name', 'Name', column_utils.LIST_BOTH),
         ('summary', 'Summary', column_utils.LIST_SHORT_ONLY),
     )
     headers, columns = column_utils.get_column_definitions(
         attr_map, long_listing=True)
     self.assertEqual(['id', 'tenant_id', 'name'], columns)
     self.assertEqual(['ID', 'Project', 'Name'], headers)
Esempio n. 13
0
    def take_action(self, parsed_args):
        neutronclient = self.app.client_manager.neutronclient
        nuageclient = self.app.client_manager.nuageclient

        subnet_id = neutronclient.find_resource('subnet',
                                                parsed_args.subnet)['id']
        nuage_redirect_targets = nuageclient.list_nuage_redirect_targets(
            subnet=subnet_id)['nuage_redirect_targets']

        headers, columns = column_util.get_column_definitions(
            _attr_map, long_listing=False)
        return (headers, (utils.get_dict_properties(obj, columns,
                                                    formatters=_formatters)
                          for obj in nuage_redirect_targets))
    def take_action(self, parsed_args):
        client = self.app.client_manager.nuageclient

        mappings = client.list_project_netpartition_mappings(
        )[RESOURCE_PLURAL_NAME]
        netpartitions = client.list_net_partitions()['net_partitions']
        netpartitions = {netpart['id']: netpart for netpart in netpartitions}
        for map in mappings:
            np = netpartitions[map['net_partition_id']]
            if np:
                map['net_partition_name'] = np['name']
        headers, columns = column_util.get_column_definitions(
            _attr_map, long_listing=True)
        return (headers, (utils.get_dict_properties(obj, columns)
                          for obj in mappings))
Esempio n. 15
0
 def take_action(self, parsed_args):
     client = self.app.client_manager.neutronclient
     params = {}
     if parsed_args.project is not None:
         project_id = nc_osc_utils.find_project(
             self.app.client_manager.identity,
             parsed_args.project,
             parsed_args.project_domain,
         ).id
         params['tenant_id'] = project_id
     objs = client.list(L2_GATEWAYS, object_path,
                        retrieve_all=True, params=params)[L2_GATEWAYS]
     headers, columns = column_util.get_column_definitions(
         _attr_map, long_listing=True)
     return (headers, (osc_utils.get_dict_properties(
         s, columns, formatters=_formatters) for s in objs))
Esempio n. 16
0
 def take_action(self, parsed_args):
     client = self.app.client_manager.neutronclient
     params = {}
     if parsed_args.project is not None:
         project_id = nc_osc_utils.find_project(
             self.app.client_manager.identity,
             parsed_args.project,
             parsed_args.project_domain,
         ).id
         params['tenant_id'] = project_id
     if parsed_args.property:
         params.update(parsed_args.property)
     objs = client.list_bgpvpns(**params)[constants.BGPVPNS]
     headers, columns = column_util.get_column_definitions(
         _attr_map, long_listing=parsed_args.long)
     return (headers, (osc_utils.get_dict_properties(
         s, columns, formatters=_formatters) for s in objs))
 def take_action(self, parsed_args):
     client = self.app.client_manager.neutronclient
     list_method = getattr(client,
                           'list_bgpvpn_%s_assocs' % self._assoc_res_name)
     bgpvpn = client.find_resource(constants.BGPVPN, parsed_args.bgpvpn)
     params = {}
     if parsed_args.property:
         params.update(parsed_args.property)
     objs = list_method(bgpvpn['id'],
                        retrieve_all=True, **params)[self._resource_plural]
     transform = getattr(self, '_transform_resource', None)
     if callable(transform):
         [transform(obj) for obj in objs]
     headers, columns = column_util.get_column_definitions(
         self._attr_map, long_listing=parsed_args.long)
     return (headers, (osc_utils.get_dict_properties(
         s, columns, formatters=self._formatters) for s in objs))
Esempio n. 18
0
 def take_action(self, parsed_args):
     client = self.app.client_manager.neutronclient
     params = {}
     if parsed_args.project is not None:
         project_id = nc_osc_utils.find_project(
             self.app.client_manager.identity,
             parsed_args.project,
             parsed_args.project_domain,
         ).id
         params['tenant_id'] = project_id
     if parsed_args.property:
         params.update(parsed_args.property)
     objs = client.list_bgpvpns(**params)[constants.BGPVPNS]
     headers, columns = column_util.get_column_definitions(
         _attr_map, long_listing=parsed_args.long)
     return (headers, (osc_utils.get_dict_properties(s,
                                                     columns,
                                                     formatters=_formatters)
                       for s in objs))
Esempio n. 19
0
 def take_action(self, parsed_args):
     client = self.app.client_manager.neutronclient
     list_method = getattr(client,
                           'list_bgpvpn_%s_assocs' % self._assoc_res_name)
     bgpvpn = client.find_resource(constants.BGPVPN, parsed_args.bgpvpn)
     params = {}
     if parsed_args.property:
         params.update(parsed_args.property)
     objs = list_method(bgpvpn['id'], retrieve_all=True,
                        **params)[self._resource_plural]
     transform = getattr(self, '_transform_resource', None)
     if callable(transform):
         [transform(obj) for obj in objs]
     headers, columns = column_util.get_column_definitions(
         self._attr_map, long_listing=parsed_args.long)
     return (headers,
             (osc_utils.get_dict_properties(s,
                                            columns,
                                            formatters=self._formatters)
              for s in objs))
Esempio n. 20
0
 def take_action(self, parsed_args):
     client = self.app.client_manager.neutronclient
     obj = client.list_endpoint_groups()['endpoint_groups']
     headers, columns = column_util.get_column_definitions(
         _attr_map, long_listing=parsed_args.long)
     return (headers, (utils.get_dict_properties(s, columns) for s in obj))
 def take_action(self, parsed_args):
     client = self.app.client_manager.neutronclient
     obj = client.list_network_loggable_resources()['loggable_resources']
     headers, columns = column_util.get_column_definitions(
         _attr_map_for_loggable, long_listing=parsed_args.long)
     return (headers, (utils.get_dict_properties(s, columns) for s in obj))
Esempio n. 22
0
 def take_action(self, parsed_args):
     client = self.app.client_manager.neutronclient
     obj = client.list_network_loggable_resources()['loggable_resources']
     headers, columns = column_util.get_column_definitions(
         _attr_map_for_loggable, long_listing=parsed_args.long)
     return (headers, (utils.get_dict_properties(s, columns) for s in obj))