def create_share(self, context, share, share_server=None): """Create a share and export it based on protocol used.""" size = share["size"] * units.Gi share_name = self._make_share_name(share) if share["share_proto"] == "NFS": flashblade_fs = purity_fb.FileSystem( name=share_name, provisioned=size, hard_limit_enabled=True, fast_remove_directory_enabled=True, snapshot_directory_enabled=True, nfs=purity_fb.NfsRule(v3_enabled=True, rules="", v4_1_enabled=True), ) self._sys.file_systems.create_file_systems(flashblade_fs) location = self._get_full_nfs_export_path(share_name) else: message = _("Unsupported share protocol: %(proto)s.") % { "proto": share["share_proto"] } LOG.exception(message) raise exception.InvalidShare(reason=message) LOG.info("FlashBlade created share %(name)s", {"name": share_name}) return location
def _update_nfs_access(self, share, access_rules): dataset_name = self._make_share_name(share) self._get_flashblade_filesystem_by_name(dataset_name) nfs_rules = "" rule_state = {} for access in access_rules: if access["access_type"] == "ip": line = (access["access_to"] + "(" + access["access_level"] + ",no_root_squash) ") rule_state[access["access_id"]] = {"state": "active"} nfs_rules += line else: message = _( 'Only "ip" access type is allowed for NFS protocol.') LOG.error(message) rule_state[access["access_id"]] = {"state": "error"} try: self._sys.file_systems.update_file_systems( name=dataset_name, attributes=purity_fb.FileSystem(nfs=purity_fb.NfsRule( rules=nfs_rules)), ) message = "Set nfs rules %(nfs_rules)s for %(share_name)s" LOG.debug(message, { "nfs_rules": nfs_rules, "share_name": dataset_name }) except purity_fb.rest.ApiException as ex: msg = _("Failed to set NFS access rules: %s\n") % ex LOG.exception(msg) raise exception.ManilaException(message=msg) return rule_state
def delete_share(self, context, share, share_server=None): """Called to delete a share""" dataset_name = self._make_share_name(share) try: self._get_flashblade_filesystem_by_name(dataset_name) except purity_fb.rest.ApiException: message = ("share %(dataset_name)s not found on FlashBlade, skip " "delete") LOG.warning(message, {"dataset_name": dataset_name}) return self._sys.file_systems.update_file_systems( name=dataset_name, attributes=purity_fb.FileSystem( nfs=purity_fb.NfsRule(v3_enabled=False, v4_1_enabled=False), smb=purity_fb.ProtocolRule(enabled=False), destroyed=True, ), ) if self.configuration.flashblade_eradicate: self._sys.file_systems.delete_file_systems(name=dataset_name) LOG.info("FlashBlade eradicated share %(name)s", {"name": dataset_name})