Example #1
0
    def test_delete_objects_removes_all_matching_objects(self):
        # create some objects with identical description
        for i in range(10):
            api.create_object(
                self.ctxt, self.model,
                {'name': 'foo%d' % i, 'description': 'bar'})
        # create some more objects with a different description
        descriptions = set()
        for i in range(10, 20):
            desc = 'bar%d' % i
            descriptions.add(desc)
            api.create_object(
                self.ctxt, self.model,
                {'name': 'foo%d' % i, 'description': desc})
        # make sure that all objects are in the database
        self.assertEqual(20, api.count(self.ctxt, self.model))
        # now delete just those with the 'bar' description
        api.delete_objects(self.ctxt, self.model, description='bar')

        # check that half of objects are gone, and remaining have expected
        # descriptions
        objs = api.get_objects(self.ctxt, self.model)
        self.assertEqual(10, len(objs))
        self.assertEqual(
            descriptions,
            {obj.description for obj in objs})
Example #2
0
 def _create_shared_network_rbac_entry(self, network):
     attrs = {
         'object_id': network['id'],
         'target_tenant': '*',
         'action': rbac_db_models.ACCESS_SHARED
     }
     obj_db_api.create_object(net_obj.NetworkRBAC, self.context, attrs)
Example #3
0
 def _create_shared_network_rbac_entry(self, network):
     attrs = {
         'object_id': network['id'],
         'target_tenant': '*',
         'action': rbac_db_models.ACCESS_SHARED
     }
     obj_db_api.create_object(net_obj.NetworkRBAC, self.context, attrs)
Example #4
0
    def test_delete_objects_removes_all_matching_objects(self):
        # create some objects with identical description
        for i in range(10):
            api.create_object(self.ctxt, self.model, {
                'name': 'foo%d' % i,
                'description': 'bar'
            })
        # create some more objects with a different description
        descriptions = set()
        for i in range(10, 20):
            desc = 'bar%d' % i
            descriptions.add(desc)
            api.create_object(self.ctxt, self.model, {
                'name': 'foo%d' % i,
                'description': desc
            })
        # make sure that all objects are in the database
        self.assertEqual(20, api.count(self.ctxt, self.model))
        # now delete just those with the 'bar' description
        api.delete_objects(self.ctxt, self.model, description='bar')

        # check that half of objects are gone, and remaining have expected
        # descriptions
        objs = api.get_objects(self.ctxt, self.model)
        self.assertEqual(10, len(objs))
        self.assertEqual(descriptions, {obj.description for obj in objs})
Example #5
0
 def test_get_values_with_None_value_in_filters(self):
     api.create_object(self.obj_cls, self.ctxt, {'name': 'foo'})
     values = api.get_values(self.obj_cls,
                             self.ctxt,
                             'name',
                             name='foo',
                             status=None)
     self.assertEqual('foo', values[0])
Example #6
0
 def test_populate_id(self, populate_id=True):
     ctxt = context.get_admin_context()
     model_cls = mock.Mock()
     values = {'x': 1, 'y': 2, 'z': 3}
     with mock.patch.object(ctxt.__class__, 'session'):
         api.create_object(ctxt, model_cls, values, populate_id=populate_id)
     expected = copy.copy(values)
     if populate_id:
         expected['id'] = mock.ANY
     model_cls.assert_called_with(**expected)
Example #7
0
 def _set_dns_domain(self, dns_domain):
     obj_db_api.delete_objects(
         self.obj_context, dns_db.NetworkDNSDomain, network_id=self.id,
     )
     if dns_domain:
         obj_db_api.create_object(
             self.obj_context, dns_db.NetworkDNSDomain,
             {'network_id': self.id, 'dns_domain': dns_domain}
         )
     self.dns_domain = dns_domain
     self.obj_reset_changes(['dns_domain'])
Example #8
0
    def test_get_objects_with_string_matching_filters_ends(self):
        obj1 = api.create_object(self.obj_cls, self.ctxt, {'name': 'obj1_end'})
        obj2 = api.create_object(self.obj_cls, self.ctxt, {'name': 'obj2_end'})
        api.create_object(self.obj_cls, self.ctxt, {'name': 'obj_3'})

        objs = api.get_objects(
            self.obj_cls, self.ctxt, name=obj_utils.StringEnds('end'),
            _pager=base.Pager(sorts=[('name', True)]))
        self.assertEqual(2, len(objs))
        self._compare_objs(obj1, objs[0])
        self._compare_objs(obj2, objs[1])
