示例#1
0
 def test_network_create_safe(self):
     ctxt = context.get_admin_context()
     values = {'host': 'localhost', 'project_id': 'project1'}
     network = db.network_create_safe(ctxt, values)
     self.assertNotEqual(None, network.uuid)
     self.assertEqual(36, len(network.uuid))
     db_network = db.network_get(ctxt, network.id)
     self.assertEqual(network.uuid, db_network.uuid)
示例#2
0
 def test_network_create_safe(self):
     ctxt = context.get_admin_context()
     values = {'host': 'localhost', 'project_id': 'project1'}
     network = db.network_create_safe(ctxt, values)
     self.assertNotEqual(None, network.uuid)
     self.assertEqual(36, len(network.uuid))
     db_network = db.network_get(ctxt, network.id)
     self.assertEqual(network.uuid, db_network.uuid)
示例#3
0
    def create_subnet(self,
                      context,
                      label,
                      project_id,
                      quantum_net_id,
                      priority,
                      cidr=None,
                      gateway=None,
                      gateway_v6=None,
                      cidr_v6=None,
                      dns1=None,
                      dns2=None):
        """Contact Melange and create a subnet for any non-NULL
           IPv4 or IPv6 subnets.

           Also create a entry in the Engine networks DB, but only
           to store values not represented in Melange or to
           temporarily provide compatibility with Engine code that
           accesses IPAM data directly via the DB (e.g., engine-api)
        """
        tenant_id = project_id or FLAGS.quantum_default_tenant_id
        if cidr:
            self.m_conn.create_block(quantum_net_id,
                                     cidr,
                                     project_id=tenant_id,
                                     gateway=gateway,
                                     dns1=dns1,
                                     dns2=dns2)
        if cidr_v6:
            self.m_conn.create_block(quantum_net_id,
                                     cidr_v6,
                                     project_id=tenant_id,
                                     gateway=gateway_v6,
                                     dns1=dns1,
                                     dns2=dns2)

        net = {
            "uuid": quantum_net_id,
            "project_id": project_id,
            "priority": priority,
            "label": label
        }
        if FLAGS.quantum_use_dhcp:
            if cidr:
                n = IPNetwork(cidr)
                net['dhcp_start'] = IPAddress(n.first + 2)
        else:
            net['dhcp_start'] = None
        admin_context = context.elevated()
        network = db.network_create_safe(admin_context, net)
    def create_subnet(self, context, label, project_id,
                      quantum_net_id, priority, cidr=None,
                      gateway=None, gateway_v6=None, cidr_v6=None,
                      dns1=None, dns2=None):
        """Contact Melange and create a subnet for any non-NULL
           IPv4 or IPv6 subnets.

           Also create a entry in the Engine networks DB, but only
           to store values not represented in Melange or to
           temporarily provide compatibility with Engine code that
           accesses IPAM data directly via the DB (e.g., engine-api)
        """
        tenant_id = project_id or FLAGS.quantum_default_tenant_id
        if cidr:
            self.m_conn.create_block(quantum_net_id, cidr,
                                     project_id=tenant_id,
                                     gateway=gateway,
                                     dns1=dns1, dns2=dns2)
        if cidr_v6:
            self.m_conn.create_block(quantum_net_id, cidr_v6,
                                     project_id=tenant_id,
                                     gateway=gateway_v6,
                                     dns1=dns1, dns2=dns2)

        net = {"uuid": quantum_net_id,
               "project_id": project_id,
               "priority": priority,
               "label": label}
        if FLAGS.quantum_use_dhcp:
            if cidr:
                n = IPNetwork(cidr)
                net['dhcp_start'] = IPAddress(n.first + 2)
        else:
            net['dhcp_start'] = None
        admin_context = context.elevated()
        network = db.network_create_safe(admin_context, net)