diff --git a/tuskarclient/tests/v1/test_client.py b/tuskarclient/tests/v1/test_client.py index 0c053f4..4575f99 100644 --- a/tuskarclient/tests/v1/test_client.py +++ b/tuskarclient/tests/v1/test_client.py @@ -33,3 +33,7 @@ class ClientTest(tutils.TestCase): self.assertEqual("FlavorManager", self.client.flavors.__class__.__name__) self.assertEqual(self.client, self.client.flavors.api) + + self.assertEqual("DataCenterManager", + self.client.data_centers.__class__.__name__) + self.assertEqual(self.client, self.client.data_centers.api) diff --git a/tuskarclient/tests/v1/test_data_centers.py b/tuskarclient/tests/v1/test_data_centers.py new file mode 100644 index 0000000..098902a --- /dev/null +++ b/tuskarclient/tests/v1/test_data_centers.py @@ -0,0 +1,32 @@ +# 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. + +import mock + +from tuskarclient.v1 import data_centers +import tuskarclient.tests.utils as tutils + + +class DataCenterManagerTest(tutils.TestCase): + + def setUp(self): + super(DataCenterManagerTest, self).setUp() + self.api = mock.Mock() + self.dcm = data_centers.DataCenterManager(self.api) + + def test_provision_all(self): + self.api.json_request = mock.Mock(return_value={'some': 'data'}) + + self.assertEqual({'some': 'data'}, self.dcm.provision_all()) + # FIXME: Tuskar currently requires trailing slash on this URL + self.api.json_request.assert_called_with( + 'POST', '/v1/data_centers/') diff --git a/tuskarclient/v1/client.py b/tuskarclient/v1/client.py index 3255b98..6da7c86 100644 --- a/tuskarclient/v1/client.py +++ b/tuskarclient/v1/client.py @@ -11,6 +11,7 @@ # under the License. from tuskarclient.common import http +from tuskarclient.v1 import data_centers from tuskarclient.v1 import flavors from tuskarclient.v1 import racks from tuskarclient.v1 import resource_classes @@ -29,3 +30,4 @@ class Client(http.HTTPClient): self.racks = racks.RackManager(self) self.resource_classes = resource_classes.ResourceClassManager(self) self.flavors = flavors.FlavorManager(self) + self.data_centers = data_centers.DataCenterManager(self) diff --git a/tuskarclient/v1/data_centers.py b/tuskarclient/v1/data_centers.py new file mode 100644 index 0000000..e9a366f --- /dev/null +++ b/tuskarclient/v1/data_centers.py @@ -0,0 +1,24 @@ +# 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 tuskarclient.common import base + + +class DataCenterManager(base.Manager): + + @staticmethod + def _path(id=None): + return '/v1/data_centers/%s' % id if id else '/v1/data_centers' + + def provision_all(self): + # FIXME: Tuskar currently requires trailing slash on this URL + return self.api.json_request('POST', self._path() + '/')