Example #9
0
    def test_get_objects_with_string_matching_filters_ends(self):
        obj1 = api.create_object(self.obj_cls, self.ctxt, {'name': 'obj1_end'})
        obj2 = api.create_object(self.obj_cls, self.ctxt, {'name': 'obj2_end'})
        obj3 = api.create_object(self.obj_cls, self.ctxt, {'name': 'obj_3'})

        objs = api.get_objects(
            self.obj_cls, self.ctxt, name=obj_utils.StringEnds('end'))
        self.assertEqual(2, len(objs))
        self.assertIn(obj1, objs)
        self.assertIn(obj2, objs)
        self.assertNotIn(obj3, objs)
Example #10
0
 def test_populate_id(self, populate_id=True):
     ctxt = context.get_admin_context()
     model_cls = mock.Mock()
     values = {'x': 1, 'y': 2, 'z': 3}
     with mock.patch.object(ctxt.__class__, 'session'):
         api.create_object(ctxt, model_cls, values,
                           populate_id=populate_id)
     expected = copy.copy(values)
     if populate_id:
         expected['id'] = mock.ANY
     model_cls.assert_called_with(**expected)
Example #11
0
    def test_get_objects_with_string_matching_filters_ends(self):
        obj1 = api.create_object(self.ctxt, self.model, {'name': 'obj1_end'})
        obj2 = api.create_object(self.ctxt, self.model, {'name': 'obj2_end'})
        obj3 = api.create_object(self.ctxt, self.model, {'name': 'obj_3'})

        objs = api.get_objects(
            self.ctxt, self.model, name=obj_utils.StringEnds('end'))
        self.assertEqual(2, len(objs))
        self.assertIn(obj1, objs)
        self.assertIn(obj2, objs)
        self.assertNotIn(obj3, objs)
Example #12
0
    def test_get_objects_with_string_matching_filters_starts(self):
        obj1 = api.create_object(self.obj_cls, self.ctxt, {'name': 'pre_obj1'})
        obj2 = api.create_object(self.obj_cls, self.ctxt, {'name': 'pre_obj2'})
        obj3 = api.create_object(self.obj_cls, self.ctxt, {'name': 'obj_3'})

        objs = api.get_objects(
            self.obj_cls, self.ctxt, name=obj_utils.StringStarts('pre'))
        self.assertEqual(2, len(objs))
        self.assertIn(obj1, objs)
        self.assertIn(obj2, objs)
        self.assertNotIn(obj3, objs)
Example #13
0
 def _set_dns_domain(self, dns_domain):
     obj_db_api.delete_objects(
         self.obj_context, dns_db.NetworkDNSDomain, network_id=self.id,
     )
     if dns_domain:
         obj_db_api.create_object(
             self.obj_context, dns_db.NetworkDNSDomain,
             {'network_id': self.id, 'dns_domain': dns_domain}
         )
     self.dns_domain = dns_domain
     self.obj_reset_changes(['dns_domain'])
Example #14
0
    def test_get_objects_with_string_matching_filters_starts(self):
        obj1 = api.create_object(self.ctxt, self.model, {'name': 'pre_obj1'})
        obj2 = api.create_object(self.ctxt, self.model, {'name': 'pre_obj2'})
        obj3 = api.create_object(self.ctxt, self.model, {'name': 'obj_3'})

        objs = api.get_objects(self.ctxt,
                               self.model,
                               name=obj_utils.StringStarts('pre'))
        self.assertEqual(2, len(objs))
        self.assertIn(obj1, objs)
        self.assertIn(obj2, objs)
        self.assertNotIn(obj3, objs)
Example #15
0
 def _attach_qos_policy(self, qos_policy_id):
     # TODO(ihrachys): introduce an object for the binding to isolate
     # database access in a single place, currently scattered between port
     # and policy objects
     obj_db_api.delete_objects(
         self.obj_context, qos_models.QosPortPolicyBinding, port_id=self.id)
     if qos_policy_id:
         obj_db_api.create_object(
             self.obj_context, qos_models.QosPortPolicyBinding,
             {'port_id': self.id, 'policy_id': qos_policy_id}
         )
     self.qos_policy_id = qos_policy_id
     self.obj_reset_changes(['qos_policy_id'])
