예제 #1
0
def init():
    openstack_params = utils.pack_openstack_params(cfg.CONF)
    try:
        return openstack.OpenStackClient(openstack_params)
    except Exception as e:
        LOG.error('Failed to connect to OpenStack: %s. '
                  'Please verify parameters: %s', e, openstack_params)
        exit(1)
예제 #2
0
    def connect_to_openstack(self, openstack_params, flavor_name, image_name,
                             external_net, dns_nameservers):
        LOG.debug('Connecting to OpenStack')

        self.openstack_client = openstack.OpenStackClient(openstack_params)

        self.flavor_name = flavor_name
        self.image_name = image_name
        self.external_net = (external_net or neutron.choose_external_net(
            self.openstack_client.neutron))
        self.stack_name = 'shaker_%s' % utils.random_string()
        self.dns_nameservers = dns_nameservers
예제 #3
0
    def connect_to_openstack(self, openstack_params, flavor_name, image_name,
                             external_net, dns_nameservers):
        LOG.debug('Connecting to OpenStack')

        self.openstack_client = openstack.OpenStackClient(openstack_params)

        self.flavor_name = flavor_name
        self.image_name = image_name
        self.stack_name = 'shaker_%s' % utils.random_string()
        self.dns_nameservers = dns_nameservers
        # intiailizing self.external_net last so that other attributes don't
        # remain uninitialized in case user forgets to create external network
        self.external_net = (external_net or neutron.choose_external_net(
            self.openstack_client.neutron))
예제 #4
0
    def connect_to_openstack(self, os_username, os_password, os_tenant_name,
                             os_auth_url, os_region_name, external_net,
                             flavor_name, image_name, os_cacert, os_insecure):
        LOG.debug('Connecting to OpenStack')

        self.openstack_client = openstack.OpenStackClient(
            username=os_username, password=os_password,
            tenant_name=os_tenant_name, auth_url=os_auth_url,
            region_name=os_region_name, cacert=os_cacert, insecure=os_insecure)

        self.flavor_name = flavor_name
        self.image_name = image_name
        self.external_net = (external_net or
                             neutron.choose_external_net(
                                 self.openstack_client.neutron))
        self.stack_name = 'shaker_%s' % utils.random_string()
예제 #5
0
def init():
    utils.init_config_and_logging(config.OPENSTACK_OPTS +
                                  config.IMAGE_BUILDER_OPTS)

    openstack_client = None
    try:
        openstack_client = openstack.OpenStackClient(
            username=cfg.CONF.os_username,
            password=cfg.CONF.os_password,
            tenant_name=cfg.CONF.os_tenant_name,
            auth_url=cfg.CONF.os_auth_url,
            region_name=cfg.CONF.os_region_name)
    except Exception as e:
        LOG.error(
            'Error establishing connection to OpenStack: %s. '
            'Please verify OpenStack credentials (--os-username, '
            '--os-password, --os-tenant-name, --os-auth-url)', e)
        exit(1)

    return openstack_client