def __init__(self, context=None, admin_clients=None, clients=None): super(CinderBasic, self).__init__(context, admin_clients, clients) if hasattr(self, "_admin_clients"): self.admin_cinder = block.BlockStorage( self._admin_clients, name_generator=self.generate_random_name, atomic_inst=self.atomic_actions()) if hasattr(self, "_clients"): self.cinder = block.BlockStorage( self._clients, name_generator=self.generate_random_name, atomic_inst=self.atomic_actions())
def _get_service_with_fake_impl(self): path = "rally.plugins.openstack.services.storage.block" path = "%s.BlockStorage.discover_impl" % path with mock.patch(path) as mock_discover: mock_discover.return_value = mock.MagicMock(), None service = block.BlockStorage(self.clients) return service
def cleanup(self): admin_clients = osclients.Clients( self.context.get("admin", {}).get("credential"), api_info=self.context["config"].get("api_versions")) cinder_service = block.BlockStorage(admin_clients) for vtype in self.context["volume_types"]: LOG.debug("Deleting Cinder volume type %s" % vtype["name"]) cinder_service.delete_volume_type(vtype["id"])
def pre_process(self, resource_spec, config): resource_id = resource_spec.get("id") if not resource_id: cinder = block.BlockStorage(self._clients) resource_id = types._id_from_name(resource_config=resource_spec, resources=cinder.list_types(), typename="volume_type") return resource_id
def setup(self): admin_clients = osclients.Clients( self.context.get("admin", {}).get("credential"), api_info=self.context["config"].get("api_versions")) cinder_service = block.BlockStorage( admin_clients, name_generator=self.generate_random_name) self.context["volume_types"] = [] for vtype_name in self.config: LOG.debug("Creating Cinder volume type %s" % vtype_name) vtype = cinder_service.create_volume_type(vtype_name) self.context["volume_types"].append({"id": vtype.id, "name": vtype_name})
def setup(self): size = self.config["size"] volume_type = self.config.get("type", None) volumes_per_tenant = self.config["volumes_per_tenant"] for user, tenant_id in rutils.iterate_per_tenants( self.context["users"]): self.context["tenants"][tenant_id].setdefault("volumes", []) clients = osclients.Clients( user["credential"], api_info=self.context["config"].get("api_versions")) cinder_service = block.BlockStorage( clients, name_generator=self.generate_random_name) for i in range(volumes_per_tenant): vol = cinder_service.create_volume(size, volume_type=volume_type) self.context["tenants"][tenant_id]["volumes"].append( vol._as_dict())