def initialize(self, _context):
        environment = helpers.get_environment(_context)
        self._tenant_id = environment.tenant_id
        keystone_settings = config.CONF.keystone
        neutron_settings = config.CONF.neutron
        self._settings = config.CONF.networking

        keystone_client = ksclient.Client(endpoint=keystone_settings.auth_url,
                                          cacert=keystone_settings.ca_file
                                          or None,
                                          cert=keystone_settings.cert_file
                                          or None,
                                          key=keystone_settings.key_file
                                          or None,
                                          insecure=keystone_settings.insecure)

        if not keystone_client.authenticate(
                auth_url=keystone_settings.auth_url,
                tenant_id=environment.tenant_id,
                token=environment.token):
            raise ks_exc.AuthorizationFailure()

        neutron_url = keystone_client.service_catalog.url_for(
            service_type='network',
            endpoint_type=neutron_settings.endpoint_type)

        self._neutron = \
            nclient.Client(endpoint_url=neutron_url,
                           token=environment.token,
                           ca_cert=neutron_settings.ca_cert or None,
                           insecure=neutron_settings.insecure)

        self._available_cidrs = self._generate_possible_cidrs()
    def initialize(self, _context):
        environment = helpers.get_environment(_context)
        self._tenant_id = environment.tenant_id
        keystone_settings = config.CONF.keystone
        neutron_settings = config.CONF.neutron
        self._settings = config.CONF.networking

        keystone_client = ksclient.Client(
            endpoint=keystone_settings.auth_url,
            cacert=keystone_settings.ca_file or None,
            cert=keystone_settings.cert_file or None,
            key=keystone_settings.key_file or None,
            insecure=keystone_settings.insecure)

        if not keystone_client.authenticate(
                auth_url=keystone_settings.auth_url,
                tenant_id=environment.tenant_id,
                token=environment.token):
            raise ks_exc.AuthorizationFailure()

        neutron_url = keystone_client.service_catalog.url_for(
            service_type='network',
            endpoint_type=neutron_settings.endpoint_type)

        self._neutron = \
            nclient.Client(endpoint_url=neutron_url,
                           token=environment.token,
                           ca_cert=neutron_settings.ca_cert or None,
                           insecure=neutron_settings.insecure)

        self._available_cidrs = self._generate_possible_cidrs()
Beispiel #3
0
    def initialize(self, _context, name):
        self._name = name
        self._template = None
        self._parameters = {}
        self._applied = True
        environment = helpers.get_environment(_context)
        keystone_settings = config.CONF.keystone
        heat_settings = config.CONF.heat

        client = ksclient.Client(
            endpoint=keystone_settings.auth_url,
            cacert=keystone_settings.ca_file or None,
            cert=keystone_settings.cert_file or None,
            key=keystone_settings.key_file or None,
            insecure=keystone_settings.insecure)

        if not client.authenticate(
                auth_url=keystone_settings.auth_url,
                tenant_id=environment.tenant_id,
                token=environment.token):
            raise heat_exc.HTTPUnauthorized()

        heat_url = client.service_catalog.url_for(
            service_type='orchestration',
            endpoint_type=heat_settings.endpoint_type)

        self._heat_client = hclient.Client(
            '1',
            heat_url,
            username='******',
            password='******',
            token_only=True,
            token=client.auth_token,
            ca_file=heat_settings.ca_file or None,
            cert_file=heat_settings.cert_file or None,
            key_file=heat_settings.key_file or None,
            insecure=heat_settings.insecure)