Example #16
0
 def _attach_qos_policy(self, qos_policy_id):
     # TODO(ihrachys): introduce an object for the binding to isolate
     # database access in a single place, currently scattered between port
     # and policy objects
     obj_db_api.delete_objects(
         self.obj_context, qos_models.QosPortPolicyBinding, port_id=self.id)
     if qos_policy_id:
         obj_db_api.create_object(
             self.obj_context, qos_models.QosPortPolicyBinding,
             {'port_id': self.id, 'policy_id': qos_policy_id}
         )
     self.qos_policy_id = qos_policy_id
     self.obj_reset_changes(['qos_policy_id'])
Example #17
0
 def test_get_objects_with_None_value_in_filters(self):
     obj = api.create_object(self.ctxt, self.model, {'name': 'foo'})
     new_objs = api.get_objects(self.ctxt,
                                self.model,
                                name='foo',
                                status=None)
     self.assertEqual(obj, new_objs[0])
Example #18
0
    def test_get_object_create_update_delete(self):
        obj = api.create_object(self.ctxt, self.model, {'name': 'foo'})

        new_obj = api.get_object(self.ctxt, self.model, id=obj.id)
        self.assertEqual(obj, new_obj)

        obj = new_obj
        api.update_object(self.ctxt, self.model, {'name': 'bar'}, id=obj.id)

        new_obj = api.get_object(self.ctxt, self.model, id=obj.id)
        self.assertEqual(obj, new_obj)

        obj = new_obj
        api.delete_object(self.ctxt, self.model, id=obj.id)

        new_obj = api.get_object(self.ctxt, self.model, id=obj.id)
        self.assertIsNone(new_obj)

        # delete_object raises an exception on missing object
        self.assertRaises(
            n_exc.ObjectNotFound,
            api.delete_object, self.ctxt, self.model, id=obj.id)

        # but delete_objects does not not
        api.delete_objects(self.ctxt, self.model, id=obj.id)
Example #19
0
    def _create_port(self, **port_attrs):
        if not hasattr(self, '_mac_address_generator'):
            self._mac_address_generator = (":".join(["%02x" % i] * 6)
                                           for i in itertools.count())

        if not hasattr(self, '_port_name_generator'):
            self._port_name_generator = ("test-port%d" % i
                                         for i in itertools.count(1))

        attrs = {
            'tenant_id': 'fake_tenant_id',
            'admin_state_up': True,
            'status': 'ACTIVE',
            'device_id': 'fake_device',
            'device_owner': 'fake_owner'
        }
        attrs.update(port_attrs)

        if 'name' not in attrs:
            attrs['name'] = next(self._port_name_generator)
        if 'mac_address' not in attrs:
            attrs['mac_address'] = next(self._mac_address_generator)

        # TODO(ihrachys): replace with port.create() once we get an object
        # implementation for ports
        return obj_db_api.create_object(self.context, models_v2.Port, attrs)
Example #20
0
    def test_get_object_create_update_delete(self):
        obj = api.create_object(self.ctxt, self.model, {'name': 'foo'})

        new_obj = api.get_object(self.ctxt, self.model, id=obj.id)
        self.assertEqual(obj, new_obj)

        obj = new_obj
        api.update_object(self.ctxt, self.model, {'name': 'bar'}, id=obj.id)

        new_obj = api.get_object(self.ctxt, self.model, id=obj.id)
        self.assertEqual(obj, new_obj)

        obj = new_obj
        api.delete_object(self.ctxt, self.model, id=obj.id)

        new_obj = api.get_object(self.ctxt, self.model, id=obj.id)
        self.assertIsNone(new_obj)

        # delete_object raises an exception on missing object
        self.assertRaises(n_exc.ObjectNotFound,
                          api.delete_object,
                          self.ctxt,
                          self.model,
                          id=obj.id)

        # but delete_objects does not not
        api.delete_objects(self.ctxt, self.model, id=obj.id)
Example #21
0
 def test_get_object_with_None_value_in_filters(self):
     obj = api.create_object(self.obj_cls, self.ctxt, {'name': 'foo'})
     new_obj = api.get_object(self.obj_cls,
                              self.ctxt,
                              name='foo',
                              status=None)
     self.assertEqual(obj, new_obj)
Example #22
0
 def create(self):
     fields = self._get_changed_persistent_fields()
     try:
         db_obj = obj_db_api.create_object(self._context, self.db_model,
                                           self.modify_fields_to_db(fields))
     except obj_exc.DBDuplicateEntry as db_exc:
         raise NeutronDbObjectDuplicateEntry(object_class=self.__class__,
                                             db_exception=db_exc)
     self.from_db_object(db_obj)
