Beispiel #1
0
 def _is_device_mounted(self, mount_path, server_details, volume=None):
     """Checks whether volume already mounted or not."""
     log_data = {
         'mount_path': mount_path,
         'server_id': server_details['instance_id'],
     }
     if volume and volume.get('mountpoint', ''):
         log_data['volume_id'] = volume['id']
         log_data['dev_mount_path'] = volume['mountpoint']
         msg = ("Checking whether volume '%(volume_id)s' with mountpoint "
                "'%(dev_mount_path)s' is mounted on mount path '%(mount_p"
                "ath)s' on server '%(server_id)s' or not." % log_data)
     else:
         msg = ("Checking whether mount path '%(mount_path)s' exists on "
                "server '%(server_id)s' or not." % log_data)
     LOG.debug(msg)
     mounts_list_cmd = ['sudo', 'mount']
     output, __ = self._ssh_exec(server_details, mounts_list_cmd)
     mounts = output.split('\n')
     for mount in mounts:
         mount_elements = mount.split(' ')
         if (len(mount_elements) > 2 and mount_path == mount_elements[2]):
             if volume:
                 # Mount goes with device path and mount path
                 if (volume.get('mountpoint', '') == mount_elements[0]):
                     return True
             else:
                 # Unmount goes only by mount path
                 return True
     return False
Beispiel #2
0
 def _is_device_mounted(self, mount_path, server_details, volume=None):
     """Checks whether volume already mounted or not."""
     log_data = {
         'mount_path': mount_path,
         'server_id': server_details['instance_id'],
     }
     if volume and volume.get('mountpoint', ''):
         log_data['volume_id'] = volume['id']
         log_data['dev_mount_path'] = volume['mountpoint']
         msg = ("Checking whether volume '%(volume_id)s' with mountpoint "
                "'%(dev_mount_path)s' is mounted on mount path '%(mount_p"
                "ath)s' on server '%(server_id)s' or not." % log_data)
     else:
         msg = ("Checking whether mount path '%(mount_path)s' exists on "
                "server '%(server_id)s' or not." % log_data)
     LOG.debug(msg)
     mounts_list_cmd = ['sudo', 'mount']
     output, __ = self._ssh_exec(server_details, mounts_list_cmd)
     mounts = output.split('\n')
     for mount in mounts:
         mount_elements = mount.split(' ')
         if (len(mount_elements) > 2 and mount_path == mount_elements[2]):
             if volume:
                 # Mount goes with device path and mount path
                 if (volume.get('mountpoint', '') == mount_elements[0]):
                     return True
             else:
                 # Unmount goes only by mount path
                 return True
     return False