Merge "keystone v3 support for all endpoint tests"

This commit is contained in:
Jenkins 2016-10-13 10:47:42 +00:00 committed by Gerrit Code Review
commit 0583279a33
6 changed files with 69 additions and 29 deletions
cloudpulse

@ -10,12 +10,19 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from cinderclient.client import Client from cinderclient.client import Client as cinder_client
from keystoneclient.auth.identity import v3 as keystone_v3
from keystoneclient import session
class CinderHealth(object): class CinderHealth(object):
def __init__(self, creds): def __init__(self, creds):
self.cinderclient = Client(**creds) cacert = creds['cacert']
del creds['cacert']
auth = keystone_v3.Password(**creds)
sess = session.Session(auth=auth, verify=cacert)
self.cinderclient = cinder_client(2, session=sess)
def cinder_list(self): def cinder_list(self):
try: try:

@ -12,18 +12,18 @@
from glanceclient.exc import ClientException from glanceclient.exc import ClientException
from glanceclient.v2 import client as glance_client from glanceclient.v2 import client as glance_client
from keystoneclient.auth.identity import v3 as keystone_v3
from keystoneclient import session
class GlanceHealth(object): class GlanceHealth(object):
def __init__(self, keystone_instance): def __init__(self, creds):
authtoken = keystone_instance.keystone_return_authtoken() cacert = creds['cacert']
glance_endpoint = (keystone_instance del creds['cacert']
.keystone_endpoint_find(service_type='image', auth = keystone_v3.Password(**creds)
endpoint_type='internalURL') sess = session.Session(auth=auth, verify=cacert)
) self.glanceclient = glance_client.Client('1', session=sess)
self.glanceclient = glance_client.Client(glance_endpoint,
token=authtoken)
def glance_image_list(self): def glance_image_list(self):
try: try:

@ -10,13 +10,21 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from keystoneclient.auth.identity import v3 as keystone_v3
from keystoneclient import client as keystoneclient
from keystoneclient.exceptions import ClientException from keystoneclient.exceptions import ClientException
from keystoneclient.v2_0 import client as keystone_client from keystoneclient import session
class KeystoneHealth(object): class KeystoneHealth(object):
def __init__(self, creds): def __init__(self, creds):
self.keystoneclient = keystone_client.Client(**creds) cacert = creds['cacert']
del creds['cacert']
auth = keystone_v3.Password(**creds)
sess = session.Session(auth=auth, verify=cacert)
self.keystoneclient = keystoneclient.Client(
3, session=sess, auth_url=creds['auth_url'])
def keystone_service_list(self): def keystone_service_list(self):
try: try:

@ -10,23 +10,37 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from keystoneclient.auth.identity import v3 as keystone_v3
from keystoneclient import session
from neutronclient.common.exceptions import NeutronException from neutronclient.common.exceptions import NeutronException
from neutronclient.v2_0 import client as neutron_client from neutronclient.neutron import client as neutronclient
class NeutronHealth(object): class NeutronHealth(object):
def __init__(self, creds): def __init__(self, creds):
creds['timeout'] = 30 # creds['timeout'] = 30
creds['ca_cert'] = creds['cacert'] cacert = creds['cacert']
self.neutronclient = neutron_client.Client(**creds) del creds['cacert']
auth = keystone_v3.Password(**creds)
sess = session.Session(auth=auth, verify=cacert)
self.neutron_client = neutronclient.Client('2.0', session=sess)
def neutron_agent_list(self): def neutron_agent_list(self):
try: try:
agent_list = self.neutronclient.list_agents() agent_list = self.neutron_client.list_agents()
except (NeutronException, Exception) as e: except (NeutronException, Exception) as e:
return (404, e.message, []) return (404, e.message, [])
return (200, "success", agent_list['agents']) return (200, "success", agent_list['agents'])
def neutron_list_networks(self):
try:
net_list = self.neutron_client.list_networks()
except (NeutronException, Exception) as e:
return (404, e.message, [])
return (200, "success", net_list['networks'])
def network_create(self, network_name): def network_create(self, network_name):
try: try:
self.neutronclient.format = 'json' self.neutronclient.format = 'json'
@ -44,7 +58,7 @@ class NeutronHealth(object):
"network_id": network_id, "network_id": network_id,
"ip_version": 4, "ip_version": 4,
"cidr": network_cidr "cidr": network_cidr
} }
res = self.neutronclient.create_subnet({'subnet': subnet}) res = self.neutronclient.create_subnet({'subnet': subnet})
except (NeutronException, Exception) as e: except (NeutronException, Exception) as e:
return (404, e.message, []) return (404, e.message, [])

