Remove keystone v2 related code
Kyestone V2 support was removed in Train, so it's safe to do such cleanup. Change-Id: I6a379ef79429eb218c6095397949fd8116a934c2
This commit is contained in:
parent
85111f528b
commit
1e304b5826
|
@ -131,8 +131,6 @@ class OSClientManager(object):
|
||||||
os_options['region_name'] = self.swift_args.get('region_name')
|
os_options['region_name'] = self.swift_args.get('region_name')
|
||||||
if 'endpoint_type' in self.swift_args.keys():
|
if 'endpoint_type' in self.swift_args.keys():
|
||||||
os_options['endpoint_type'] = self.swift_args.get('endpoint_type')
|
os_options['endpoint_type'] = self.swift_args.get('endpoint_type')
|
||||||
if 'tenant_id' in self.swift_args.keys():
|
|
||||||
os_options['tenant_id'] = self.swift_args.get('tenant_id')
|
|
||||||
if 'identity_api_version' in self.swift_args.keys():
|
if 'identity_api_version' in self.swift_args.keys():
|
||||||
os_options['identity_api_version'] = \
|
os_options['identity_api_version'] = \
|
||||||
self.swift_args.get('identity_api_version')
|
self.swift_args.get('identity_api_version')
|
||||||
|
@ -348,14 +346,14 @@ class OSClientManager(object):
|
||||||
class OpenstackOpts(object):
|
class OpenstackOpts(object):
|
||||||
"""
|
"""
|
||||||
Gathering and maintaining the right Openstack credentials that will be used
|
Gathering and maintaining the right Openstack credentials that will be used
|
||||||
to authenticate against keystone. Now we support keystone v2 and v3.
|
to authenticate against keystone. Now we support keystone v3.
|
||||||
We need to provide a correct url that ends with either v2.0 or v3
|
We need to provide a correct url that ends with either v3
|
||||||
or provide auth_version or identity_api_version
|
or provide auth_version or identity_api_version
|
||||||
"""
|
"""
|
||||||
def __init__(self, auth_url, auth_method='password', auth_version=None,
|
def __init__(self, auth_url, auth_method='password', auth_version=None,
|
||||||
username=None, password=None, region_name=None, cacert=None,
|
username=None, password=None, region_name=None, cacert=None,
|
||||||
identity_api_version=None, project_id=None, project_name=None,
|
identity_api_version=None, project_id=None, project_name=None,
|
||||||
tenant_id=None, tenant_name=None, token=None, insecure=False,
|
token=None, insecure=False,
|
||||||
endpoint_type='internalURL', interface=None,
|
endpoint_type='internalURL', interface=None,
|
||||||
compute_api_version=2, image_api_version=2,
|
compute_api_version=2, image_api_version=2,
|
||||||
volume_api_version=2, user_domain_name=None, domain_id=None,
|
volume_api_version=2, user_domain_name=None, domain_id=None,
|
||||||
|
@ -364,10 +362,10 @@ class OpenstackOpts(object):
|
||||||
"""
|
"""
|
||||||
Authentication Options to build a valid opts dict to be used to
|
Authentication Options to build a valid opts dict to be used to
|
||||||
authenticate against keystone. You must provide auth_url with a vaild
|
authenticate against keystone. You must provide auth_url with a vaild
|
||||||
Openstack version at the end v2.0 or v3 or provide auth_version.
|
Openstack version at the end v3 or provide auth_version.
|
||||||
:param auth_url: string Keystone API URL
|
:param auth_url: string Keystone API URL
|
||||||
:param auth_method: string defaults to password or token (not tested)
|
:param auth_method: string defaults to password or token (not tested)
|
||||||
:param auth_version: string Keystone API version. 2.0 or 3
|
:param auth_version: string Keystone API version. v3
|
||||||
:param username: string A valid Username
|
:param username: string A valid Username
|
||||||
:param password: string A valid Password
|
:param password: string A valid Password
|
||||||
:param region_name: string Region name or None
|
:param region_name: string Region name or None
|
||||||
|
@ -375,9 +373,6 @@ class OpenstackOpts(object):
|
||||||
:param identity_api_version: string Keystone API version to use
|
:param identity_api_version: string Keystone API version to use
|
||||||
:param project_id: UUID string Project ID
|
:param project_id: UUID string Project ID
|
||||||
:param project_name: string Project Name
|
:param project_name: string Project Name
|
||||||
:param tenant_id: string Project/ Tenant ID.
|
|
||||||
Use with keystone v2.0 only
|
|
||||||
:param tenant_name: string Project/ Tenant Name. keystone v2.0 only
|
|
||||||
:param token: string Valid token. Only if auth_method is token
|
:param token: string Valid token. Only if auth_method is token
|
||||||
:param insecure: boolean Use insecure connections
|
:param insecure: boolean Use insecure connections
|
||||||
:param endpoint_type: string publicURL, adminURL, internalURL
|
:param endpoint_type: string publicURL, adminURL, internalURL
|
||||||
|
@ -402,10 +397,8 @@ class OpenstackOpts(object):
|
||||||
self.region_name = region_name
|
self.region_name = region_name
|
||||||
self.cacert = cacert
|
self.cacert = cacert
|
||||||
self.identity_api_version = identity_api_version
|
self.identity_api_version = identity_api_version
|
||||||
self.tenant_id = tenant_id or project_id
|
self.project_id = project_id
|
||||||
self.project_id = project_id or tenant_id
|
self.project_name = project_name
|
||||||
self.project_name = project_name or tenant_name
|
|
||||||
self.tenant_name = tenant_name or project_name
|
|
||||||
self.token = token
|
self.token = token
|
||||||
self.insecure = insecure
|
self.insecure = insecure
|
||||||
self.endpoint_type = endpoint_type
|
self.endpoint_type = endpoint_type
|
||||||
|
@ -457,27 +450,8 @@ class OpenstackOpts(object):
|
||||||
self.auth_version = str(self.auth_version)
|
self.auth_version = str(self.auth_version)
|
||||||
self.identity_api_version = str(self.identity_api_version)
|
self.identity_api_version = str(self.identity_api_version)
|
||||||
|
|
||||||
if self.auth_version == '3' or self.identity_api_version == '3':
|
opts['auth_version'] = opts['identity_api_version'] = '3'
|
||||||
opts['auth_version'] = opts['identity_api_version'] = '3'
|
|
||||||
opts.pop('tenant_id', None)
|
|
||||||
opts.pop('tenant_name', None)
|
|
||||||
|
|
||||||
elif (self.auth_version in ['2.0', '2'] or
|
|
||||||
self.identity_api_version in ['2.0', '2']):
|
|
||||||
opts['auth_version'] = opts['identity_api_version'] = '2.0'
|
|
||||||
# these parameters won't work with keystone v2.0
|
|
||||||
opts.pop('project_id', None)
|
|
||||||
opts.pop('project_name', None)
|
|
||||||
opts.pop('project_domain_id', None)
|
|
||||||
opts.pop('project_domain_name', None)
|
|
||||||
opts.pop('user_domain_id', None)
|
|
||||||
opts.pop('user_domain_name', None)
|
|
||||||
opts.pop('domain_id', None)
|
|
||||||
opts.pop('domain_name', None)
|
|
||||||
else:
|
|
||||||
raise Exception('Keystone Auth version {0} is not supported!. '
|
|
||||||
'Generated from auth_url: {1}'.
|
|
||||||
format(self.auth_version, self.auth_url))
|
|
||||||
for i in opts.copy().keys():
|
for i in opts.copy().keys():
|
||||||
if opts.get(i) is None:
|
if opts.get(i) is None:
|
||||||
opts.pop(i)
|
opts.pop(i)
|
||||||
|
@ -505,8 +479,6 @@ class OpenstackOpts(object):
|
||||||
auth_version=src_dict.get('OS_AUTH_VERSION', None),
|
auth_version=src_dict.get('OS_AUTH_VERSION', None),
|
||||||
username=src_dict.get('OS_USERNAME', None),
|
username=src_dict.get('OS_USERNAME', None),
|
||||||
password=src_dict.get('OS_PASSWORD', None),
|
password=src_dict.get('OS_PASSWORD', None),
|
||||||
tenant_id=src_dict.get('OS_TENANT_ID', None),
|
|
||||||
tenant_name=src_dict.get('OS_TENANT_NAME', None),
|
|
||||||
project_id=src_dict.get('OS_PROJECT_ID', None),
|
project_id=src_dict.get('OS_PROJECT_ID', None),
|
||||||
project_name=src_dict.get('OS_PROJECT_NAME', None),
|
project_name=src_dict.get('OS_PROJECT_NAME', None),
|
||||||
region_name=src_dict.get('OS_REGION_NAME', None),
|
region_name=src_dict.get('OS_REGION_NAME', None),
|
||||||
|
|
|
@ -62,7 +62,7 @@ def get_common_opts():
|
||||||
short='c',
|
short='c',
|
||||||
help='Specifies the client_id used when contacting the '
|
help='Specifies the client_id used when contacting the '
|
||||||
'service.\n If not specified it will be automatically '
|
'service.\n If not specified it will be automatically '
|
||||||
'created \n using the tenant-id and the machine '
|
'created \n using the project-id and the machine '
|
||||||
'hostname.'),
|
'hostname.'),
|
||||||
cfg.BoolOpt('no-api',
|
cfg.BoolOpt('no-api',
|
||||||
default=False,
|
default=False,
|
||||||
|
@ -154,16 +154,6 @@ def build_os_options():
|
||||||
help='User\'s domain name. Defaults to '
|
help='User\'s domain name. Defaults to '
|
||||||
'env[OS_USER_DOMAIN_NAME].',
|
'env[OS_USER_DOMAIN_NAME].',
|
||||||
dest='os_user_domain_name'),
|
dest='os_user_domain_name'),
|
||||||
cfg.StrOpt('os-tenant-name',
|
|
||||||
default=env('OS_TENANT_NAME'),
|
|
||||||
help='Tenant to request authorization on. Defaults to '
|
|
||||||
'env[OS_TENANT_NAME].',
|
|
||||||
dest='os_tenant_name'),
|
|
||||||
cfg.StrOpt('os-tenant-id',
|
|
||||||
default=env('OS_TENANT_ID'),
|
|
||||||
help='Tenant to request authorization on. Defaults to '
|
|
||||||
'env[OS_TENANT_ID].',
|
|
||||||
dest='os_tenant_id'),
|
|
||||||
cfg.StrOpt('os-auth-url',
|
cfg.StrOpt('os-auth-url',
|
||||||
default=env('OS_AUTH_URL'),
|
default=env('OS_AUTH_URL'),
|
||||||
help='Specify the Identity endpoint to use for '
|
help='Specify the Identity endpoint to use for '
|
||||||
|
|
|
@ -70,30 +70,19 @@ class PySvc(win32serviceutil.ServiceFramework):
|
||||||
if os.environ.get('SERVICE_INSECURE'):
|
if os.environ.get('SERVICE_INSECURE'):
|
||||||
self.insecure = True
|
self.insecure = True
|
||||||
|
|
||||||
# Add support for keystone v2 and v3
|
# only support for keystone v3
|
||||||
credentials = {}
|
credentials = {}
|
||||||
if os.environ['OS_IDENTITY_API_VERSION'] == 2:
|
# if os.environ['OS_IDENTITY_API_VERSION'] == 3:
|
||||||
credentials = {
|
credentials = {
|
||||||
'version': 2,
|
'username': os.environ['OS_USERNAME'],
|
||||||
'username': os.environ['OS_USERNAME'],
|
'password': os.environ['OS_PASSWORD'],
|
||||||
'password': os.environ['OS_PASSWORD'],
|
'auth_url': os.environ['OS_AUTH_URL'],
|
||||||
'auth_url': os.environ['OS_AUTH_URL'],
|
'endpoint': os.environ['OS_BACKUP_URL'],
|
||||||
'endpoint': os.environ['OS_BACKUP_URL'],
|
'project_name': os.environ['OS_PROJECT_NAME'],
|
||||||
'tenant_name': os.environ['OS_TENANT_NAME'],
|
'user_domain_name': os.environ['OS_USER_DOMAIN_NAME'],
|
||||||
'insecure': self.insecure
|
'project_domain_name': os.environ['OS_PROJECT_DOMAIN_NAME'],
|
||||||
}
|
'insecure': self.insecure
|
||||||
elif os.environ['OS_IDENTITY_API_VERSION'] == 3:
|
}
|
||||||
credentials = {
|
|
||||||
'version': 3,
|
|
||||||
'username': os.environ['OS_USERNAME'],
|
|
||||||
'password': os.environ['OS_PASSWORD'],
|
|
||||||
'auth_url': os.environ['OS_AUTH_URL'],
|
|
||||||
'endpoint': os.environ['OS_BACKUP_URL'],
|
|
||||||
'project_name': os.environ['OS_PROJECT_NAME'],
|
|
||||||
'user_domain_name': os.environ['OS_USER_DOMAIN_NAME'],
|
|
||||||
'project_domain_name': os.environ['OS_PROJECT_DOMAIN_NAME'],
|
|
||||||
'insecure': self.insecure
|
|
||||||
}
|
|
||||||
|
|
||||||
client = Client(**credentials)
|
client = Client(**credentials)
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,11 @@ from freezer.storage import swift
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
os.environ['OS_REGION_NAME'] = 'testregion'
|
os.environ['OS_REGION_NAME'] = 'testregion'
|
||||||
os.environ['OS_TENANT_ID'] = '0123456789'
|
os.environ['OS_PROJECT_ID'] = '0123456789'
|
||||||
os.environ['OS_PASSWORD'] = 'testpassword'
|
os.environ['OS_PASSWORD'] = 'testpassword'
|
||||||
os.environ['OS_AUTH_URL'] = 'http://testauthurl/v2.0'
|
os.environ['OS_AUTH_URL'] = 'http://testauthurl/v3'
|
||||||
os.environ['OS_USERNAME'] = 'testusername'
|
os.environ['OS_USERNAME'] = 'testusername'
|
||||||
os.environ['OS_TENANT_NAME'] = 'testtenantename'
|
os.environ['OS_PROJECT_NAME'] = 'testtenantename'
|
||||||
|
|
||||||
|
|
||||||
class FakeSubProcess(object):
|
class FakeSubProcess(object):
|
||||||
|
|
|
@ -243,20 +243,20 @@ class TestFS(unittest.TestCase):
|
||||||
container = os.environ.get('FREEZER_TEST_CONTAINER')
|
container = os.environ.get('FREEZER_TEST_CONTAINER')
|
||||||
use_ssh = ssh_key and ssh_username and ssh_host and container
|
use_ssh = ssh_key and ssh_username and ssh_host and container
|
||||||
|
|
||||||
os_tenant_name = os.environ.get('FREEZER_TEST_OS_TENANT_NAME')
|
os_project_name = os.environ.get('FREEZER_TEST_OS_TENANT_NAME')
|
||||||
os_user_name = os.environ.get('FREEZER_TEST_OS_USERNAME')
|
os_user_name = os.environ.get('FREEZER_TEST_OS_USERNAME')
|
||||||
os_region = os.environ.get('FREEZER_TEST_OS_REGION_NAME')
|
os_region = os.environ.get('FREEZER_TEST_OS_REGION_NAME')
|
||||||
os_password = os.environ.get('FREEZER_TEST_OS_PASSWORD')
|
os_password = os.environ.get('FREEZER_TEST_OS_PASSWORD')
|
||||||
os_auth_url = os.environ.get('FREEZER_TEST_OS_AUTH_URL')
|
os_auth_url = os.environ.get('FREEZER_TEST_OS_AUTH_URL')
|
||||||
use_os = (os_tenant_name and os_user_name and os_region and
|
use_os = (os_project_name and os_user_name and os_region and
|
||||||
os_password and os_auth_url)
|
os_password and os_auth_url)
|
||||||
if use_os:
|
if use_os:
|
||||||
os.environ['OS_USERNAME'] = os_user_name
|
os.environ['OS_USERNAME'] = os_user_name
|
||||||
os.environ['OS_TENANT_NAME'] = os_tenant_name
|
os.environ['OS_PROJECT_NAME'] = os_project_name
|
||||||
os.environ['OS_AUTH_URL'] = os_auth_url
|
os.environ['OS_AUTH_URL'] = os_auth_url
|
||||||
os.environ['OS_PASSWORD'] = os_password
|
os.environ['OS_PASSWORD'] = os_password
|
||||||
os.environ['OS_REGION_NAME'] = os_region
|
os.environ['OS_REGION_NAME'] = os_region
|
||||||
os.environ['OS_TENANT_ID'] = ''
|
os.environ['OS_PROJECT_ID'] = ''
|
||||||
|
|
||||||
openstack_executable = distutils.spawn.find_executable('openstack')
|
openstack_executable = distutils.spawn.find_executable('openstack')
|
||||||
swift_executable = distutils.spawn.find_executable('swift')
|
swift_executable = distutils.spawn.find_executable('swift')
|
||||||
|
|
|
@ -22,7 +22,7 @@ from freezer.openstack import osclients
|
||||||
class TestOsClients(unittest.TestCase):
|
class TestOsClients(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.opts = osclients.OpenstackOpts(
|
self.opts = osclients.OpenstackOpts(
|
||||||
username="user", tenant_name="tenant", project_name="project",
|
username="user", project_name="project",
|
||||||
auth_url="url/v3", password="password", identity_api_version="3",
|
auth_url="url/v3", password="password", identity_api_version="3",
|
||||||
insecure=False, cacert='cert', user_domain_name='Default',
|
insecure=False, cacert='cert', user_domain_name='Default',
|
||||||
project_domain_name='Default').get_opts_dicts()
|
project_domain_name='Default').get_opts_dicts()
|
||||||
|
|
|
@ -76,24 +76,24 @@ class TestUtils(commons.FreezerBaseTestCase):
|
||||||
self.__dict__.update(opts)
|
self.__dict__.update(opts)
|
||||||
|
|
||||||
env_dict = dict(OS_USERNAME='testusername',
|
env_dict = dict(OS_USERNAME='testusername',
|
||||||
OS_TENANT_NAME='testtenantename',
|
OS_PROJECT_NAME='testtenantename',
|
||||||
OS_AUTH_URL='testauthurl',
|
OS_AUTH_URL='testauthurl',
|
||||||
OS_PASSWORD='testpassword',
|
OS_PASSWORD='testpassword',
|
||||||
OS_REGION_NAME='testregion',
|
OS_REGION_NAME='testregion',
|
||||||
OS_TENANT_ID='0123456789',
|
OS_PROJECT_ID='0123456789',
|
||||||
OS_AUTH_VERSION='2.0')
|
OS_AUTH_VERSION='2.0')
|
||||||
options = osclients.OpenstackOpts.create_from_dict(
|
options = osclients.OpenstackOpts.create_from_dict(
|
||||||
env_dict).get_opts_dicts()
|
env_dict).get_opts_dicts()
|
||||||
options = FreezerOpts(options)
|
options = FreezerOpts(options)
|
||||||
assert options.username == env_dict['OS_USERNAME']
|
assert options.username == env_dict['OS_USERNAME']
|
||||||
assert options.tenant_name == env_dict['OS_TENANT_NAME']
|
assert options.project_name == env_dict['OS_PROJECT_NAME']
|
||||||
assert options.auth_url == env_dict['OS_AUTH_URL']
|
assert options.auth_url == env_dict['OS_AUTH_URL']
|
||||||
assert options.password == env_dict['OS_PASSWORD']
|
assert options.password == env_dict['OS_PASSWORD']
|
||||||
assert options.region_name == env_dict['OS_REGION_NAME']
|
assert options.region_name == env_dict['OS_REGION_NAME']
|
||||||
assert options.tenant_id == env_dict['OS_TENANT_ID']
|
assert options.project_id == env_dict['OS_PROJECT_ID']
|
||||||
|
|
||||||
env_dict = dict(OS_USERNAME='testusername',
|
env_dict = dict(OS_USERNAME='testusername',
|
||||||
OS_TENANT_NAME='testtenantename',
|
OS_PROJECT_NAME='testtenantename',
|
||||||
OS_AUTH_URL='testauthurl',
|
OS_AUTH_URL='testauthurl',
|
||||||
OS_PASSWORD='testpassword',
|
OS_PASSWORD='testpassword',
|
||||||
OS_AUTH_VERSION='2.0')
|
OS_AUTH_VERSION='2.0')
|
||||||
|
@ -101,7 +101,7 @@ class TestUtils(commons.FreezerBaseTestCase):
|
||||||
env_dict).get_opts_dicts()
|
env_dict).get_opts_dicts()
|
||||||
options = FreezerOpts(options)
|
options = FreezerOpts(options)
|
||||||
assert options.username == env_dict['OS_USERNAME']
|
assert options.username == env_dict['OS_USERNAME']
|
||||||
assert options.tenant_name == env_dict['OS_TENANT_NAME']
|
assert options.project_name == env_dict['OS_PROJECT_NAME']
|
||||||
assert options.auth_url == env_dict['OS_AUTH_URL']
|
assert options.auth_url == env_dict['OS_AUTH_URL']
|
||||||
assert options.password == env_dict['OS_PASSWORD']
|
assert options.password == env_dict['OS_PASSWORD']
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue