def setUp(self): super(AddressGroupRBACDbObjectTestCase, self).setUp() for obj in self.db_objs: ag_obj = address_group.AddressGroup(self.context, id=obj['object_id'], project_id=obj['project_id']) ag_obj.create()
def create_address_group(self, context, address_group): """Create an address group.""" fields = address_group['address_group'] args = { 'project_id': fields['project_id'], 'id': uuidutils.generate_uuid(), 'name': fields['name'], 'description': fields['description'] } ag = ag_obj.AddressGroup(context, **args) ag.create() address_group = self._make_address_group_dict(ag) registry.publish(resources.ADDRESS_GROUP, events.AFTER_CREATE, self, payload=events.DBEventPayload( context, resource_id=ag.id, states=(address_group, ))) # NOTE(hangyang): after sent the create notification we then handle # adding addresses which will send another update notification if fields.get('addresses') is not constants.ATTR_NOT_SPECIFIED: self.add_addresses(context, ag.id, fields) ag.update() # reload synthetic fields return self._make_address_group_dict(ag)
def create_address_group(self, context, address_group): """Create an address group.""" fields = address_group['address_group'] args = { 'project_id': fields['project_id'], 'id': uuidutils.generate_uuid(), 'name': fields['name'], 'description': fields['description'] } ag = ag_obj.AddressGroup(context, **args) ag.create() kwargs = {'address_group': self._make_address_group_dict(ag)} # TODO(mlavalle) this notification should be updated to publish when # the callback handler handle_event, class _ObjectChangeHandler in # neutron.plugins.ml2.ovo_rpc is updated to receive notifications with # new style payload objects as argument. registry.notify(resources.ADDRESS_GROUP, events.AFTER_CREATE, self, context=context, **kwargs) # NOTE(hangyang): after sent the create notification we then handle # adding addresses which will send another update notification if fields.get('addresses') is not constants.ATTR_NOT_SPECIFIED: self.add_addresses(context, ag.id, fields) ag.update() # reload synthetic fields return self._make_address_group_dict(ag)
def create_address_group(self, context, address_group): """Create an address group.""" fields = address_group['address_group'] args = { 'project_id': fields['project_id'], 'id': uuidutils.generate_uuid(), 'name': fields['name'], 'description': fields['description'] } ag = ag_obj.AddressGroup(context, **args) ag.create() if fields.get('addresses') is not constants.ATTR_NOT_SPECIFIED: self.add_addresses(context, ag.id, fields) ag.update() # reload synthetic fields return self._make_address_group_dict(ag)
def _make_address_group_ovo(self, *args, **kwargs): id = uuidutils.generate_uuid() address_associations = [ address_group.AddressAssociation( self.ctx, address=netaddr.IPNetwork('10.0.0.1/32'), address_group_id=id), address_group.AddressAssociation( self.ctx, address=netaddr.IPNetwork('2001:db8::/32'), address_group_id=id) ] ag = address_group.AddressGroup(self.ctx, id=id, name='an-address-group', description='An address group', addresses=address_associations) self.rcache.record_resource_update(self.ctx, resources.ADDRESSGROUP, ag) return ag