Enhancements in nova support
This patch add the discover of nova following options: * compute-feature-enabled.attach_encrypted_volume Also add the defaults to the following to true: * compute-feature-enabled.console_output * compute-feature-enabled.resize Change-Id: I96f140de50d5cfaeaab06e1e4d15e427c50b215b
This commit is contained in:
parent
29d6500ce5
commit
9be036cf1f
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
from tempest.lib import exceptions
|
from tempest.lib import exceptions
|
||||||
from tempest.lib.services.compute import flavors_client
|
from tempest.lib.services.compute import flavors_client
|
||||||
|
from tempest.lib.services.compute import hosts_client
|
||||||
from tempest.lib.services.compute import networks_client as nova_net_client
|
from tempest.lib.services.compute import networks_client as nova_net_client
|
||||||
from tempest.lib.services.compute import servers_client
|
from tempest.lib.services.compute import servers_client
|
||||||
from tempest.lib.services.identity.v2 import identity_client
|
from tempest.lib.services.identity.v2 import identity_client
|
||||||
@ -107,6 +108,12 @@ class ClientManager(object):
|
|||||||
endpoint_type='publicURL',
|
endpoint_type='publicURL',
|
||||||
default_params=default_params)
|
default_params=default_params)
|
||||||
|
|
||||||
|
self.hosts_client = hosts_client.HostsClient(
|
||||||
|
self.auth_provider,
|
||||||
|
conf.get_defaulted('compute', 'catalog_type'),
|
||||||
|
self.identity_region,
|
||||||
|
**default_params)
|
||||||
|
|
||||||
self.set_users_client(
|
self.set_users_client(
|
||||||
auth=self.auth_provider,
|
auth=self.auth_provider,
|
||||||
identity_version=creds.identity_version,
|
identity_version=creds.identity_version,
|
||||||
@ -208,6 +215,11 @@ class ClientManager(object):
|
|||||||
:type service_name: string
|
:type service_name: string
|
||||||
:rtype: client object or None when the client doesn't exist
|
:rtype: client object or None when the client doesn't exist
|
||||||
"""
|
"""
|
||||||
|
# TODO(arxcruz): This function is under used, it should return
|
||||||
|
# a dictionary of all services for a particular client, for
|
||||||
|
# example, we need hosts_client and flavors_client for compute
|
||||||
|
# should return {'hosts': self.hosts_client, 'flavors': self.flavors }
|
||||||
|
# and so on.
|
||||||
if service_name == "image":
|
if service_name == "image":
|
||||||
return self.images
|
return self.images
|
||||||
elif service_name == "network":
|
elif service_name == "network":
|
||||||
@ -215,6 +227,8 @@ class ClientManager(object):
|
|||||||
# currently needs to have an access to get_neutron/nova_client
|
# currently needs to have an access to get_neutron/nova_client
|
||||||
# methods which are chosen according to neutron presence
|
# methods which are chosen according to neutron presence
|
||||||
return self
|
return self
|
||||||
|
elif service_name == "compute":
|
||||||
|
return self.hosts_client
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -75,6 +75,9 @@ class Service(object):
|
|||||||
def get_versions(self):
|
def get_versions(self):
|
||||||
return self.versions
|
return self.versions
|
||||||
|
|
||||||
|
def set_default_tempest_options(self, conf):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class VersionedService(Service):
|
class VersionedService(Service):
|
||||||
def set_versions(self, top_level=True):
|
def set_versions(self, top_level=True):
|
||||||
|
@ -14,7 +14,9 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from base import VersionedService
|
from base import VersionedService
|
||||||
|
import config_tempest.constants as C
|
||||||
import json
|
import json
|
||||||
|
from tempest.lib import exceptions
|
||||||
|
|
||||||
|
|
||||||
class ComputeService(VersionedService):
|
class ComputeService(VersionedService):
|
||||||
@ -28,3 +30,24 @@ class ComputeService(VersionedService):
|
|||||||
body = self.do_get(url, top_level=top_level)
|
body = self.do_get(url, top_level=top_level)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
self.versions = self.deserialize_versions(body)
|
self.versions = self.deserialize_versions(body)
|
||||||
|
|
||||||
|
def set_default_tempest_options(self, conf):
|
||||||
|
conf.set('compute-feature-enabled', 'console_output', 'True')
|
||||||
|
# Resize only works if it has at least 2 compute nodes
|
||||||
|
# or if nova has the option allow_resize_to_same_host
|
||||||
|
# set to true. Unfortunately we can't get this info from
|
||||||
|
# nova api, so we only set it when we know there's 2
|
||||||
|
# compute nodes
|
||||||
|
if self._get_number_of_hosts() >= 2:
|
||||||
|
conf.set('compute-feature-enabled', 'resize', 'True')
|
||||||
|
|
||||||
|
def _get_number_of_hosts(self):
|
||||||
|
# Right now the client returned is hosts, in the future
|
||||||
|
# change it to a dict, and get the client as requested
|
||||||
|
try:
|
||||||
|
hosts = self.client.list_hosts()['hosts']
|
||||||
|
compute_hosts = [h for h in hosts if h['service'] == 'compute']
|
||||||
|
return len(compute_hosts)
|
||||||
|
except exceptions.Forbidden:
|
||||||
|
C.LOG.info('Can not retrieve hosts, user are not allowed')
|
||||||
|
return 1
|
||||||
|
@ -65,6 +65,9 @@ class Services(object):
|
|||||||
# discover versions of the service
|
# discover versions of the service
|
||||||
service.set_versions()
|
service.set_versions()
|
||||||
|
|
||||||
|
# default tempest options
|
||||||
|
service.set_default_tempest_options(self._conf)
|
||||||
|
|
||||||
self._services.append(service)
|
self._services.append(service)
|
||||||
|
|
||||||
service_name = 'volume'
|
service_name = 'volume'
|
||||||
@ -210,6 +213,13 @@ class Services(object):
|
|||||||
self._conf.set('service_available', 'aodh', 'True')
|
self._conf.set('service_available', 'aodh', 'True')
|
||||||
self._conf.set('service_available', 'aodh_plugin', 'True')
|
self._conf.set('service_available', 'aodh_plugin', 'True')
|
||||||
|
|
||||||
|
# TODO(arxcruz): This should be set in compute service, not here,
|
||||||
|
# however, it requires a refactor in the code, which is not our
|
||||||
|
# goal right now
|
||||||
|
self._conf.set('compute-feature-enabled',
|
||||||
|
'attach_encrypted_volume',
|
||||||
|
str(self.is_service('key-manager')))
|
||||||
|
|
||||||
def set_supported_api_versions(self):
|
def set_supported_api_versions(self):
|
||||||
# set supported API versions for services with more of them
|
# set supported API versions for services with more of them
|
||||||
for service, service_info in C.SERVICE_VERSIONS.iteritems():
|
for service, service_info in C.SERVICE_VERSIONS.iteritems():
|
||||||
|
@ -13,7 +13,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from config_tempest.services.compute import ComputeService
|
from config_tempest.services.compute import ComputeService
|
||||||
|
from config_tempest.tempest_conf import TempestConf
|
||||||
from config_tempest.tests.base import BaseServiceTest
|
from config_tempest.tests.base import BaseServiceTest
|
||||||
|
|
||||||
|
|
||||||
@ -32,3 +35,17 @@ class TestComputeService(BaseServiceTest):
|
|||||||
def test_set_get_versions(self):
|
def test_set_get_versions(self):
|
||||||
exp_resp = ['v2.0', 'v2.1']
|
exp_resp = ['v2.0', 'v2.1']
|
||||||
self._set_get_versions(self.Service, exp_resp, self.FAKE_VERSIONS)
|
self._set_get_versions(self.Service, exp_resp, self.FAKE_VERSIONS)
|
||||||
|
|
||||||
|
@mock.patch('config_tempest.services.compute'
|
||||||
|
'.ComputeService._get_number_of_hosts')
|
||||||
|
def test_set_default_tempest_options(self, mock_get_number_of_hosts):
|
||||||
|
mock_get_number_of_hosts.return_value = 2
|
||||||
|
conf = TempestConf()
|
||||||
|
self.Service.set_default_tempest_options(conf)
|
||||||
|
self.assertEqual(
|
||||||
|
conf.get('compute-feature-enabled',
|
||||||
|
'resize'), 'True')
|
||||||
|
self.assertEqual(
|
||||||
|
conf.get('compute-feature-enabled',
|
||||||
|
'console_output'), 'True')
|
||||||
|
mock_get_number_of_hosts.assert_called_once()
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
prelude: >
|
||||||
|
Improve nova discovery settings
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Discover when there is more than one compute node and set the resize
|
||||||
|
option according, when the tool is executed with admin credentials.
|
||||||
|
Set by default the console_output to true.
|
Loading…
Reference in New Issue
Block a user