示例#1
0
 def get_all_networks(self, tenant_id, **kwargs):
     nets = []
     for x in db.network_list(tenant_id):
         LOG.debug("Adding network: %s" % x.uuid)
         nets.append(
             self._make_net_dict(str(x.uuid), x.name, None, x.op_status))
     return nets
示例#2
0
 def get_all_networks(self, tenant_id, **kwargs):
     nets = []
     for x in db.network_list(tenant_id):
         LOG.debug("Adding network: %s" % x.uuid)
         nets.append(self._make_net_dict(str(x.uuid), x.name,
                                         None, x.op_status))
     return nets
    def _verify_show_network_details(self):
            # Verification - get raw result from db
            nw = db.network_list(self.tenant_id)[0]
            network = {'id': nw.uuid,
                       'name': nw.name,
                       'op-status': nw.op_status}
            port_list = db.port_list(nw.uuid)
            if not port_list:
                network['ports'] = [{'id': '<none>',
                                     'state': '<none>',
                                     'attachment': {'id': '<none>'}}]
            else:
                network['ports'] = []
                for port in port_list:
                    network['ports'].append({'id': port.uuid,
                                             'state': port.state,
                                             'attachment': {'id':
                                                            port.interface_id
                                                            or '<none>'}})

            # Fill CLI template
            output = cli.prepare_output('show_net_detail',
                                        self.tenant_id,
                                        dict(network=network),
                                        self.version)
            # Verify!
            # Must add newline at the end to match effect of print call
            self.assertEquals(self.fake_stdout.make_string(), output + '\n')
 def _verify_show_network(self):
         # Verification - get raw result from db
         nw = db.network_list(self.tenant_id)[0]
         network = dict(id=nw.uuid, name=nw.name)
         # Fill CLI template
         output = cli.prepare_output('show_net', self.tenant_id,
                                     dict(network=network))
         # Verify!
         # Must add newline at the end to match effect of print call
         self.assertEquals(self.fake_stdout.make_string(), output + '\n')
示例#5
0
 def _verify_update_network(self):
     # Verification - get raw result from db
     nw_list = db.network_list(self.tenant_id)
     network_data = {'id': nw_list[0].uuid, 'name': nw_list[0].name}
     # Fill CLI template
     output = cli.prepare_output('update_net', self.tenant_id,
                                 dict(network=network_data))
     # Verify!
     # Must add newline at the end to match effect of print call
     self.assertEquals(self.fake_stdout.make_string(), output + '\n')
 def _verify_list_networks(self):
         # Verification - get raw result from db
         nw_list = db.network_list(self.tenant_id)
         networks = [dict(id=nw.uuid, name=nw.name) for nw in nw_list]
         # Fill CLI template
         output = cli.prepare_output('list_nets', self.tenant_id,
                                     dict(networks=networks))
         # Verify!
         # Must add newline at the end to match effect of print call
         self.assertEquals(self.fake_stdout.make_string(), output + '\n')
示例#7
0
 def _verify_show_network(self):
     # Verification - get raw result from db
     nw = db.network_list(self.tenant_id)[0]
     network = dict(id=nw.uuid, name=nw.name)
     # Fill CLI template
     output = cli.prepare_output('show_net', self.tenant_id,
                                 dict(network=network))
     # Verify!
     # Must add newline at the end to match effect of print call
     self.assertEquals(self.fake_stdout.make_string(), output + '\n')
示例#8
0
 def _verify_list_networks(self):
     # Verification - get raw result from db
     nw_list = db.network_list(self.tenant_id)
     networks = [dict(id=nw.uuid, name=nw.name) for nw in nw_list]
     # Fill CLI template
     output = cli.prepare_output('list_nets', self.tenant_id,
                                 dict(networks=networks))
     # Verify!
     # Must add newline at the end to match effect of print call
     self.assertEquals(self.fake_stdout.make_string(), output + '\n')
示例#9
0
 def _verify_delete_network(self, network_id):
     # Verification - get raw result from db
     nw_list = db.network_list(self.tenant_id)
     if len(nw_list) != 0:
         self.fail("DB should not contain any network")
     # Fill CLI template
     output = cli.prepare_output('delete_net', self.tenant_id,
                                 dict(network_id=network_id))
     # Verify!
     # Must add newline at the end to match effect of print call
     self.assertEquals(self.fake_stdout.make_string(), output + '\n')
 def _verify_delete_network(self, network_id):
         # Verification - get raw result from db
         nw_list = db.network_list(self.tenant_id)
         if len(nw_list) != 0:
             self.fail("DB should not contain any network")
         # Fill CLI template
         output = cli.prepare_output('delete_net', self.tenant_id,
                                     dict(network_id=network_id))
         # Verify!
         # Must add newline at the end to match effect of print call
         self.assertEquals(self.fake_stdout.make_string(), output + '\n')
 def _verify_update_network(self):
         # Verification - get raw result from db
         nw_list = db.network_list(self.tenant_id)
         network_data = {'id': nw_list[0].uuid,
                         'name': nw_list[0].name}
         # Fill CLI template
         output = cli.prepare_output('update_net', self.tenant_id,
                                     dict(network=network_data))
         # Verify!
         # Must add newline at the end to match effect of print call
         self.assertEquals(self.fake_stdout.make_string(), output + '\n')