@ -10,14 +10,21 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from novaclient.client import Client from keystoneclient.auth.identity import v3 as keystone_v3
from keystoneclient import session
from novaclient.client import Client as novaclient
from novaclient.exceptions import ClientException from novaclient.exceptions import ClientException
class NovaHealth(object): class NovaHealth(object):
def __init__(self, creden):
creden['timeout'] = 30 def __init__(self, creds):
self.novaclient = Client(**creden) # creden['timeout'] = 30
cacert = creds['cacert']
del creds['cacert']
auth = keystone_v3.Password(**creds)
sess = session.Session(auth=auth, verify=cacert)
self.novaclient = novaclient(2, session=sess)
def nova_hypervisor_list(self): def nova_hypervisor_list(self):
try: try:

@ -57,11 +57,16 @@ class endpoint_scenario(base.Scenario):
importutils.import_module('keystonemiddleware.auth_token') importutils.import_module('keystonemiddleware.auth_token')
creds = {} creds = {}
creds['username'] = cfg.CONF.keystone_authtoken.username creds['username'] = cfg.CONF.keystone_authtoken.username
creds['tenant_name'] = cfg.CONF.keystone_authtoken.project_name
creds['password'] = cfg.CONF.keystone_authtoken.password creds['password'] = cfg.CONF.keystone_authtoken.password
creds['project_name'] = cfg.CONF.keystone_authtoken.project_name
creds['auth_url'] = cfg.CONF.keystone_authtoken.auth_uri creds['auth_url'] = cfg.CONF.keystone_authtoken.auth_uri
creds['cacert'] = cfg.CONF.keystone_authtoken.cafile creds['cacert'] = cfg.CONF.keystone_authtoken.cafile
creds['endpoint_type'] = 'internalURL' if cfg.CONF.keystone_authtoken.project_domain_id:
creds[
'project_domain_id'] = (cfg.CONF.keystone_authtoken.
project_domain_id)
creds[
'user_domain_id'] = cfg.CONF.keystone_authtoken.user_domain_id
return creds return creds
def _get_nova_v2_credentials(self): def _get_nova_v2_credentials(self):
@ -78,7 +83,7 @@ class endpoint_scenario(base.Scenario):
@base.scenario(admin_only=False, operator=False) @base.scenario(admin_only=False, operator=False)
def nova_endpoint(self, *args, **kwargs): def nova_endpoint(self, *args, **kwargs):
creds = self._get_nova_v2_credentials() creds = self._get_credentials()
nova = NovaHealth(creds) nova = NovaHealth(creds)
return nova.nova_service_list() return nova.nova_service_list()
@ -86,7 +91,7 @@ class endpoint_scenario(base.Scenario):
def neutron_endpoint(self, *args, **kwargs): def neutron_endpoint(self, *args, **kwargs):
creds = self._get_credentials() creds = self._get_credentials()
neutron = NeutronHealth(creds) neutron = NeutronHealth(creds)
return neutron.neutron_agent_list() return neutron.neutron_list_networks()
@base.scenario(admin_only=False, operator=False) @base.scenario(admin_only=False, operator=False)
def keystone_endpoint(self, *args, **kwargs): def keystone_endpoint(self, *args, **kwargs):
@ -97,13 +102,12 @@ class endpoint_scenario(base.Scenario):
@base.scenario(admin_only=False, operator=False) @base.scenario(admin_only=False, operator=False)
def glance_endpoint(self, *args, **kwargs): def glance_endpoint(self, *args, **kwargs):
creds = self._get_credentials() creds = self._get_credentials()
keystone = KeystoneHealth(creds) glance = GlanceHealth(creds)
glance = GlanceHealth(keystone)
return glance.glance_image_list() return glance.glance_image_list()
@base.scenario(admin_only=False, operator=False) @base.scenario(admin_only=False, operator=False)
def cinder_endpoint(self, *args, **kwargs): def cinder_endpoint(self, *args, **kwargs):
creds = self._get_nova_v2_credentials() creds = self._get_credentials()
cinder = CinderHealth(creds) cinder = CinderHealth(creds)
return cinder.cinder_list() return cinder.cinder_list()