'Create network resources and a server.
Creating a network, subnet, router, keypair, security group
and a server.'

def setup_network_and_server(self, router=None, **kwargs):

    self.network = self.create_network()
    LOG.debug('Created    network    %s', self.network['name'])
    self.subnet = self.create_subnet(self.network)
    LOG.debug('Created    subnet    %s', self.subnet['id'])
    secgroup = self.os_primary.network_client.create_security_group(name=data_utils.rand_name('secgroup-'))
    LOG.debug('Created    security    group    %s', secgroup['security_group']['name'])
    self.security_groups.append(secgroup['security_group'])
    if (not router):
        router = self.create_router_by_client(**kwargs)
    self.create_router_interface(router['id'], self.subnet['id'])
    self.keypair = self.create_keypair()
    self.create_loginable_secgroup_rule(secgroup_id=secgroup['security_group']['id'])
    self.server = self.create_server(flavor_ref=CONF.compute.flavor_ref, image_ref=CONF.compute.image_ref, key_name=self.keypair['name'], networks=[{'uuid': self.network['id']}], security_groups=[{'name': secgroup['security_group']['name']}])
    waiters.wait_for_server_status(self.os_primary.servers_client, self.server['server']['id'], constants.SERVER_STATUS_ACTIVE)
    self.port = self.client.list_ports(network_id=self.network['id'], device_id=self.server['server']['id'])['ports'][0]
    self.fip = self.create_and_associate_floatingip(self.port['id'])