示例#12
0
 def _verify_create_network(self):
     # Verification - get raw result from db
     nw_list = db.network_list(self.tenant_id)
     if len(nw_list) != 1:
         self.fail("No network created")
     network_id = nw_list[0].uuid
     # Fill CLI template
     output = cli.prepare_output('create_net', self.tenant_id,
                                 dict(network_id=network_id))
     # Verify!
     # Must add newline at the end to match effect of print call
     self.assertEquals(self.fake_stdout.make_string(), output + '\n')
示例#13
0
    def test_delete_network(self):
        try:
            db.network_create(self.tenant_id, self.network_name_1)
            network_id = db.network_list(self.tenant_id)[0]['uuid']
            cli.delete_net(self.client, self.tenant_id, network_id)
        except:
            LOG.exception("Exception caught: %s", sys.exc_info())
            self.fail("test_delete_network failed due to an exception")

        LOG.debug("Operation completed. Verifying result")
        LOG.debug(self.fake_stdout.content)
        self._verify_delete_network(network_id)
    def test_delete_network(self):
        try:
            db.network_create(self.tenant_id, self.network_name_1)
            network_id = db.network_list(self.tenant_id)[0]['uuid']
            cli.delete_net(self.client, self.tenant_id, network_id)
        except:
            LOG.exception("Exception caught: %s", sys.exc_info())
            self.fail("test_delete_network failed due to an exception")

        LOG.debug("Operation completed. Verifying result")
        LOG.debug(self.fake_stdout.content)
        self._verify_delete_network(network_id)
示例#15
0
 def get_all_networks(self, tenant_id):
     """
     Returns a dictionary containing all
     <network_uuid, network_name> for
     the specified tenant.
     """
     LOG.debug("FakePlugin.get_all_networks() called")
     nets = []
     for net in db.network_list(tenant_id):
         net_item = {"net-id": str(net.uuid), "net-name": net.name}
         nets.append(net_item)
     return nets
 def get_all_networks(self, tenant_id):
     """
     Returns a dictionary containing all
     <network_uuid, network_name> for
     the specified tenant.
     """
     LOG.debug("get_all_networks() called")
     networks = []
     for network in db.network_list(tenant_id):
         network_item = {'net-id': network.uuid, 'net-name': network.name}
         networks.append(network_item)
     return networks
 def _verify_create_network(self):
         # Verification - get raw result from db
         nw_list = db.network_list(self.tenant_id)
         if len(nw_list) != 1:
             self.fail("No network created")
         network_id = nw_list[0].uuid
         # Fill CLI template
         output = cli.prepare_output('create_net', self.tenant_id,
                                     dict(network_id=network_id))
         # Verify!
         # Must add newline at the end to match effect of print call
         self.assertEquals(self.fake_stdout.make_string(), output + '\n')
示例#18
0
 def get_all_networks(self, tenant_id):
     """Get all networks"""
     nets = []
     try:
         for net in db.network_list(tenant_id):
             LOG.debug("Getting network: %s", net.uuid)
             net_dict = {}
             net_dict["tenant_id"] = net.tenant_id
             net_dict["id"] = str(net.uuid)
             net_dict["name"] = net.name
             nets.append(net_dict)
     except Exception, exc:
         LOG.error("Failed to get all networks: %s", str(exc))
 def get_all_networks(self, tenant_id):
     """Get all networks"""
     nets = []
     try:
         for net in db.network_list(tenant_id):
             LOG.debug("Getting network: %s" % net.uuid)
             net_dict = {}
             net_dict["tenant-id"] = net.tenant_id
             net_dict["net-id"] = str(net.uuid)
             net_dict["net-name"] = net.name
             nets.append(net_dict)
     except Exception, exc:
         LOG.error("Failed to get all networks: %s" % str(exc))
示例#20
0
    def get_all_networks(self, tenant_id, **kwargs):
        """
        Returns a dictionary containing all <network_uuid, network_name> for
        the specified tenant using local persistent store.

        :param tenant_id: unique identifier for the tenant whose networks
            are being retrieved by this method
        :param **kwargs: options to be passed to the plugin. The following
            keywork based-options can be specified:
            filter_opts - options for filtering network list
        :returns: a list of mapping sequences with the following signature:
                     [ {'net-id': uuid that uniquely identifies
                                      the particular quantum network,
                        'net-name': a human-readable name associated
                                      with network referenced by net-id
                        'net-op-status': network op_status
                       },
                       ....
                       {'net-id': uuid that uniquely identifies the
                                       particular quantum network,
                        'net-name': a human-readable name associated
                                       with network referenced by net-id
                        'net-op-status': network op_status
                       }
                    ]
        :raises: None
        """
        LOG.debug("QuantumRestProxy: get_all_networks() called")

        filter_fn = None
        filter_opts = kwargs.get('filter_opts', None)
        if filter_opts is not None and len(filter_opts) > 0:
            filter_fn = self.filter_net
            LOG.debug("QuantumRestProxy: filter_opts ignored: %s" %
                      filter_opts)

        nets = []
        for net in db.network_list(tenant_id):
            if filter_fn is not None and \
               filter_fn(filter_opts, net) is None:
                continue
            net_item = {
                'net-id': str(net.uuid),
                'net-name': net.name,
                'net-op-status': net.op_status,
            }
            nets.append(net_item)
        return nets
