예제 #1
0
 def get_rbac_objects(self):
     """Generator that lists all RBAC policies for all tenants."""
     valid_actions = notification_handlers.RBAC_VALID_ACTIONS
     neutron_client = openstack_clients.get_neutronclient()
     policies = neutron_client.list_rbac_policies()['rbac_policies']
     for policy in [p for p in policies if
                    p['object_type'] == 'network' and
                    p['action'] in valid_actions]:
         yield policy
예제 #2
0
    def get_objects(self):
        neutron_client = openstack_clients.get_neutronclient()
        for port in neutron_client.list_ports()['ports']:
            # TODO(sjmc7): Remove this once we can get proper notifications
            # about DHCP ports.
            #  See https://bugs.launchpad.net/searchlight/+bug/1558790
            if port['device_owner'] == 'network:dhcp':
                continue

            yield port
예제 #3
0
    def get_objects(self):
        neutron_client = openstack_clients.get_neutronclient()
        for port in neutron_client.list_ports()['ports']:
            # TODO(sjmc7): Remove this once we can get proper notifications
            # about DHCP ports.
            #  See https://bugs.launchpad.net/searchlight/+bug/1558790
            if port['device_owner'] == 'network:dhcp':
                continue

            yield port
예제 #4
0
 def get_rbac_objects(self):
     """Generator that lists all RBAC policies for all tenants."""
     valid_actions = notification_handlers.RBAC_VALID_ACTIONS
     neutron_client = openstack_clients.get_neutronclient()
     policies = neutron_client.list_rbac_policies()['rbac_policies']
     for policy in [
             p for p in policies if p['object_type'] == 'network'
             and p['action'] in valid_actions
     ]:
         yield policy
예제 #5
0
 def get_objects(self):
     """Generator that lists all networks owned by all tenants."""
     # Neutronclient handles pagination itself; list_networks is a generator
     policies = self.get_rbac_policies()
     neutron_client = openstack_clients.get_neutronclient()
     for network in neutron_client.list_networks()['networks']:
         network['members'] = []
         network['rbac_policy'] = []
         for policy in policies[network['id']]:
             add_rbac(network, policy['target_tenant'], policy['id'])
         yield network
예제 #6
0
 def get_objects(self):
     """Generator that lists all networks owned by all tenants."""
     # Neutronclient handles pagination itself; list_networks is a generator
     policies = self.get_rbac_policies()
     neutron_client = openstack_clients.get_neutronclient()
     for network in neutron_client.list_networks()['networks']:
         network['members'] = []
         network['rbac_policy'] = []
         for policy in policies[network['id']]:
             add_rbac(network, policy['target_tenant'], policy['id'])
         yield network
 def create_or_update_from_interface(self, payload, timestamp):
     """Unfortunately there seems to be no notification for ports created
     as part of a router interface creation, nor for DHCP ports. This
     means we need to go to the API.
     """
     port_id = payload['router_interface']['port_id']
     LOG.debug("Retrieving port %s from API", port_id)
     nc = openstack_clients.get_neutronclient()
     port = nc.show_port(port_id)['port']
     serialized = serialize_port(port)
     version = self.get_version(serialized, timestamp)
     self.index_helper.save_document(serialized, version=version)
 def create_or_update_from_interface(self, payload, timestamp):
     """Unfortunately there seems to be no notification for ports created
     as part of a router interface creation, nor for DHCP ports. This
     means we need to go to the API.
     """
     port_id = payload['router_interface']['port_id']
     LOG.debug("Retrieving port %s from API", port_id)
     nc = openstack_clients.get_neutronclient()
     port = nc.show_port(port_id)['port']
     serialized = serialize_port(port)
     version = self.get_version(serialized, timestamp)
     self.index_helper.save_document(serialized, version=version)
예제 #9
0
    def get_objects(self):
        # This list of owners shamelessly taken from the Neutron code:
        #     neutron/neutron/notifiers/nova.py
        valid_owners = ('compute:', 'baremetal:')

        neutron_client = openstack_clients.get_neutronclient()
        for port in neutron_client.list_ports()['ports']:
            if (not port['device_owner']
                    or not port['device_owner'].startswith(valid_owners)):
                continue
            """The check/TODO below is superseded by the above check. When we
               flesh out the device owner check, re-enable the check below.
            # TODO(sjmc7): Remove this once we can get proper notifications
            # about DHCP ports.
            #  See https://bugs.launchpad.net/searchlight/+bug/1558790
            if port['device_owner'] == 'network:dhcp':
                continue
            """

            yield port
예제 #10
0
    def get_objects(self):
        # This list of owners shamelessly taken from the Neutron code:
        #     neutron/neutron/notifiers/nova.py
        valid_owners = ('compute:', 'baremetal:')

        neutron_client = openstack_clients.get_neutronclient()
        for port in neutron_client.list_ports()['ports']:
            if (not port['device_owner'] or
               not port['device_owner'].startswith(valid_owners)):
                continue
            """The check/TODO below is superceded by the above check. When we
               flesh out the device owner check, re-enable the check below.
            # TODO(sjmc7): Remove this once we can get proper notifications
            # about DHCP ports.
            #  See https://bugs.launchpad.net/searchlight/+bug/1558790
            if port['device_owner'] == 'network:dhcp':
                continue
            """

            yield port
예제 #11
0
 def get_objects(self):
     """Generator that lists all networks owned by all tenants."""
     # Neutronclient handles pagination itself; list_networks is a generator
     neutron_client = openstack_clients.get_neutronclient()
     for network in neutron_client.list_networks()['networks']:
         yield network
예제 #12
0
 def get_objects(self):
     """Generator that lists all networks owned by all tenants."""
     neutron_client = openstack_clients.get_neutronclient()
     for fip in neutron_client.list_floatingips()['floatingips']:
         yield fip
예제 #13
0
 def get_objects(self):
     neutron_client = openstack_clients.get_neutronclient()
     for subnet in neutron_client.list_subnets()['subnets']:
         yield subnet
예제 #14
0
 def get_objects(self):
     """Generator that lists all security groups."""
     neutron_client = openstack_clients.get_neutronclient()
     for group in neutron_client.list_security_groups()['security_groups']:
         yield group
예제 #15
0
 def get_objects(self):
     neutron_client = openstack_clients.get_neutronclient()
     for router in neutron_client.list_routers()['routers']:
         yield router
예제 #16
0
 def get_objects(self):
     """Generator that lists all networks owned by all tenants."""
     # Neutronclient handles pagination itself; list_networks is a generator
     neutron_client = openstack_clients.get_neutronclient()
     for network in neutron_client.list_networks()['networks']:
         yield network
예제 #17
0
 def get_objects(self):
     neutron_client = openstack_clients.get_neutronclient()
     for subnet in neutron_client.list_subnets()['subnets']:
         yield subnet
예제 #18
0
 def get_objects(self):
     neutron_client = openstack_clients.get_neutronclient()
     for router in neutron_client.list_routers()['routers']:
         yield router
예제 #19
0
 def get_objects(self):
     neutron_client = openstack_clients.get_neutronclient()
     for port in neutron_client.list_ports()['ports']:
         yield port