Source files: 2
Click here to show/hide file namesSource files:
cinder/volume/drivers/glusterfs.py,
cinder/volume/drivers/nfs.py
Clones detected: 5
150 of 423 lines are duplicates (35.46%)
Parameters
clustering_threshold = 10
distance_threshold = 5
size_threshold = 5
hashing_depth = 1
clusterize_using_hash = False
clusterize_using_dcup = False
Clone # 1
Distance between two fragments = 3
Clone size = 49
Source file "cinder/volume/drivers/glusterfs.py" The first line is 90 | Source file "cinder/volume/drivers/nfs.py" The first line is 236 | |
def create_cloned_volume(self, volume, src_vref): raise NotImplementedError() |
def create_cloned_volume(self, volume, src_vref): raise NotImplementedError() |
|
def create_volume(self, volume): self._ensure_shares_mounted() volume['provider_location'] = self._find_share(volume['size']) LOG.info((_('casted to %s')) % (volume['provider_location'])) self._do_create_volume(volume) return {'provider_location': volume['provider_location']} |
def create_volume(self, volume): self._ensure_shares_mounted() volume['provider_location'] = self._find_share(volume['size']) LOG.info((_('casted to %s')) % (volume['provider_location'])) self._do_create_volume(volume) return {'provider_location': volume['provider_location']} |
|
def delete_volume(self, volume): if not volume['provider_location']: LOG.warn(_('Volume %s does not have provider_location specified, skipping'), volume['name']) return None self._ensure_share_mounted(volume['provider_location']) mounted_path = self.local_path(volume) self._execute('rm', '-f', mounted_path, run_as_root=True) |
def delete_volume(self, volume): if not volume['provider_location']: LOG.warn(_('Volume %s does not have provider_location specified, skipping'), volume['name']) return None self._ensure_share_mounted(volume['provider_location']) mounted_path = self.local_path(volume) self._execute('rm', '-f', mounted_path, run_as_root=True) |
|
def ensure_export(self, ctx, volume): self._ensure_share_mounted(volume['provider_location']) |
def ensure_export(self, ctx, volume): self._ensure_share_mounted(volume['provider_location']) |
|
def create_export(self, ctx, volume): pass |
def create_export(self, ctx, volume): pass |
|
def remove_export(self, ctx, volume): pass |
def remove_export(self, ctx, volume): pass |
|
def initialize_connection(self, volume, connector): data = {'export': volume['provider_location'], 'name': volume['name']} if volume['provider_location'] in self.shares: data['options'] = self.shares[volume['provider_location']] return {'driver_volume_type': 'glusterfs', 'data': data} |
def initialize_connection(self, volume, connector): data = {'export': volume['provider_location'], 'name': volume['name']} if volume['provider_location'] in self.shares: data['options'] = self.shares[volume['provider_location']] return {'driver_volume_type': 'nfs', 'data': data} |
|
def terminate_connection(self, volume, *connector, **kwargs): pass |
def terminate_connection(self, volume, *connector, **kwargs): pass |
|
def _do_create_volume(self, volume): volume_path = self.local_path(volume) volume_size = volume['size'] if self.configuration.glusterfs_sparsed_volumes: self._create_sparsed_file(volume_path, volume_size) else: self._create_regular_file(volume_path, volume_size) self._set_rw_permissions_for_all(volume_path) |
def _do_create_volume(self, volume): volume_path = self.local_path(volume) volume_size = volume['size'] if self.configuration.nfs_sparsed_volumes: self._create_sparsed_file(volume_path, volume_size) else: self._create_regular_file(volume_path, volume_size) self._set_rw_permissions_for_all(volume_path) |
|
def _ensure_shares_mounted(self): self._mounted_shares = [] self._load_shares_config(self.configuration.glusterfs_shares_config) for share in self.shares.keys(): try: self._ensure_share_mounted(share) self._mounted_shares.append(share) except Exception, exc: LOG.warning((_('Exception during mounting %s')) % ((exc))) LOG.debug(('Available shares %s') % (str(self._mounted_shares))) |
def _ensure_shares_mounted(self): self._mounted_shares = [] self._load_shares_config(self.configuration.nfs_shares_config) for share in self.shares.keys(): try: self._ensure_share_mounted(share) self._mounted_shares.append(share) except Exception, exc: LOG.warning((_('Exception during mounting %s')) % ((exc))) LOG.debug(('Available shares %s') % (str(self._mounted_shares))) |
Clone # 2
Distance between two fragments = 2
Clone size = 9
Source file "cinder/volume/drivers/nfs.py" The first line is 451 | Source file "cinder/volume/drivers/glusterfs.py" The first line is 271 | |
data = {} | data = {} | |
backend_name = self.configuration.safe_get('volume_backend_name') | backend_name = self.configuration.safe_get('volume_backend_name') | |
data['volume_backend_name'] = (backend_name) or ('Generic_NFS') | data['volume_backend_name'] = (backend_name) or ('GlusterFS') | |
data['vendor_name'] = 'Open Source' | data['vendor_name'] = 'Open Source' | |
data['driver_version'] = VERSION | data['driver_version'] = VERSION | |
data['storage_protocol'] = 'nfs' | data['storage_protocol'] = 'glusterfs' | |
self._ensure_shares_mounted() | self._ensure_shares_mounted() | |
global_capacity = 0 | global_capacity = 0 | |
global_free = 0 | global_free = 0 |
Clone # 3
Distance between two fragments = 2
Clone size = 6
Source file "cinder/volume/drivers/nfs.py" The first line is 430 | Source file "cinder/volume/drivers/glusterfs.py" The first line is 250 | |
try: self._execute(run_as_root=True, *nfs_cmd) except exception.ProcessExecutionError, exc: if (ensure) and ('already mounted' in exc.stderr): LOG.warn(_('%s is already mounted'), nfs_share) else: raise |
try: self._execute(run_as_root=True, *command) except exception.ProcessExecutionError, exc: if (ensure) and ('already mounted' in exc.stderr): LOG.warn(_('%s is already mounted'), glusterfs_share) else: raise |
Clone # 4
Distance between two fragments = 4
Clone size = 6
Source file "cinder/volume/drivers/glusterfs.py" The first line is 63 | Source file "cinder/volume/drivers/nfs.py" The first line is 201 | |
config = self.configuration.glusterfs_shares_config | config = self.configuration.nfs_shares_config | |
if not config: msg = (_("There's no Gluster config file configured (%s)")) % ('glusterfs_shares_config') LOG.warn(msg) raise exception.GlusterfsException(msg) |
if not config: msg = (_("There's no NFS config file configured (%s)")) % ('nfs_shares_config') LOG.warn(msg) raise exception.NfsException(msg) |
Clone # 5
Distance between two fragments = 2
Clone size = 5
Source file "cinder/volume/drivers/glusterfs.py" The first line is 69 | Source file "cinder/volume/drivers/nfs.py" The first line is 207 | |
if not os.path.exists(config): msg = (_("Gluster config file at %(config)s doesn't exist")) % ({'config': config}) LOG.warn(msg) raise exception.GlusterfsException(msg) |
if not os.path.exists(config): msg = (_("NFS config file at %(config)s doesn't exist")) % ({'config': config}) LOG.warn(msg) raise exception.NfsException(msg) |