Exemplo n.º 1
0
    def __init__(self, **kwargs):
        """Initialize a new client for the Keystone v2.0 API."""

        if not kwargs.get('session'):
            warnings.warn(
                'Constructing an instance of the '
                'keystoneclient.v2_0.client.Client class without a session is '
                'deprecated as of the 1.7.0 release and may be removed in '
                'the 2.0.0 release.', DeprecationWarning)

        super(Client, self).__init__(**kwargs)

        self.certificates = certificates.CertificatesManager(self._adapter)
        self.endpoints = endpoints.EndpointManager(self._adapter)
        self.extensions = extensions.ExtensionManager(self._adapter)
        self.roles = roles.RoleManager(self._adapter)
        self.services = services.ServiceManager(self._adapter)
        self.tokens = tokens.TokenManager(self._adapter)
        self.users = users.UserManager(self._adapter, self.roles)

        self.tenants = tenants.TenantManager(self._adapter, self.roles,
                                             self.users)

        # extensions
        self.ec2 = ec2.CredentialsManager(self._adapter)

        # DEPRECATED: if session is passed then we go to the new behaviour of
        # authenticating on the first required call.
        if not kwargs.get('session') and self.management_url is None:
            self.authenticate()
Exemplo n.º 2
0
    def __init__(self, *args, **kwargs):
        super(V2IdentityClient, self).__init__(*args, **kwargs)

        self.endpoints = v2endpoints.EndpointManager(self)
        self.roles = v2roles.RoleManager(self)
        self.services = v2services.ServiceManager(self)
        self.tenants = v2tenants.TenantManager(self)
        self.tokens = v2tokens.TokenManager(self)
        self.users = v2users.UserManager(self)
Exemplo n.º 3
0
    def __init__(self, http_client, **kwargs):
        """ Initialize a new client for the Keystone v2.0 API. """
        super(IdentityAdminClient, self).__init__(http_client)

        self.endpoints = endpoints.EndpointManager(self)
        self.roles = roles.RoleManager(self)
        self.services = services.ServiceManager(self)
        self.tenants = tenants.TenantManager(self)
        self.tokens = tokens.TokenManager(self)
        self.users = users.UserManager(self)

        # extensions
        self.ec2 = ec2.CredentialsManager(self)
Exemplo n.º 4
0
 def __init__(self, endpoint=None, **kwargs):
     """ Initialize a new client for the Keystone v2.0 API. """
     super(Client, self).__init__(endpoint=endpoint, **kwargs)
     self.roles = roles.RoleManager(self)
     self.services = services.ServiceManager(self)
     self.tenants = tenants.TenantManager(self)
     self.tokens = tokens.TokenManager(self)
     self.users = users.UserManager(self)
     # NOTE(gabriel): If we have a pre-defined endpoint then we can
     #                get away with lazy auth. Otherwise auth immediately.
     if endpoint is None:
         self.authenticate()
     else:
         self.management_url = endpoint
Exemplo n.º 5
0
    def __init__(self, **kwargs):
        """ Initialize a new client for the Keystone v2.0 API. """
        super(Client, self).__init__(**kwargs)
        self.endpoints = endpoints.EndpointManager(self)
        self.roles = roles.RoleManager(self)
        self.services = services.ServiceManager(self)
        self.tenants = tenants.TenantManager(self)
        self.tokens = tokens.TokenManager(self)
        self.users = users.UserManager(self)

        # extensions
        self.ec2 = ec2.CredentialsManager(self)

        if self.management_url is None:
            self.authenticate()
Exemplo n.º 6
0
    def __init__(self, **kwargs):
        """Initialize a new client for the Keystone v2.0 API."""
        super(Client, self).__init__(**kwargs)
        self.endpoints = endpoints.EndpointManager(self)
        self.roles = roles.RoleManager(self)
        self.services = services.ServiceManager(self)
        self.tenants = tenants.TenantManager(self)
        self.tokens = tokens.TokenManager(self)
        self.users = users.UserManager(self)

        # extensions
        self.ec2 = ec2.CredentialsManager(self)

        # DEPRECATED: if session is passed then we go to the new behaviour of
        # authenticating on the first required call.
        if not kwargs.get('session') and self.management_url is None:
            self.authenticate()
    def __init__(self, **kwargs):
        """Initialize a new client for the Keystone v2.0 API."""
        if not kwargs.get('session'):
            warnings.warn(
                'Constructing an instance of the '
                'keystoneclient.v2_0.client.Client class without a session is '
                'deprecated as of the 1.7.0 release and may be removed in '
                'the 2.0.0 release.', DeprecationWarning)

        # NOTE(knasim-wrs): As per US76645, the Keystone adminURL
        # is no longer an internal address since it needs to be
        # accessible via remote Openstack client. Things get
        # complicated with HTTPS where the internal keystone client
        # gets this adminURL and cannot connect to Keystone server
        # as it cannot verify the SSL certificate.
        # We will check for this condition here, if OS_ENDPOINT_TYPE
        # is not publicURL then this is an internal access scenario and
        # Keystone client will be set to SSL insecure mode
        if os.environ.get('OS_ENDPOINT_TYPE') == 'internalURL':
            kwargs['insecure'] = True
            # disable verbose insecurity warnings
            urllib3_disable_warnings(InsecureRequestWarning)

        super(Client, self).__init__(**kwargs)

        self.certificates = certificates.CertificatesManager(self._adapter)
        self.endpoints = endpoints.EndpointManager(self._adapter)
        self.extensions = extensions.ExtensionManager(self._adapter)
        self.roles = roles.RoleManager(self._adapter)
        self.services = services.ServiceManager(self._adapter)
        self.tokens = tokens.TokenManager(self._adapter)
        self.users = users.UserManager(self._adapter, self.roles)

        self.tenants = tenants.TenantManager(self._adapter, self.roles,
                                             self.users)

        # extensions
        self.ec2 = ec2.CredentialsManager(self._adapter)

        # DEPRECATED: if session is passed then we go to the new behaviour of
        # authenticating on the first required call.
        if not kwargs.get('session') and self.management_url is None:
            self.authenticate()
