def test_url_for(self):
        url = api_base.url_for(self.request, 'image')
        self.assertEqual(url, 'http://int.glance.example.com:9292/v1')

        url = api_base.url_for(self.request, 'image', admin=False)
        self.assertEqual(url, 'http://int.glance.example.com:9292/v1')

        url = api_base.url_for(self.request, 'image', admin=True)
        self.assertEqual(url, 'http://admin.glance.example.com:9292/v1')

        url = api_base.url_for(self.request, 'compute')
        self.assertEqual(url, 'http://int.nova.example.com:8774/v2')

        url = api_base.url_for(self.request, 'compute', admin=False)
        self.assertEqual(url, 'http://int.nova.example.com:8774/v2')

        url = api_base.url_for(self.request, 'compute', admin=True)
        self.assertEqual(url, 'http://admin.nova.example.com:8774/v2')

        url = api_base.url_for(self.request, 'volume')
        self.assertEqual(url, 'http://int.nova.example.com:8776/v1')

        url = api_base.url_for(self.request, 'volume', admin=False)
        self.assertEqual(url, 'http://int.nova.example.com:8776/v1')

        url = api_base.url_for(self.request, 'volume', admin=True)
        self.assertEqual(url, 'http://admin.nova.example.com:8776/v1')

        self.assertNotIn('notAnApi', self.request.user.service_catalog,
                         'Select a new nonexistent service catalog key')
        with self.assertRaises(exceptions.ServiceCatalogException):
            url = api_base.url_for(self.request, 'notAnApi')
Exemple #2
0
    def test_url_for(self):
        url = api_base.url_for(self.request, 'image')
        self.assertEqual(url, 'http://internal.glance.example.com:9292/v1')

        url = api_base.url_for(self.request, 'image', admin=False)
        self.assertEqual(url, 'http://internal.glance.example.com:9292/v1')

        url = api_base.url_for(self.request, 'image', admin=True)
        self.assertEqual(url, 'http://admin.glance.example.com:9292/v1')

        url = api_base.url_for(self.request, 'compute')
        self.assertEqual(url, 'http://internal.nova.example.com:8774/v2')

        url = api_base.url_for(self.request, 'compute', admin=False)
        self.assertEqual(url, 'http://internal.nova.example.com:8774/v2')

        url = api_base.url_for(self.request, 'compute', admin=True)
        self.assertEqual(url, 'http://admin.nova.example.com:8774/v2')

        url = api_base.url_for(self.request, 'volume')
        self.assertEqual(url, 'http://internal.nova.example.com:8776/v1')

        url = api_base.url_for(self.request, 'volume', admin=False)
        self.assertEqual(url, 'http://internal.nova.example.com:8776/v1')

        url = api_base.url_for(self.request, 'volume', admin=True)
        self.assertEqual(url, 'http://admin.nova.example.com:8776/v1')

        self.assertNotIn('notAnApi', self.request.user.service_catalog,
                         'Select a new nonexistent service catalog key')
        with self.assertRaises(exceptions.ServiceCatalogException):
            url = api_base.url_for(self.request, 'notAnApi')
Exemple #3
0
def quantumclient(request):
    LOG.debug('quantumclient connection created using token "%s" and url "%s"'
              % (request.user.token.id, url_for(request, 'network')))
    LOG.debug('user_id=%(user)s, tenant_id=%(tenant)s' %
              {'user': request.user.id, 'tenant': request.user.tenant_id})
    c = quantum_client.Client(token=request.user.token.id,
                              endpoint_url=url_for(request, 'network'))
    return c
Exemple #4
0
def quantumclient(request):
    LOG.debug('quantumclient connection created using token "%s" and url "%s"'
              % (request.user.token.id, url_for(request, 'network')))
    LOG.debug('user_id=%(user)s, tenant_id=%(tenant)s' %
              {'user': request.user.id, 'tenant': request.user.tenant_id})
    c = quantum_client.Client(token=request.user.token.id,
                              endpoint_url=url_for(request, 'network'))
    return c
Exemple #5
0
def cinderclient(request):
    LOG.debug('cinderclient connection created using token "%s" and url "%s"' %
              (request.user.token, url_for(request, 'volume')))
    c = nova_client.Client(request.user.username,
                           request.user.token,
                           project_id=request.user.tenant_id,
                           auth_url=url_for(request, 'volume'))
    c.client.auth_token = request.user.token
    c.client.management_url = url_for(request, 'volume')
    return c
Exemple #6
0
def novaclient(request):
    LOG.debug('novaclient connection created using token "%s" and url "%s"' %
              (request.user.token.id, url_for(request, 'compute')))
    c = nova_client.Client(request.user.username,
                           request.user.token.id,
                           project_id=request.user.tenant_id,
                           auth_url=url_for(request, 'compute'))
    c.client.auth_token = request.user.token.id
    c.client.management_url = url_for(request, 'compute')
    return c