Example #23
0
    def create(self):
        fields = self._get_changed_persistent_fields()
        try:
            db_obj = obj_db_api.create_object(self._context, self.db_model,
                                              fields)
        except obj_exc.DBDuplicateEntry as db_exc:
            raise NeutronDbObjectDuplicateEntry(object_class=self.__class__,
                                                db_exception=db_exc)

        self.from_db_object(db_obj)
Example #24
0
 def _create_test_segment(self, network):
     test_segment = {
         'network_id': network['id'],
         'network_type': 'vxlan',
     }
     # TODO(korzen): replace with segment.create() once we get an object
     # implementation for segments
     self._segment = obj_db_api.create_object(self.context,
                                              segments_db.NetworkSegment,
                                              test_segment)
Example #25
0
 def _create_test_segment(self, network):
     test_segment = {
         'network_id': network['id'],
         'network_type': 'vxlan',
     }
     # TODO(korzen): replace with segment.create() once we get an object
     # implementation for segments
     self._segment = obj_db_api.create_object(self.context,
                                              segments_db.NetworkSegment,
                                              test_segment)
Example #26
0
    def create(self):
        fields = self._get_changed_persistent_fields()
        with self.db_context_writer(self.obj_context):
            try:
                db_obj = obj_db_api.create_object(
                    self, self.obj_context, self.modify_fields_to_db(fields))
            except obj_exc.DBDuplicateEntry as db_exc:
                raise o_exc.NeutronDbObjectDuplicateEntry(
                    object_class=self.__class__, db_exception=db_exc)

            self.from_db_object(db_obj)
Example #27
0
 def _create_test_port(self, network):
     # TODO(ihrachys): replace with port.create() once we get an object
     # implementation for ports
     self._port = obj_db_api.create_object(self.context, models_v2.Port,
                                           {'tenant_id': 'fake_tenant_id',
                                            'name': 'test-port1',
                                            'network_id': network['id'],
                                            'mac_address': 'fake_mac',
                                            'admin_state_up': True,
                                            'status': 'ACTIVE',
                                            'device_id': 'fake_device',
                                            'device_owner': 'fake_owner'})
Example #28
0
    def create(self):
        fields = self._get_changed_persistent_fields()
        with db_api.autonested_transaction(self.obj_context.session):
            try:
                db_obj = obj_db_api.create_object(
                    self.obj_context, self.db_model,
                    self.modify_fields_to_db(fields))
            except obj_exc.DBDuplicateEntry as db_exc:
                raise o_exc.NeutronDbObjectDuplicateEntry(
                    object_class=self.__class__, db_exception=db_exc)

            self.from_db_object(db_obj)
Example #29
0
    def create(self):
        fields = self._get_changed_persistent_fields()
        with db_api.autonested_transaction(self.obj_context.session):
            try:
                db_obj = obj_db_api.create_object(
                    self.obj_context, self.db_model,
                    self.modify_fields_to_db(fields))
            except obj_exc.DBDuplicateEntry as db_exc:
                raise o_exc.NeutronDbObjectDuplicateEntry(
                    object_class=self.__class__, db_exception=db_exc)

            self.from_db_object(db_obj)
Example #30
0
 def _create_test_port(self, network):
     # TODO(ihrachys): replace with port.create() once we get an object
     # implementation for ports
     self._port = obj_db_api.create_object(self.context, models_v2.Port,
                                           {'tenant_id': 'fake_tenant_id',
                                            'name': 'test-port1',
                                            'network_id': network['id'],
                                            'mac_address': 'fake_mac',
                                            'admin_state_up': True,
                                            'status': 'ACTIVE',
                                            'device_id': 'fake_device',
                                            'device_owner': 'fake_owner'})
Example #31
0
    def test_attach_and_get_multiple_policy_networks(self):

        net1_id = self._network['id']
        net2 = db_api.create_object(self.context, models_v2.Network,
                                    {'name': 'test-network2'})
        net2_id = net2['id']

        obj = self._create_test_policy()
        obj.attach_network(net1_id)
        obj.attach_network(net2_id)

        networks = obj.get_bound_networks()
        self.assertEqual(2, len(networks))
        self.assertTrue(net1_id in networks)
        self.assertTrue(net2_id in networks)
