Beispiel #1
0
    def create_vm(self, instance):
        LOG.info("Creating Instance: " + instance.vm_name)
        instance.create_server(**instance.boot_info)
        if not instance.instance:
            raise KBVMCreationException(
                'Instance %s takes too long to become ACTIVE.' % instance.vm_name)

        if instance.vol:
            instance.attach_vol()

        instance.fixed_ip = instance.instance.networks.values()[0][0]
        u_fip = instance.config['use_floatingip']
        if instance.vm_name == "KB-PROXY" and not u_fip and not self.multicast_mode:
            neutron_client = instance.network.router.user.neutron_client
            external_network = base_network.find_external_network(neutron_client)
            instance.fip = base_network.create_floating_ip(neutron_client, external_network)
            instance.fip_ip = instance.fip['floatingip']['floating_ip_address']
            self.res_logger.log('floating_ips',
                                instance.fip['floatingip']['floating_ip_address'],
                                instance.fip['floatingip']['id'])

        if instance.fip:
            # Associate the floating ip with this instance
            instance.instance.add_floating_ip(instance.fip_ip)
            instance.ssh_ip = instance.fip_ip
        else:
            # Store the fixed ip as ssh ip since there is no floating ip
            instance.ssh_ip = instance.fixed_ip

        if not instance.vm_name == "KB-PROXY" and self.multicast_mode:
            nc = instance.network.router.user.neutron_client
            base_network.disable_port_security(nc, instance.fixed_ip)
Beispiel #2
0
    def create_resources(self):
        """
        Creates all the User elements associated with a User
        1. Creates the routers
        2. Creates the neutron and nova client objects
        """
        # Create a new neutron client for this User with correct credentials
        creden = {}
        creden['username'] = self.user_name
        creden['password'] = self.password
        creden['auth_url'] = self.tenant.kloud.auth_url
        creden['tenant_name'] = self.tenant.tenant_name

        # Create the neutron client to be used for all operations
        self.neutron_client = neutronclient.Client(**creden)

        # Create a new nova and cinder client for this User with correct credentials
        creden_nova = {}
        creden_nova['username'] = self.user_name
        creden_nova['api_key'] = self.password
        creden_nova['auth_url'] = self.tenant.kloud.auth_url
        creden_nova['project_id'] = self.tenant.tenant_name
        creden_nova['version'] = 2

        self.nova_client = Client(**creden_nova)
        self.cinder_client = cinderclient.Client(**creden_nova)

        if self.tenant.kloud.reusing_tenants:
            self.check_resources_quota()
        else:
            self.update_tenant_quota(self.tenant.tenant_quota)

        config_scale = self.tenant.kloud.scale_cfg

        # Create the user's keypair if configured
        if config_scale.public_key_file:
            self.key_pair = base_compute.KeyPair(self.nova_client)
            self.key_name = self.user_name + '-K'
            self.key_pair.add_public_key(self.key_name, config_scale.public_key_file)

        # Find the external network that routers need to attach to
        external_network = base_network.find_external_network(self.neutron_client)

        # Create the required number of routers and append them to router list
        LOG.info("Creating routers and networks for user %s" % self.user_name)
        for router_count in range(config_scale['routers_per_user']):
            router_instance = base_network.Router(self)
            self.router_list.append(router_instance)
            router_name = self.user_name + "-R" + str(router_count)
            # Create the router and also attach it to external network
            router_instance.create_router(router_name, external_network)
            self.res_logger.log('routers', router_instance.router['router']['name'],
                                router_instance.router['router']['id'])
            # Now create the network resources inside the router
            router_instance.create_network_resources(config_scale)
Beispiel #3
0
    def create_resources(self):
        """
        Creates all the User elements associated with a User
        1. Creates the routers
        2. Creates the neutron and nova client objects
        """
        session = self.tenant.kloud.osclient_session

        # Create nova/neutron/cinder clients to be used for all operations
        self.neutron_client = neutronclient.Client('2.0', endpoint_type='publicURL',
                                                   session=session)
        self.nova_client = novaclient.Client('2', endpoint_type='publicURL',
                                             http_log_debug=True, session=session)
        self.cinder_client = cinderclient.Client('2', endpoint_type='publicURL',
                                                 session=session)

        if self.tenant.kloud.reusing_tenants:
            self.check_resources_quota()
        else:
            self.update_tenant_quota(self.tenant.tenant_quota)

        config_scale = self.tenant.kloud.scale_cfg

        # Create the user's keypair if configured
        if config_scale.public_key_file:
            self.key_pair = base_compute.KeyPair(self.nova_client)
            self.key_name = self.user_name + '-K'
            self.res_logger.log('keypairs', self.key_name, "")
            self.key_pair.add_public_key(self.key_name, config_scale.public_key_file)

        # Find the external network that routers need to attach to
        if self.tenant.kloud.multicast_mode:
            router_instance = base_network.Router(self, is_dumb=True)
            self.router_list.append(router_instance)
            router_instance.create_network_resources(config_scale)

        else:
            external_network = base_network.find_external_network(self.neutron_client)
            # Create the required number of routers and append them to router list
            LOG.info("Creating routers and networks for tenant %s" % self.tenant.tenant_name)
            for router_count in range(config_scale['routers_per_tenant']):
                router_instance = base_network.Router(self)
                self.router_list.append(router_instance)
                router_name = self.user_name + "-R" + str(router_count)
                # Create the router and also attach it to external network
                router_instance.create_router(router_name, external_network)
                self.res_logger.log('routers', router_instance.router['router']['name'],
                                    router_instance.router['router']['id'])
                # Now create the network resources inside the router
                router_instance.create_network_resources(config_scale)