Exemple #7
0
def cinderclient(request):
    LOG.debug('cinderclient connection created using token "%s" and url "%s"' %
              (request.user.token, url_for(request, 'volume')))
    c = nova_client.Client(request.user.username,
                           request.user.token,
                           project_id=request.user.tenant_id,
                           auth_url=url_for(request, 'volume'))
    c.client.auth_token = request.user.token
    c.client.management_url = url_for(request, 'volume')
    return c
def hostcapabilityclient(request):
    insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
    LOG.debug('hostcapabilityclient connection created using token "%s" and url "%s"' %
              (request.user.token.id, url_for(request, 'compute')))
    c = host_capability_client(request.user.username,
        request.user.token.id,
        project_id=request.user.tenant_id,
        auth_url=url_for(request, 'compute'),
        insecure=insecure)
    c.client.auth_token = request.user.token.id
    c.client.management_url = url_for(request, 'compute')
    return c
Exemple #9
0
def cinderclient(request):
    insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
    LOG.debug('cinderclient connection created using token "%s" and url "%s"' %
              (request.user.token.id, url_for(request, 'volume')))
    c = cinder_client.Client(request.user.username,
                             request.user.token.id,
                             project_id=request.user.tenant_id,
                             auth_url=url_for(request, 'volume'),
                             insecure=insecure)
    c.client.auth_token = request.user.token.id
    c.client.management_url = url_for(request, 'volume')
    return c
Exemple #10
0
def glanceclient(request):
    o = urlparse.urlparse(url_for(request, 'image'))
    LOG.debug('glanceclient connection created for host "%s:%d"' %
                     (o.hostname, o.port))
    return glance_client.Client(o.hostname,
                                o.port,
                                auth_tok=request.user.token)
Exemple #11
0
def glanceclient(request):
    o = urlparse.urlparse(url_for(request, 'image'))
    LOG.debug('glanceclient connection created for host "%s:%d"' %
              (o.hostname, o.port))
    return glance_client.Client(o.hostname,
                                o.port,
                                auth_tok=request.user.token)
Exemple #12
0
def _get_endpoint_url(request, endpoint_type, catalog=None):
    if getattr(request.user, "service_catalog", None):
        return base.url_for(request,
                            service_type='identity',
                            endpoint_type=endpoint_type)
    return request.session.get('region_endpoint',
                               getattr(settings, 'OPENSTACK_KEYSTONE_URL'))
Exemple #13
0
def _get_endpoint_url(request, endpoint_type, catalog=None):
    if getattr(request.user, "service_catalog", None):
        return base.url_for(request,
                            service_type='identity',
                            endpoint_type=endpoint_type)
    return request.session.get('region_endpoint',
                               getattr(settings, 'OPENSTACK_KEYSTONE_URL'))
Exemple #14
0
def glanceclient(request):
    o = urlparse.urlparse(url_for(request, 'image'))
    url = "://".join((o.scheme, o.netloc))
    insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
    LOG.debug('glanceclient connection created using token "%s" and url "%s"'
              % (request.user.token.id, url))
    return glance_client.Client('1', url, token=request.user.token.id,
                                insecure=insecure)
Exemple #15
0
def cinderclient(request):
    LOG.debug('cinderclient connection created using token "%s" and url "%s"' %
              (request.user.token, url_for(request, 'volume')))
    # jt
    #c = nova_client.Client(request.user.username,
    #                       request.user.token,
    #                       project_id=request.user.tenant_id,
    #                       auth_url=url_for(request, 'volume'))
    c = nova_client.Client(request.user.username,
                           request.user.token,
                           project_id=request.user.tenant_id,
                           region_name=request.session.get(
                               'region_name', None),
                           auth_url=url_for(request, 'volume'))
    c.client.auth_token = request.user.token
    c.client.management_url = url_for(request, 'volume')
    return c
Exemple #16
0
def glanceclient(request):
    o = urlparse.urlparse(url_for(request, 'image'))
    url = "://".join((o.scheme, o.netloc))
    insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
    LOG.debug('glanceclient connection created using token "%s" and url "%s"'
              % (request.user.token.id, url))
    return glance_client.Client('1', url, token=request.user.token.id,
                                insecure=insecure)
Exemple #17
0
def glanceclient(request):
    o = urlparse.urlparse(url_for(request, 'image'))
    LOG.debug('glanceclient connection created for host "%s:%d"' %
                     (o.hostname, o.port))
    # jt
    #return glance_client.Client(o.hostname,
    #                            o.port,
    #                            auth_tok=request.user.token)
    return glance_client.get_client(o.hostname, o.port, auth_token=request.user.token, region=request.session.get('region_name', None), auth_url=request.session.get('region_endpoint', None), auth_strategy='keystone')
