예제 #1
0
    def detach(self, client, volume_id):
        # TODO(e0ne): multipath support
        conn_prop = connector.get_connector_properties(utils.get_root_helper(),
                                                       utils.get_my_ip(),
                                                       multipath=False,
                                                       enforce_multipath=False)
        connection = client.volumes.initialize_connection(volume_id, conn_prop)
        nfs_mount_point_base = connection.get('mount_point_base')
        brick_connector = self._brick_get_connector(
            connection['driver_volume_type'],
            nfs_mount_point_base=nfs_mount_point_base)

        # TODO(e0ne): use real device info from params
        device_info = {}
        brick_connector.disconnect_volume(connection['data'], device_info)
        protocol = connection['driver_volume_type']
        protocol = protocol.upper()
        if protocol == 'RBD':
            # TODO(e0ne): move to detach_rbd_volume() function
            # TODO(e0ne): multipath support
            pool, volume = connection['data']['name'].split('/')
            dev_name = '/dev/rbd/{pool}/{volume}'.format(pool=pool,
                                                         volume=volume)
            cmd = ['rbd', 'unmap', dev_name]
            processutils.execute(*cmd,
                                 root_helper=utils.get_root_helper(),
                                 run_as_root=True)
        elif protocol == 'NFS':
            nfs_share = connection['data']['export']
            cmd = ['umount', nfs_share]
            processutils.execute(*cmd, root_helper=utils.get_root_helper(),
                                 run_as_root=True)
        client.volumes.terminate_connection(volume_id, conn_prop)
        client.volumes.detach(volume_id)
예제 #2
0
 def get_connector(self):
     # TODO(e0ne): multipath support
     conn_prop = connector.get_connector_properties(utils.get_root_helper(),
                                                    utils.get_my_ip(),
                                                    multipath=False,
                                                    enforce_multipath=False)
     return conn_prop
예제 #3
0
    def attach(self, client, volume_id, hostname):
        # TODO(e0ne): multipath support
        conn_prop = connector.get_connector_properties(utils.get_root_helper(),
                                                       utils.get_my_ip(),
                                                       multipath=False,
                                                       enforce_multipath=False)
        connection = client.volumes.initialize_connection(volume_id, conn_prop)

        protocol = connection['driver_volume_type']
        protocol = protocol.upper()
        nfs_mount_point_base = connection.get('mount_point_base')
        brick_connector = self._brick_get_connector(
            protocol, nfs_mount_point_base=nfs_mount_point_base)

        device_info = brick_connector.connect_volume(connection['data'])
        if protocol == 'RBD':
            # TODO(e0ne): move to attach_rbd_volume() function
            # TODO(e0ne): multipath support
            pool, volume = connection['data']['name'].split('/')
            cmd = ['rbd', 'map', volume, '--pool', pool]
            processutils.execute(*cmd, root_helper=utils.get_root_helper(),
                                 run_as_root=True)
        client.volumes.attach(volume_id, None, None, host_name=hostname)
        return device_info