Exemplo n.º 8
0
def generate_test_data():
    ''' Builds a set of test_data data as returned by Keystone V2. '''
    test_data = TestDataContainer()

    keystone_service = {
        'type':
        'identity',
        'name':
        'keystone',
        'endpoints_links': [],
        'endpoints': [{
            'region': 'RegionOne',
            'adminURL': 'http://admin.localhost:35357/v2.0',
            'internalURL': 'http://internal.localhost:5000/v2.0',
            'publicURL': 'http://public.localhost:5000/v2.0'
        }]
    }

    # Users
    user_dict = {
        'id': uuid.uuid4().hex,
        'name': 'gabriel',
        'email': '*****@*****.**',
        'password': '******',
        'token': '',
        'enabled': True
    }
    test_data.user = users.User(users.UserManager(None),
                                user_dict,
                                loaded=True)

    # Tenants
    tenant_dict_1 = {
        'id': uuid.uuid4().hex,
        'name': 'tenant_one',
        'description': '',
        'enabled': True
    }
    tenant_dict_2 = {
        'id': uuid.uuid4().hex,
        'name': 'tenant_two',
        'description': '',
        'enabled': False
    }
    test_data.tenant_one = tenants.Tenant(tenants.TenantManager(None),
                                          tenant_dict_1,
                                          loaded=True)
    test_data.tenant_two = tenants.Tenant(tenants.TenantManager(None),
                                          tenant_dict_2,
                                          loaded=True)

    nova_service = {
        'type':
        'compute',
        'name':
        'nova',
        'endpoint_links': [],
        'endpoints': [{
            'region':
            'RegionOne',
            'adminURL': ('http://nova-admin.localhost:8774/v2.0/%s' %
                         (tenant_dict_1['id'])),
            'internalURL': ('http://nova-internal.localhost:8774/v2.0/%s' %
                            (tenant_dict_1['id'])),
            'publicURL': ('http://nova-public.localhost:8774/v2.0/%s' %
                          (tenant_dict_1['id']))
        }, {
            'region':
            'RegionTwo',
            'adminURL': ('http://nova2-admin.localhost:8774/v2.0/%s' %
                         (tenant_dict_1['id'])),
            'internalURL': ('http://nova2-internal.localhost:8774/v2.0/%s' %
                            (tenant_dict_1['id'])),
            'publicURL': ('http://nova2-public.localhost:8774/v2.0/%s' %
                          (tenant_dict_1['id']))
        }]
    }

    # Roles
    role_dict = {'id': uuid.uuid4().hex, 'name': 'Member'}
    test_data.role = roles.Role(roles.RoleManager, role_dict)

    # Tokens
    tomorrow = datetime_safe.datetime.now() + datetime.timedelta(days=1)
    expiration = datetime_safe.datetime.isoformat(tomorrow)

    scoped_token_dict = {
        'access': {
            'token': {
                'id': uuid.uuid4().hex,
                'expires': expiration,
                'tenant': tenant_dict_1,
                'tenants': [tenant_dict_1, tenant_dict_2]
            },
            'user': {
                'id': user_dict['id'],
                'name': user_dict['name'],
                'roles': [role_dict]
            },
            'serviceCatalog': [keystone_service, nova_service]
        }
    }

    test_data.scoped_access_info = access.AccessInfo.factory(
        resp=None, body=scoped_token_dict)

    unscoped_token_dict = {
        'access': {
            'token': {
                'id': uuid.uuid4().hex,
                'expires': expiration
            },
            'user': {
                'id': user_dict['id'],
                'name': user_dict['name'],
                'roles': [role_dict]
            },
            'serviceCatalog': [keystone_service]
        }
    }
    test_data.unscoped_access_info = access.AccessInfo.factory(
        resp=None, body=unscoped_token_dict)

    # Service Catalog
    test_data.service_catalog = service_catalog.ServiceCatalog.factory({
        'serviceCatalog': [keystone_service, nova_service],
        'token': {
            'id': scoped_token_dict['access']['token']['id'],
            'expires': scoped_token_dict['access']['token']['expires'],
            'user_id': user_dict['id'],
            'tenant_id': tenant_dict_1['id']
        }
    })

    return test_data
Exemplo n.º 9
0
    def __init__(self, http_client, **kwargs):
        """ Initialize a new client for the Keystone v2.0 API. """
        super(IdentityPublicClient, self).__init__(http_client)

        self.tenants = tenants.TenantManager(self)