示例#21
0
 def get_all_networks(self, tenant_id):
     """
     Returns a dictionary containing all
     <network_uuid, network_name> for
     the specified tenant.
     """
     LOG.debug("FakePlugin.get_all_networks() called")
     nets = []
     for net in db.network_list(tenant_id):
         net_item = {
             'net-id': str(net.uuid),
             'net-name': net.name,
             'net-op-status': net.op_status
         }
         nets.append(net_item)
     return nets
示例#22
0
 def _verify_list_networks_details_name_filter(self, name):
         # Verification - get raw result from db
         nw_list = db.network_list(self.tenant_id)
         nw_filtered = []
         for nw in nw_list:
             if nw.name == name:
                 nw_filtered.append(nw)
         networks = [dict(id=nw.uuid, name=nw.name) for nw in nw_filtered]
         # Fill CLI template
         output = cli.prepare_output('list_nets_detail',
                                     self.tenant_id,
                                     dict(networks=networks),
                                     self.version)
         # Verify!
         # Must add newline at the end to match effect of print call
         self.assertEquals(self.fake_stdout.make_string(), output + '\n')
示例#23
0
    def get_all_networks(self, tenant_id, **kwargs):
        """
        Returns a dictionary containing all
        <network_uuid, network_name> for
        the specified tenant.
        """
        LOG.debug("LinuxBridgePlugin.get_all_networks() called")
        networks_list = db.network_list(tenant_id)
        new_networks_list = []
        for network in networks_list:
            new_network_dict = cutil.make_net_dict(network[const.UUID],
                                                   network[const.NETWORKNAME],
                                                   [], network[const.OPSTATUS])
            new_networks_list.append(new_network_dict)

        # This plugin does not perform filtering at the moment
        return new_networks_list
示例#24
0
    def get_all_networks(self, tenant_id, **kwargs):
        """
        Returns a dictionary containing all
        <network_uuid, network_name> for
        the specified tenant.
        """
        LOG.debug("UCSVICPlugin:get_all_networks() called\n")
        self._set_ucsm(kwargs[const.DEVICE_IP])
        networks_list = db.network_list(tenant_id)
        new_networks_list = []
        for network in networks_list:
            new_network_dict = cutil.make_net_dict(network[const.UUID],
                                                   network[const.NETWORKNAME],
                                                   [])
            new_networks_list.append(new_network_dict)

        return new_networks_list
示例#25
0
    def get_all_networks(self, tenant_id, **kwargs):
        """
        Returns a dictionary containing all
        <network_uuid, network_name> for
        the specified tenant.
        """
        LOG.debug("LinuxBridgePlugin.get_all_networks() called")
        networks_list = db.network_list(tenant_id)
        new_networks_list = []
        for network in networks_list:
            new_network_dict = cutil.make_net_dict(network[const.UUID],
                                                   network[const.NETWORKNAME],
                                                   [], network[const.OPSTATUS])
            new_networks_list.append(new_network_dict)

        # This plugin does not perform filtering at the moment
        return new_networks_list
示例#26
0
    def get_all_networks(self, tenant_id, **kwargs):
        """
        Returns a dictionary containing all
        <network_uuid, network_name> for
        the specified tenant.
        """
        LOG.debug("UCSVICPlugin:get_all_networks() called\n")
        self._set_ucsm(kwargs[const.DEVICE_IP])
        networks_list = db.network_list(tenant_id)
        new_networks_list = []
        for network in networks_list:
            new_network_dict = cutil.make_net_dict(network[const.UUID],
                                                   network[const.NETWORKNAME],
                                                   [])
            new_networks_list.append(new_network_dict)

        return new_networks_list
示例#27
0
 def get_all_networks(self, tenant_id, **kwargs):
     """
     Returns a dictionary containing all
     <network_uuid, network_name> for
     the specified tenant.
     """
     LOG.debug("FakePlugin.get_all_networks() called")
     filter_opts = kwargs.get('filter_opts', None)
     if not filter_opts is None and len(filter_opts) > 0:
         LOG.debug("filtering options were passed to the plugin"
                   "but the Fake plugin does not support them")
     nets = []
     for net in db.network_list(tenant_id):
         net_item = {'net-id': str(net.uuid),
                     'net-name': net.name,
                     'net-op-status': net.op_status}
         nets.append(net_item)
     return nets