Ejemplo n.º 1
0
    def test_get_id_from_name(self):
        output = utils.get_id_from_name(
            cons.RT_NETWORK, 'name#77b0babc-f7e4-4c14-b250-1f18835a52c2')
        self.assertEqual('77b0babc-f7e4-4c14-b250-1f18835a52c2', output)

        output = utils.get_id_from_name(
            cons.RT_NETWORK, '77b0babc-f7e4-4c14-b250-1f18835a52c2')
        self.assertEqual('77b0babc-f7e4-4c14-b250-1f18835a52c2', output)

        output = utils.get_id_from_name(cons.RT_NETWORK, 'name@not_uuid')
        self.assertIsNone(output)

        output = utils.get_id_from_name(
            cons.RT_PORT, '77b0babc-f7e4-4c14-b250-1f18835a52c2')
        self.assertEqual('77b0babc-f7e4-4c14-b250-1f18835a52c2', output)

        output = utils.get_id_from_name(cons.RT_PORT, 'not_uuid')
        self.assertIsNone(output)
Ejemplo n.º 2
0
 def create_subnet(self, context, subnet):
     # this method is overwritten for bottom bridge subnet and external
     # subnet creation, for internal subnet, get_subnet and get_subnets
     # will do the trick
     subnet_body = subnet['subnet']
     if subnet_body['name']:
         subnet_id = t_utils.get_id_from_name(t_constants.RT_SUBNET,
                                              subnet_body['name'])
         if subnet_id:
             subnet_body['id'] = subnet_id
     b_subnet = self.core_plugin.create_subnet(context,
                                               {'subnet': subnet_body})
     return b_subnet
Ejemplo n.º 3
0
 def create_subnet(self, context, subnet):
     # this method is overwritten for bottom bridge subnet and external
     # subnet creation, for internal subnet, get_subnet and get_subnets
     # will do the trick
     subnet_body = subnet['subnet']
     if subnet_body['name']:
         subnet_id = t_utils.get_id_from_name(t_constants.RT_SUBNET,
                                              subnet_body['name'])
         if subnet_id:
             subnet_body['id'] = subnet_id
     b_subnet = self.core_plugin.create_subnet(context,
                                               {'subnet': subnet_body})
     return b_subnet
Ejemplo n.º 4
0
 def create_network(self, context, network):
     # this method is overwritten for bottom bridge network and external
     # network creation, for internal network, get_network and get_networks
     # will do the trick
     net_body = network['network']
     self._adapt_network_body(net_body)
     if net_body['name']:
         net_id = t_utils.get_id_from_name(t_constants.RT_NETWORK,
                                           net_body['name'])
         if net_id:
             net_body['id'] = net_id
     b_network = self.core_plugin.create_network(context,
                                                 {'network': net_body})
     return b_network
Ejemplo n.º 5
0
 def create_network(self, context, network):
     # this method is overwritten for bottom bridge network and external
     # network creation, for internal network, get_network and get_networks
     # will do the trick
     net_body = network['network']
     self._adapt_network_body(net_body)
     if net_body['name']:
         net_id = t_utils.get_id_from_name(t_constants.RT_NETWORK,
                                           net_body['name'])
         if net_id:
             net_body['id'] = net_id
     b_network = self.core_plugin.create_network(context,
                                                 {'network': net_body})
     return b_network