Add put Plan in YAML

Change-Id: I7dcefb8bfe43d7ffd63833d78d405f24a097d583
Related-Bug: #1309493
This commit is contained in:
Pierre Padrixe
2014-06-17 16:33:52 +02:00
parent 43ef5a0532
commit 9bfa678c1e
2 changed files with 15 additions and 4 deletions

View File

@@ -171,5 +171,6 @@ class PlanManagerTest(base.TestCase):
fake_http_client = fake_client.FakeHTTPClient(fixtures=fixtures_put)
api_client = sclient.Client(fake_http_client)
mgr = plan.PlanManager(api_client)
plan_obj = mgr.update(plan_id='p1', **plan_fixture)
plan_obj = mgr.update('version: 1\nname: ex_plan1\ndescription: dsc1.',
plan_id='p1')
self.assert_plan_obj(plan_obj)

View File

@@ -113,9 +113,19 @@ class PlanManager(solum_base.CrudManager, solum_base.FindMixin):
else:
return super(PlanManager, self).findone(name=name_or_uuid)
def update(self, **kwargs):
return super(PlanManager,
self).update(base_url="/v1", **kwargs)
def update(self, plan, **kwargs):
kwargs = self._filter_kwargs(kwargs)
kwargs['data'] = plan
kwargs.setdefault("headers", kwargs.get("headers", {}))
kwargs['headers']['Content-Type'] = 'x-application/yaml'
resp = self.client.put(self.build_url(base_url="/v1", **kwargs),
**kwargs)
try:
resp_plan = yaml.load(resp.content)
except yaml.YAMLError:
raise exc.BaseException(message='Could not parse response '
'from Plan API resource.')
return self.resource_class(self, resp_plan)
def delete(self, **kwargs):
return super(PlanManager, self).delete(base_url="/v1", **kwargs)