Add wait functions to orchestration proxy

Senlin uses wait_for_status and wait_for_delete that were previously
provided in openstack.proxy.Proxy. This adds the functions removed from
openstack.proxy.Proxy to the orchestration proxy.

This change also reenables the orchestration functional test.

Change-Id: I70b478669951237bc290c66d4ae160ec21c655ac
This commit is contained in:
Duc Truong 2018-11-05 16:49:24 -08:00 committed by Monty Taylor
parent 46ca87b8e8
commit 92eb2edd76
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
2 changed files with 48 additions and 4 deletions

View File

@ -20,6 +20,7 @@ from openstack.orchestration.v1 import stack_files as _stack_files
from openstack.orchestration.v1 import stack_template as _stack_template
from openstack.orchestration.v1 import template as _template
from openstack import proxy
from openstack import resource
class Proxy(proxy.Proxy):
@ -360,3 +361,44 @@ class Proxy(proxy.Proxy):
return tmpl.validate(self, template, environment=environment,
template_url=template_url,
ignore_errors=ignore_errors)
def wait_for_status(self, res, status='ACTIVE', failures=None,
interval=2, wait=120):
"""Wait for a resource to be in a particular status.
:param res: The resource to wait on to reach the specified status.
The resource must have a ``status`` attribute.
:type resource: A :class:`~openstack.resource.Resource` object.
:param status: Desired status.
:param failures: Statuses that would be interpreted as failures.
:type failures: :py:class:`list`
:param interval: Number of seconds to wait before to consecutive
checks. Default to 2.
:param wait: Maximum number of seconds to wait before the change.
Default to 120.
:returns: The resource is returned on success.
:raises: :class:`~openstack.exceptions.ResourceTimeout` if transition
to the desired status failed to occur in specified seconds.
:raises: :class:`~openstack.exceptions.ResourceFailure` if the resource
has transited to one of the failure statuses.
:raises: :class:`~AttributeError` if the resource does not have a
``status`` attribute.
"""
failures = [] if failures is None else failures
return resource.wait_for_status(
self, res, status, failures, interval, wait)
def wait_for_delete(self, res, interval=2, wait=120):
"""Wait for a resource to be deleted.
:param res: The resource to wait on to be deleted.
:type resource: A :class:`~openstack.resource.Resource` object.
:param interval: Number of seconds to wait before to consecutive
checks. Default to 2.
:param wait: Maximum number of seconds to wait before the change.
Default to 120.
:returns: The resource is returned on success.
:raises: :class:`~openstack.exceptions.ResourceTimeout` if transition
to delete failed to occur in the specified seconds.
"""
return resource.wait_for_delete(self, res, interval, wait)

View File

@ -10,6 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import yaml
from openstack import exceptions
from openstack.orchestration.v1 import stack
from openstack.tests.functional import base
@ -26,9 +28,6 @@ class TestStack(base.BaseFunctionalTest):
def setUp(self):
super(TestStack, self).setUp()
self.skipTest(
'Orchestration functional tests disabled:'
' https://storyboard.openstack.org/#!/story/1525005')
self.require_service('orchestration')
if self.conn.compute.find_keypair(self.NAME) is None:
@ -36,7 +35,10 @@ class TestStack(base.BaseFunctionalTest):
image = next(self.conn.image.images())
tname = "openstack/tests/functional/orchestration/v1/hello_world.yaml"
with open(tname) as f:
template = f.read()
template = yaml.safe_load(f)
# TODO(mordred) Fix the need for this. We have better support in
# the shade layer.
template['heat_template_version'] = '2013-05-23'
self.network, self.subnet = test_network.create_network(
self.conn,
self.NAME,