def exportgroup_remove_volumes_by_uri( self, exportgroup_uri, volumeIdList, sync=False, tenantname=None, projectname=None, snapshots=None, cg=None ): # if snapshot given then snapshot added to exportgroup volume_snapshots = volumeIdList if snapshots: resuri = None if cg: blockTypeName = "consistency-groups" from consistencygroup import ConsistencyGroup cgObject = ConsistencyGroup(self.__ipAddr, self.__port) resuri = cgObject.consistencygroup_query(cg, projectname, tenantname) else: blockTypeName = "volumes" if len(volumeIdList) > 0: resuri = volumeIdList[0] volume_snapshots = [] snapshotObject = Snapshot(self.__ipAddr, self.__port) for snapshot in snapshots: volume_snapshots.append(snapshotObject.snapshot_query("block", blockTypeName, resuri, snapshot)) parms = {} parms["volume_changes"] = self._remove_list(volume_snapshots) o = self.send_json_request(exportgroup_uri, parms) return self.check_for_sync(o, sync) # initator """
def exportgroup_add_volumes( self, sync, exportgroupname, tenantname, projectname, volumenames, snapshots=None, cg=None ): exportgroup_uri = self.exportgroup_query(exportgroupname, projectname, tenantname) # get volume uri if tenantname is None: tenantname = "" # List of volumes. # incase of snapshots from volume, this will hold the source volume # URI. volume_snapshots = [] if volumenames: volume_snapshots = self._get_resource_lun_tuple(volumenames, "volumes", None, tenantname, projectname, None) # if snapshot given then snapshot added to exportgroup if snapshots and len(snapshots) > 0: resuri = None if cg: blockTypeName = "consistency-groups" from consistencygroup import ConsistencyGroup cgObject = ConsistencyGroup(self.__ipAddr, self.__port) resuri = cgObject.consistencygroup_query(cg, projectname, tenantname) else: blockTypeName = "volumes" if len(volume_snapshots) > 0: resuri = volume_snapshots[0]["id"] volume_snapshots = self._get_resource_lun_tuple( snapshots, "snapshots", resuri, tenantname, projectname, blockTypeName ) parms = {} # construct the body volChanges = {} volChanges["add"] = volume_snapshots parms["volume_changes"] = volChanges o = self.send_json_request(exportgroup_uri, parms) return self.check_for_sync(o, sync)