Beispiel #4
0
    def create_resources(self):
        """
        Creates all the User elements associated with a User
        1. Creates the routers
        2. Creates the neutron and nova client objects
        """

        config_scale = self.tenant.kloud.scale_cfg

        # Create the user's keypair if configured
        if config_scale.public_key_file:
            self.key_pair = base_compute.KeyPair(self.nova_client)
            self.key_name = self.user_name + '-K'
            self.res_logger.log('keypairs', self.key_name, "")
            self.key_pair.add_public_key(self.key_name,
                                         config_scale.public_key_file)

        # Find the external network that routers need to attach to
        if self.tenant.kloud.multicast_mode:
            router_instance = base_network.Router(self, is_dumb=True)
            self.router_list.append(router_instance)
            router_instance.create_network_resources(config_scale)

        else:
            external_network = base_network.find_external_network(
                self.neutron_client)
            # Create the required number of routers and append them to router list
            LOG.info("Creating routers and networks for tenant %s" %
                     self.tenant.tenant_name)
            for router_count in range(config_scale['routers_per_tenant']):
                router_instance = base_network.Router(self)
                self.router_list.append(router_instance)
                router_name = self.user_name + "-R" + str(router_count)
                # Create the router and also attach it to external network
                router_instance.create_router(router_name, external_network)
                self.res_logger.log('routers',
                                    router_instance.router['router']['name'],
                                    router_instance.router['router']['id'])
                # Now create the network resources inside the router
                router_instance.create_network_resources(config_scale)
Beispiel #5
0
    def create_vm(self, instance):
        LOG.info("Creating Instance: " + instance.vm_name)
        instance.create_server(**instance.boot_info)
        if not instance.instance:
            raise KBVMCreationException()

        instance.fixed_ip = instance.instance.networks.values()[0][0]
        if (instance.vm_name == "KB-PROXY") and (not instance.config['use_floatingip']):
            neutron_client = instance.network.router.user.neutron_client
            external_network = base_network.find_external_network(neutron_client)
            instance.fip = base_network.create_floating_ip(neutron_client, external_network)
            instance.fip_ip = instance.fip['floatingip']['floating_ip_address']
            self.res_logger.log('floating_ips',
                                instance.fip['floatingip']['floating_ip_address'],
                                instance.fip['floatingip']['id'])

        if instance.fip:
            # Associate the floating ip with this instance
            instance.instance.add_floating_ip(instance.fip_ip)
            instance.ssh_ip = instance.fip_ip
        else:
            # Store the fixed ip as ssh ip since there is no floating ip
            instance.ssh_ip = instance.fixed_ip
Beispiel #6
0
    def create_vm(self, instance):
        LOG.info("Creating Instance: " + instance.vm_name)
        instance.create_server(**instance.boot_info)
        if not instance.instance:
            raise KBVMCreationException(
                'Instance %s takes too long to become ACTIVE.' %
                instance.vm_name)

        if instance.vol:
            instance.attach_vol()

        instance.fixed_ip = instance.instance.networks.values()[0][0]
        u_fip = instance.config['use_floatingip']
        if instance.vm_name == "KB-PROXY" and not u_fip and not self.multicast_mode:
            neutron_client = instance.network.router.user.neutron_client
            external_network = base_network.find_external_network(
                neutron_client)
            instance.fip = base_network.create_floating_ip(
                neutron_client, external_network)
            instance.fip_ip = instance.fip['floatingip']['floating_ip_address']
            self.res_logger.log(
                'floating_ips',
                instance.fip['floatingip']['floating_ip_address'],
                instance.fip['floatingip']['id'])

        if instance.fip:
            # Associate the floating ip with this instance
            instance.instance.add_floating_ip(instance.fip_ip)
            instance.ssh_ip = instance.fip_ip
        else:
            # Store the fixed ip as ssh ip since there is no floating ip
            instance.ssh_ip = instance.fixed_ip

        if not instance.vm_name == "KB-PROXY" and self.multicast_mode:
            nc = instance.network.router.user.neutron_client
            base_network.disable_port_security(nc, instance.fixed_ip)