Example #32
0
    def test_attach_and_get_multiple_policy_networks(self):

        net1_id = self._network['id']
        net2 = db_api.create_object(self.context,
                                    models_v2.Network,
                                    {'name': 'test-network2'})
        net2_id = net2['id']

        obj = self._create_test_policy()
        obj.attach_network(net1_id)
        obj.attach_network(net2_id)

        networks = obj.get_bound_networks()
        self.assertEqual(2, len(networks))
        self.assertTrue(net1_id in networks)
        self.assertTrue(net2_id in networks)
Example #33
0
    def test_get_values_with_string_matching_filters_ends(self):
        api.create_object(self.obj_cls, self.ctxt, {'name': 'obj1_end'})
        api.create_object(self.obj_cls, self.ctxt, {'name': 'obj2_end'})
        api.create_object(self.obj_cls, self.ctxt, {'name': 'obj_3'})

        values = api.get_values(
            self.obj_cls, self.ctxt, 'name', name=obj_utils.StringEnds('end'))
        self.assertEqual(2, len(values))
        self.assertIn('obj1_end', values)
        self.assertIn('obj2_end', values)
        self.assertNotIn('obj_3', values)
Example #34
0
    def test_get_values_with_string_matching_filters_ends(self):
        api.create_object(self.obj_cls, self.ctxt, {'name': 'obj1_end'})
        api.create_object(self.obj_cls, self.ctxt, {'name': 'obj2_end'})
        api.create_object(self.obj_cls, self.ctxt, {'name': 'obj_3'})

        values = api.get_values(
            self.obj_cls, self.ctxt, 'name', name=obj_utils.StringEnds('end'))
        self.assertEqual(2, len(values))
        self.assertIn('obj1_end', values)
        self.assertIn('obj2_end', values)
        self.assertNotIn('obj_3', values)
Example #35
0
    def test_get_values_with_string_matching_filters_contains(self):
        api.create_object(self.obj_cls, self.ctxt, {'name': 'obj_con_1'})
        api.create_object(self.obj_cls, self.ctxt, {'name': 'obj_con_2'})
        api.create_object(self.obj_cls, self.ctxt, {'name': 'obj_3'})

        values = api.get_values(self.obj_cls,
                                self.ctxt,
                                'name',
                                name=obj_utils.StringContains('con'))
        self.assertEqual(2, len(values))
        self.assertIn('obj_con_1', values)
        self.assertIn('obj_con_2', values)
        self.assertNotIn('obj_3', values)
Example #36
0
    def test_get_values_with_string_matching_filters_contains(self):
        api.create_object(
            self.obj_cls, self.ctxt, {'name': 'obj_con_1'})
        api.create_object(
            self.obj_cls, self.ctxt, {'name': 'obj_con_2'})
        api.create_object(
            self.obj_cls, self.ctxt, {'name': 'obj_3'})

        values = api.get_values(
            self.obj_cls, self.ctxt, 'name',
            name=obj_utils.StringContains('con'))
        self.assertEqual(2, len(values))
        self.assertIn('obj_con_1', values)
        self.assertIn('obj_con_2', values)
        self.assertNotIn('obj_3', values)
Example #37
0
    def test_attach_and_get_multiple_policy_ports(self):

        port1_id = self._port['id']
        port2 = db_api.create_object(self.context, models_v2.Port,
                                     {'tenant_id': 'fake_tenant_id',
                                     'name': 'test-port2',
                                     'network_id': self._network['id'],
                                     'mac_address': 'fake_mac2',
                                     'admin_state_up': True,
                                     'status': 'ACTIVE',
                                     'device_id': 'fake_device',
                                     'device_owner': 'fake_owner'})
        port2_id = port2['id']

        obj = self._create_test_policy()
        obj.attach_port(port1_id)
        obj.attach_port(port2_id)

        ports = obj.get_bound_ports()
        self.assertEqual(2, len(ports))
        self.assertIn(port1_id, ports)
        self.assertIn(port2_id, ports)
Example #38
0
    def test_attach_and_get_multiple_policy_ports(self):

        port1_id = self._port['id']
        port2 = db_api.create_object(port_obj.Port, self.context,
                                     {'tenant_id': 'fake_tenant_id',
                                     'name': 'test-port2',
                                     'network_id': self._network_id,
                                     'mac_address': 'fake_mac2',
                                     'admin_state_up': True,
                                     'status': 'ACTIVE',
                                     'device_id': 'fake_device',
                                     'device_owner': 'fake_owner'})
        port2_id = port2['id']

        obj = self._create_test_policy()
        obj.attach_port(port1_id)
        obj.attach_port(port2_id)

        ports = obj.get_bound_ports()
        self.assertEqual(2, len(ports))
        self.assertIn(port1_id, ports)
        self.assertIn(port2_id, ports)
