Changes in client to work with deployment logs fetching.

Change-Id: Ieb2e189af7b47deef7a1b83bf98a0ebfefe738c9
This commit is contained in:
Alexander Tivelkov 2013-07-15 19:30:02 +04:00
parent 4bca32840e
commit e9264019d3
2 changed files with 53 additions and 1 deletions

View File

@ -13,7 +13,7 @@
# under the License.
from muranoclient.common import http
from muranoclient.v1 import environments, sessions, services
from muranoclient.v1 import environments, sessions, services, deployments
class Client(http.HTTPClient):
@ -31,3 +31,4 @@ class Client(http.HTTPClient):
self.environments = environments.EnvironmentManager(self)
self.sessions = sessions.SessionManager(self)
self.services = services.ServiceManager(self)
self.deployments = deployments.DeploymentManager(self)

View File

@ -0,0 +1,51 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# 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.
from muranoclient.common import base
class Deployment(base.Resource):
def __repr__(self):
return '<Deployment %s>' % self._info
def data(self, **kwargs):
return self.manager.data(self, **kwargs)
class Status(base.Resource):
def __repr__(self):
return '<Status %s>' % self._info
def data(self, **kwargs):
return self.manager.data(self, **kwargs)
class DeploymentManager(base.Manager):
resource_class = Deployment
def list(self, environment_id):
return self._get('environments/{id}/deployments'.
format(id=environment_id))
def reports(self, environment_id, deployment_id, *service_ids):
path = 'environments/{id}/deployments/{deployment_id}'
path = path.format(id=environment_id, deployment_id=deployment_id)
if service_ids:
for service_id in service_ids:
path += '?service_id={0}'.format(service_id)
resp, body = self.api.json_request('GET', path)
data = body.get('reports', [])
return [Status(self, res, loaded=True) for res in data if res]