Merge "Provide method for calling action in an environment"

This commit is contained in:
Jenkins 2014-09-09 12:00:17 +00:00 committed by Gerrit Code Review
commit 7f67b27f73
3 changed files with 40 additions and 0 deletions

View File

@ -18,6 +18,7 @@ import mock
import testtools
from muranoclient import client
from muranoclient.v1 import actions
import muranoclient.v1.environments as environments
import muranoclient.v1.sessions as sessions
@ -192,3 +193,10 @@ class UnitTestsForClassesAndFunctions(testtools.TestCase):
manager = sessions.SessionManager(api)
self.assertRaises(TypeError, manager.deploy)
def test_action_manager_call(self):
manager = actions.ActionManager(api)
result = manager.call('testEnvId', 'testActionId', ['arg1', 'arg2'])
self.assertEqual(('POST',
'/v1/environments/testEnvId/actions/testActionId'),
result)

View File

@ -0,0 +1,30 @@
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class ActionManager(object):
"""Not a true manager yet; should be changed to be one if CRUD
functionality becomes available for actions.
"""
def __init__(self, api):
self.api = api
def call(self, environment_id, action_id, arguments=None):
if arguments is None:
arguments = {}
url = '/v1/environments/{environment_id}/actions/{action_id}'.format(
environment_id=environment_id, action_id=action_id)
resp, arguments = self.api.json_request('POST', url, body=arguments)
return resp

View File

@ -13,6 +13,7 @@
# under the License.
from muranoclient.common import http
from muranoclient.v1 import actions
from muranoclient.v1 import deployments
from muranoclient.v1 import environments
from muranoclient.v1 import instance_statistics
@ -43,3 +44,4 @@ class Client(http.HTTPClient):
self.instance_statistics = \
instance_statistics.InstanceStatisticsManager(self)
self.packages = packages.PackageManager(self)
self.actions = actions.ActionManager(self)