def _get_flexvol_to_pool_map(self): """Get the flexvols that back all mounted shares. The map is of the format suitable for seeding the storage service catalog: {<flexvol_name> : {'pool_name': <share_path>}} """ pools = {} vserver_addresses = self.zapi_client.get_operational_lif_addresses() for share in self._mounted_shares: host, junction_path = na_utils.get_export_host_junction_path(share) address = volume_utils.resolve_hostname(host) if address not in vserver_addresses: LOG.warning('Address not found for NFS share %s.', share) continue try: flexvol = self.zapi_client.get_flexvol( flexvol_path=junction_path) pools[flexvol['name']] = {'pool_name': share} except exception.VolumeBackendAPIException: LOG.exception('Flexvol not found for NFS share %s.', share) return pools
def _get_destination_ip_and_path(self, volume): share = volume_utils.extract_host(volume['host'], level='pool') share_ip, share_path = na_utils.get_export_host_junction_path(share) dest_ip = self._get_ip_verify_on_cluster(share_ip) dest_path = os.path.join(share_path, volume['name']) return dest_ip, dest_path
def _get_export_ip_path(self, volume_id=None, share=None): """Returns export ip and path. One of volume id or share is used to return the values. """ if volume_id: provider_location = self._get_provider_location(volume_id) host_ip, export_path = na_utils.get_export_host_junction_path( provider_location) elif share: host_ip, export_path = na_utils.get_export_host_junction_path( share) else: raise exception.InvalidInput( 'A volume ID or share was not specified.') return host_ip, export_path
def _get_export_ip_path(self, volume_id=None, share=None): """Returns export ip and path. One of volume id or share is used to return the values. """ if volume_id: provider_location = self._get_provider_location(volume_id) host_ip, export_path = na_utils.get_export_host_junction_path( provider_location) elif share: host_ip, export_path = na_utils.get_export_host_junction_path( share) else: raise exception.InvalidInput( 'A volume ID or share was not specified.') return host_ip, export_path
def _get_volume_location(self, volume_id): """Returns NFS mount address as <nfs_ip_address>:<nfs_mount_dir>.""" provider_location = self._get_provider_location(volume_id) nfs_server_ip, export_path = na_utils.get_export_host_junction_path( provider_location) if netutils.is_valid_ipv6(nfs_server_ip): nfs_server_ip = netutils.escape_ipv6(nfs_server_ip) return nfs_server_ip + ':' + export_path
def _get_volume_location(self, volume_id): """Returns NFS mount address as <nfs_ip_address>:<nfs_mount_dir>.""" provider_location = self._get_provider_location(volume_id) nfs_server_ip, export_path = na_utils.get_export_host_junction_path( provider_location) if netutils.is_valid_ipv6(nfs_server_ip): nfs_server_ip = netutils.escape_ipv6(nfs_server_ip) return nfs_server_ip + ':' + export_path
def _set_qos_policy_group_on_volume(self, volume, qos_policy_group_info): if qos_policy_group_info is None: return qos_policy_group_name = na_utils.get_qos_policy_group_name_from_info( qos_policy_group_info) if qos_policy_group_name is None: return target_path = '%s' % (volume['name']) share = volume_utils.extract_host(volume['host'], level='pool') __, export_path = na_utils.get_export_host_junction_path(share) flex_vol_name = self.zapi_client.get_vol_by_junc_vserver( self.vserver, export_path) self.zapi_client.file_assign_qos(flex_vol_name, qos_policy_group_name, target_path)
def _share_match_for_ip(self, ip, shares): """Returns the share that is served by ip. Multiple shares can have same dir path but can be served using different ips. It finds the share which is served by ip on same nfs server. """ ip_vserver = self._get_vserver_for_ip(ip) if ip_vserver and shares: for share in shares: ip_sh, __ = na_utils.get_export_host_junction_path(share) sh_vserver = self._get_vserver_for_ip(ip_sh) if sh_vserver == ip_vserver: LOG.debug('Share match found for ip %s', ip) return share LOG.debug('No share match found for ip %s', ip) return None
def _get_source_ip_and_path(self, nfs_share, file_name): host, share_path = na_utils.get_export_host_junction_path(nfs_share) src_ip = self._get_ip_verify_on_cluster(host) src_path = os.path.join(share_path, file_name) return src_ip, src_path
def test_get_export_host_junction_path(self, share, host, junction_path): result_host, result_path = na_utils.get_export_host_junction_path( share) self.assertEqual(host, result_host) self.assertEqual(junction_path, result_path)
def test_get_export_host_junction_path(self, share, host, junction_path): result_host, result_path = na_utils.get_export_host_junction_path( share) self.assertEqual(host, result_host) self.assertEqual(junction_path, result_path)