Example #39
0
    def _create_port(self, **port_attrs):
        if not hasattr(self, '_mac_address_generator'):
            self._mac_address_generator = (":".join(["%02x" % i] * 6)
                                           for i in itertools.count())

        if not hasattr(self, '_port_name_generator'):
            self._port_name_generator = ("test-port%d" % i
                                         for i in itertools.count(1))

        attrs = {'tenant_id': 'fake_tenant_id',
                 'admin_state_up': True,
                 'status': 'ACTIVE',
                 'device_id': 'fake_device',
                 'device_owner': 'fake_owner'}
        attrs.update(port_attrs)

        if 'name' not in attrs:
            attrs['name'] = next(self._port_name_generator)
        if 'mac_address' not in attrs:
            attrs['mac_address'] = next(self._mac_address_generator)

        # TODO(ihrachys): replace with port.create() once we get an object
        # implementation for ports
        return obj_db_api.create_object(self.context, models_v2.Port, attrs)
Example #40
0
 def _create_test_network(self):
     # TODO(ihrachys): replace with network.create() once we get an object
     # implementation for networks
     self._network = obj_db_api.create_object(self.context,
                                              models_v2.Network,
                                              {'name': 'test-network1'})
Example #41
0
 def test_get_object_with_None_value_in_filters(self):
     obj = api.create_object(self.obj_cls, self.ctxt, {'name': 'foo'})
     new_obj = api.get_object(
         self.obj_cls, self.ctxt, name='foo', status=None)
     self.assertEqual(obj, new_obj)
Example #42
0
 def _attach_security_group(self, sg_id):
     obj_db_api.create_object(
         self.obj_context, sg_models.SecurityGroupPortBinding,
         {'port_id': self.id, 'security_group_id': sg_id}
     )
Example #43
0
 def _create_network(self):
     name = "test-network-%s" % tools.get_random_string(4)
     return obj_db_api.create_object(self.context,
                                     models_v2.Network,
                                     {'name': name})
Example #44
0
 def test_get_objects_with_None_value_in_filters(self):
     obj = api.create_object(self.obj_cls, self.ctxt, {'name': 'foo'})
     new_objs = api.get_objects(
         self.obj_cls, self.ctxt, name='foo', status=None)
     self._compare_objs(obj, new_objs[0])
Example #45
0
 def test_get_values_with_None_value_in_filters(self):
     api.create_object(self.obj_cls, self.ctxt, {'name': 'foo'})
     values = api.get_values(
         self.obj_cls, self.ctxt, 'name', name='foo', status=None)
     self.assertEqual('foo', values[0])
Example #46
0
 def _create_test_security_group(self):
     return obj_db_api.create_object(
         self.context, sg_models.SecurityGroup, {})
Example #47
0
 def test_get_objects_with_None_value_in_filters(self):
     obj = api.create_object(self.ctxt, self.model, {'name': 'foo'})
     new_objs = api.get_objects(
         self.ctxt, self.model, name='foo', status=None)
     self.assertEqual(obj, new_objs[0])
Example #48
0
 def _attach_security_group(self, sg_id):
     obj_db_api.create_object(self.obj_context,
                              sg_models.SecurityGroupPortBinding, {
                                  'port_id': self.id,
                                  'security_group_id': sg_id
                              })
Example #49
0
 def _create_test_network(self):
     # TODO(ihrachys): replace with network.create() once we get an object
     # implementation for networks
     self._network = obj_db_api.create_object(self.context,
                                              models_v2.Network,
                                              {'name': 'test-network1'})
Example #50
0
 def _create_test_security_group(self):
     return obj_db_api.create_object(self.context, sg_models.SecurityGroup,
                                     {})
Example #51
0
 def _create_network(self):
     name = "test-network-%s" % tools.get_random_string(4)
     return obj_db_api.create_object(self.context,
                                     models_v2.Network,
                                     {'name': name})
Example #52
0
 def _attach_security_group(self, sg_id):
     LOG.info('%s(): caller(): %s', log_utils.get_fname(1), log_utils.get_fname(2))
     obj_db_api.create_object(
         SecurityGroupPortBinding, self.obj_context,
         {'port_id': self.id, 'security_group_id': sg_id}
     )