def test_make_resource_cls(self): FooCls = service.make_resource_cls("Foo", properties=["a", "b"]) # check repr self.assertEqual("<Foo id=1>", "%s" % FooCls(a=1)) # check getitem self.assertEqual(1, FooCls(a=1)["a"]) # check used name for a type in error messages e = self.assertRaises(AttributeError, getattr, FooCls(a=1), "c") self.assertEqual("'Foo' object has no attribute 'c'", "%s" % e) # check asserts self.assertEqual(FooCls(a=1), FooCls(a=1)) self.assertEqual(FooCls(a=1), FooCls(a=1, b=3)) self.assertNotEqual(FooCls(a=1), FooCls(a=2))
# 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 rally.task import service Project = service.make_resource_cls("Project", ["id", "name", "domain_id"]) User = service.make_resource_cls( "User", properties=["id", "name", "project_id", "domain_id"]) Service = service.make_resource_cls("Service", properties=["id", "name"]) Role = service.make_resource_cls("Role", properties=["id", "name"]) class Identity(service.UnifiedService): @classmethod def is_applicable(cls, clients): cloud_version = clients.keystone().version.split(".")[0][1:] return cloud_version == cls._meta_get("impl")._meta_get("version") @service.should_be_overridden def create_project(self, project_name=None, domain_name="Default"): """Creates new project/tenant and return project object.
# 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 rally import exceptions from rally.task import service from oslo_config import cfg CONF = cfg.CONF UnifiedImage = service.make_resource_cls( "Image", properties=["id", "name", "visibility", "status"]) class VisibilityException(exceptions.RallyException): """Wrong visibility value exception. """ error_code = 531 class RemovePropsException(exceptions.RallyException): """Remove Props it not supported exception. """ error_code = 560
# # 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 rally.common import cfg from rally import exceptions from rally.task import service CONF = cfg.CONF UnifiedImage = service.make_resource_cls( "Image", properties=["id", "name", "visibility", "status"]) class VisibilityException(exceptions.RallyException): """Wrong visibility value exception. """ error_code = 531 class RemovePropsException(exceptions.RallyException): """Remove Props it not supported exception. """ error_code = 560
# # 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 oslo_config import cfg from rally.task import service CONF = cfg.CONF Volume = service.make_resource_cls( "Volume", properties=["id", "name", "size", "status"]) VolumeSnapshot = service.make_resource_cls( "VolumeSnapshot", properties=["id", "name", "volume_id", "status"]) VolumeBackup = service.make_resource_cls( "VolumeBackup", properties=["id", "name", "volume_id", "status"]) VolumeTransfer = service.make_resource_cls( "VolumeTransfer", properties=["id", "name", "volume_id", "auth_key"]) VolumeEncryptionType = service.make_resource_cls( "VolumeEncryptionType", properties=["id", "volume_type_id"]) QoSSpecs = service.make_resource_cls( "QoSSpecs", properties=["id", "name", "specs"]) class BlockStorage(service.UnifiedService): @service.should_be_overridden
# 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 rally.common import cfg from rally.common import logging from rally.task import service CONF = cfg.CONF LOG = logging.getLogger(__name__) Volume = service.make_resource_cls("Volume", properties=["id", "name", "size", "status"]) VolumeSnapshot = service.make_resource_cls( "VolumeSnapshot", properties=["id", "name", "volume_id", "status"]) VolumeBackup = service.make_resource_cls( "VolumeBackup", properties=["id", "name", "volume_id", "status"]) VolumeTransfer = service.make_resource_cls( "VolumeTransfer", properties=["id", "name", "volume_id", "auth_key"]) VolumeEncryptionType = service.make_resource_cls( "VolumeEncryptionType", properties=["id", "volume_type_id"]) QoSSpecs = service.make_resource_cls("QoSSpecs", properties=["id", "name", "specs"]) class BlockStorage(service.UnifiedService): @service.should_be_overridden def create_volume(self,