Exemple #18
0
def novaclient(request):
    insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
    LOG.debug('novaclient connection created using token "%s" and url "%s"' %
              (request.user.token.id, url_for(request, 'compute')))
    # jt
    #c = nova_client.Client(request.user.username,
    #                       request.user.token.id,
    #                       project_id=request.user.tenant_id,
    #                       auth_url=url_for(request, 'compute'),
    #                       insecure=insecure)
    c = nova_client.Client(request.user.username,
                           request.user.token.id,
                           project_id=request.user.tenant_id,
                           region_name=request.session.get('region_name', None),
                           auth_url=url_for(request, 'compute'),
                           insecure=insecure)
    c.client.auth_token = request.user.token.id
    c.client.management_url = url_for(request, 'compute')
    return c
Exemple #19
0
def swift_api(request):
    endpoint = url_for(request, 'object-store')
    LOG.debug('Swift connection created using token "%s" and url "%s"'
              % (request.user.token.id, endpoint))
    return swiftclient.client.Connection(None,
                                         request.user.username,
                                         None,
                                         preauthtoken=request.user.token.id,
                                         preauthurl=endpoint,
                                         auth_version="2.0")
Exemple #20
0
def swift_api(request):
    endpoint = url_for(request, 'object-store')
    LOG.debug('Swift connection created using token "%s" and url "%s"' %
              (request.user.token.id, endpoint))
    return swiftclient.client.Connection(None,
                                         request.user.username,
                                         None,
                                         preauthtoken=request.user.token.id,
                                         preauthurl=endpoint,
                                         auth_version="2.0")
Exemple #21
0
def get_client(request):
    user_id = request.user.id
    tenant_id = request.user.tenant_id
    auth_token = request.user.token
    management_url = api_base.url_for(request, 'compute')

    client = NovaClient(None, user_id, None, tenant_id)
    client.auth_token = auth_token
    client.management_url = management_url

    return client
Exemple #22
0
def get_eho_address(request):
    eho_address = 'endpoints'
    logging.warning("test")
    try:
        eho_address = EHO_ADDRESS
    except NameError:
        pass

    if eho_address == 'endpoints':
        return url_for(request, 'Hadoop')
    
    return eho_address + "/" + request.user.tenant_id
Exemple #23
0
def glanceclient(request):
    o = urlparse.urlparse(url_for(request, 'image'))
    LOG.debug('glanceclient connection created for host "%s:%d"' %
              (o.hostname, o.port))
    # jt
    #return glance_client.Client(o.hostname,
    #                            o.port,
    #                            auth_tok=request.user.token)
    return glance_client.get_client(
        o.hostname,
        o.port,
        auth_token=request.user.token,
        region=request.session.get('region_name', None),
        auth_url=request.session.get('region_endpoint', None),
        auth_strategy='keystone')
Exemple #24
0
def cinderclient(request):
    insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
    cinder_url = ""
    try:
        cinder_url = url_for(request, 'volume')
    except exceptions.ServiceCatalogException:
        LOG.debug('no volume service configured.')
        return None
    LOG.debug('cinderclient connection created using token "%s" and url "%s"' %
              (request.user.token.id, cinder_url))
    c = cinder_client.Client(request.user.username,
                             request.user.token.id,
                             project_id=request.user.tenant_id,
                             auth_url=cinder_url,
                             insecure=insecure)
    c.client.auth_token = request.user.token.id
    c.client.management_url = cinder_url
    return c
 def __init__(self):
     self.cdn_enabled = False
     self.uri = base.url_for(request, "object-store")
     self.token = TEST.token
     self.user_agent = "python-cloudfiles"
Exemple #26
0
def quantum_api(request):
    tenant = request.user.tenant_id
    url = urlparse.urlparse(url_for(request, 'network'))
    return quantum_client.Client(url.hostname, url.port, False, tenant, 'json')
Exemple #27
0
def glanceclient(request):
    o = urlparse.urlparse(url_for(request, 'image'))
    url = "://".join((o.scheme, o.netloc))
    LOG.debug('glanceclient connection created using token "%s" and url "%s"' %
              (request.user.token.id, url))
    return glance_client.Client(endpoint=url, token=request.user.token.id)
 def __init__(self):
     self.cdn_enabled = False
     self.uri = base.url_for(request, "object-store")
     self.token = TEST.token
     self.user_agent = "python-cloudfiles"
Exemple #29
0
def swift_api(request):
    endpoint = url_for(request, 'object-store')
    LOG.debug('Swift connection created using token "%s" and url "%s"' %
              (request.session['token'], endpoint))
    auth = SwiftAuthentication(endpoint, request.session['token'])
    return cloudfiles.get_connection(auth=auth)
Exemple #30
0
def swift_api(request):
    endpoint = url_for(request, 'object-store')
    LOG.debug('Swift connection created using token "%s" and url "%s"'
              % (request.session['token'], endpoint))
    auth = SwiftAuthentication(endpoint, request.session['token'])
    return cloudfiles.get_connection(auth=auth)
Exemple #31
0
def glanceclient(request):
    o = urlparse.urlparse(url_for(request, 'image'))
    url = "://".join((o.scheme, o.netloc))
    LOG.debug('glanceclient connection created using token "%s" and url "%s"'
              % (request.user.token.id, url))
    return glance_client.Client(endpoint=url, token=request.user.token.id)