Merge "keystone v3 support for all endpoint tests"
This commit is contained in:
commit
0583279a33
cloudpulse
openstack/api
scenario/plugins/endpoint_tests
@ -10,12 +10,19 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# 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):
|
||||
|
||||
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):
|
||||
try:
|
||||
|
@ -12,18 +12,18 @@
|
||||
|
||||
from glanceclient.exc import ClientException
|
||||
from glanceclient.v2 import client as glance_client
|
||||
from keystoneclient.auth.identity import v3 as keystone_v3
|
||||
from keystoneclient import session
|
||||
|
||||
|
||||
class GlanceHealth(object):
|
||||
|
||||
def __init__(self, keystone_instance):
|
||||
authtoken = keystone_instance.keystone_return_authtoken()
|
||||
glance_endpoint = (keystone_instance
|
||||
.keystone_endpoint_find(service_type='image',
|
||||
endpoint_type='internalURL')
|
||||
)
|
||||
self.glanceclient = glance_client.Client(glance_endpoint,
|
||||
token=authtoken)
|
||||
def __init__(self, creds):
|
||||
cacert = creds['cacert']
|
||||
del creds['cacert']
|
||||
auth = keystone_v3.Password(**creds)
|
||||
sess = session.Session(auth=auth, verify=cacert)
|
||||
self.glanceclient = glance_client.Client('1', session=sess)
|
||||
|
||||
def glance_image_list(self):
|
||||
try:
|
||||
|
@ -10,13 +10,21 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# 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.v2_0 import client as keystone_client
|
||||
from keystoneclient import session
|
||||
|
||||
|
||||
class KeystoneHealth(object):
|
||||
|
||||
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):
|
||||
try:
|
||||
|
@ -10,23 +10,37 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
from keystoneclient.auth.identity import v3 as keystone_v3
|
||||
from keystoneclient import session
|
||||
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):
|
||||
|
||||
def __init__(self, creds):
|
||||
creds['timeout'] = 30
|
||||
creds['ca_cert'] = creds['cacert']
|
||||
self.neutronclient = neutron_client.Client(**creds)
|
||||
# creds['timeout'] = 30
|
||||
cacert = creds['cacert']
|
||||
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):
|
||||
try:
|
||||
agent_list = self.neutronclient.list_agents()
|
||||
agent_list = self.neutron_client.list_agents()
|
||||
except (NeutronException, Exception) as e:
|
||||
return (404, e.message, [])
|
||||
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):
|
||||
try:
|
||||
self.neutronclient.format = 'json'
|
||||
@ -44,7 +58,7 @@ class NeutronHealth(object):
|
||||
"network_id": network_id,
|
||||
"ip_version": 4,
|
||||
"cidr": network_cidr
|
||||
}
|
||||
}
|
||||
res = self.neutronclient.create_subnet({'subnet': subnet})
|
||||
except (NeutronException, Exception) as e:
|
||||
return (404, e.message, [])
|
||||
|
@ -10,14 +10,21 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# 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
|
||||
|
||||
|
||||
class NovaHealth(object):
|
||||
def __init__(self, creden):
|
||||
creden['timeout'] = 30
|
||||
self.novaclient = Client(**creden)
|
||||
|
||||
def __init__(self, creds):
|
||||
# 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):
|
||||
try:
|
||||
|
@ -57,11 +57,16 @@ class endpoint_scenario(base.Scenario):
|
||||
importutils.import_module('keystonemiddleware.auth_token')
|
||||
creds = {}
|
||||
creds['username'] = cfg.CONF.keystone_authtoken.username
|
||||
creds['tenant_name'] = cfg.CONF.keystone_authtoken.project_name
|
||||
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['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
|
||||
|
||||
def _get_nova_v2_credentials(self):
|
||||
@ -78,7 +83,7 @@ class endpoint_scenario(base.Scenario):
|
||||
|
||||
@base.scenario(admin_only=False, operator=False)
|
||||
def nova_endpoint(self, *args, **kwargs):
|
||||
creds = self._get_nova_v2_credentials()
|
||||
creds = self._get_credentials()
|
||||
nova = NovaHealth(creds)
|
||||
return nova.nova_service_list()
|
||||
|
||||
@ -86,7 +91,7 @@ class endpoint_scenario(base.Scenario):
|
||||
def neutron_endpoint(self, *args, **kwargs):
|
||||
creds = self._get_credentials()
|
||||
neutron = NeutronHealth(creds)
|
||||
return neutron.neutron_agent_list()
|
||||
return neutron.neutron_list_networks()
|
||||
|
||||
@base.scenario(admin_only=False, operator=False)
|
||||
def keystone_endpoint(self, *args, **kwargs):
|
||||
@ -97,13 +102,12 @@ class endpoint_scenario(base.Scenario):
|
||||
@base.scenario(admin_only=False, operator=False)
|
||||
def glance_endpoint(self, *args, **kwargs):
|
||||
creds = self._get_credentials()
|
||||
keystone = KeystoneHealth(creds)
|
||||
glance = GlanceHealth(keystone)
|
||||
glance = GlanceHealth(creds)
|
||||
return glance.glance_image_list()
|
||||
|
||||
@base.scenario(admin_only=False, operator=False)
|
||||
def cinder_endpoint(self, *args, **kwargs):
|
||||
creds = self._get_nova_v2_credentials()
|
||||
creds = self._get_credentials()
|
||||
cinder = CinderHealth(creds)
|
||||
return cinder.cinder_list()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user