def _setUp(self): super(NeutronNetworkFixture, self)._setUp() self.neutron = get_neutron_client( project_name=self.project_fixture.name, user_name=self.project_fixture.admin_user.name, password=self.project_fixture.admin_user_fixture.password) self.subnet_id = self.get_subnet_id() cidr = CONF.network['cidr'].format(subnet=self.subnet_id) # TODO: handle clashes and retry. self.net_name = factory.make_obj_name("network") self.sub_name = factory.make_obj_name("subnet") self.network = self.neutron.create_network( {"network": dict(name=self.net_name)}) network_id = self.network["network"]["id"] self.subnet = self.neutron.create_subnet( {"subnet": dict( name=self.sub_name, network_id=network_id, cidr=cidr, ip_version=4)}) self.addCleanup(self.delete_network) self.addDetail( 'NeutronNetworkFixture-network', text_content('Network %s created' % self.net_name)) self.addDetail( 'NeutronNetworkFixture-subnet', text_content('Subnet %s created (cidr=%s)' % ( self.sub_name, cidr)))
def setUp(self): super(RouterFixture, self).setUp() self.neutron = get_neutron_client( project_name=self.project_fixture.name, user_name=self.project_fixture.admin_user.name, password=self.project_fixture.admin_user_fixture.password) # TODO: handle clashes and retry. self.name = factory.make_obj_name("router") self.router = self.neutron.create_router( {'router': {'name': self.name, 'admin_state_up': True}}) self.addCleanup(self.delete_router) self.addDetail( 'RouterFixture-network', text_content('Router %s created' % self.name)) self.wait_until_active()
def _setUp(self): super(ProjectFixture, self)._setUp() self.name = factory.make_obj_name('project') self.keystone = get_keystone_v3_client(project_name=CONF.admin_project) self.project = self.keystone.projects.create( name=self.name, domain='default') self.addCleanup(self.delete_project) self.addDetail( 'ProjectFixture', text_content('Project %s created' % self.name)) # Make an admin for the project. self.admin_user_fixture = self.useFixture(UserFixture()) self.admin_user = self.admin_user_fixture.user self.add_user_to_role(self.admin_user, "admin") return self.project