Esempio n. 1
0
def delete_backend_volume_eqlx(volume_id):
    # get provider_location
    sql_get_provider_location = 'SELECT provider_location FROM volumes WHERE id =\'%s\';' % volume_id
    provider_location = str(db_connect(sql_get_provider_location)).split()[1]
    # ssh to controller and compute node to delete the iscsi connection
    LOG.info('   Deleting iscsi connection ...')
    controller_list = get_node_list('controller')
    compute_list = get_node_list('compute')
    node_list = controller_list + compute_list
    for node in node_list:
        cmd_show = 'iscsiadm -m session -o show'
        (out, err) = ssh_connect(node, cmd_show)
        if out.find(provider_location) > 0:
            cmd_delete = 'iscsiadm -m node -u -T %s' % provider_location
            (o, e) = ssh_connect(node, cmd_delete)
            if o.find('successful') < 0:
                LOG.error(
                    '   Can not delete the iscsi connection "%s" at host %s.' %
                    (provider_location, node))
    # ssh to eqlx to delete the volume
    LOG.info('   Deleting backend(eqlx) volume ...')
    ## set eqlx volume status to offline
    cmd_set_eqlx_volume_offline = 'volume select volume-%s offline' % volume_id
    out = eqlx_ssh_execute(cmd_set_eqlx_volume_offline)
    if len(out) == 3:
        LOG.error('   ' + out[1])
        return False
    ## delete the eqlx volume
    cmd_delete_eqlx_volume = 'volume delete volume-%s' % volume_id
    result = eqlx_ssh_execute(cmd_delete_eqlx_volume)
    if not result or result[1] != 'Volume deletion succeeded.':
        LOG.error('   Delete backend volume faild !')
        return False
    else:
        return True
Esempio n. 2
0
def delete_backend_volume_eqlx(volume_id):
    # get provider_location
    sql_get_provider_location = 'SELECT provider_location FROM volumes WHERE id =\'%s\';' % volume_id
    provider_location = str(db_connect(sql_get_provider_location)).split()[1]
    # ssh to controller and compute node to delete the iscsi connection
    LOG.info('   Deleting iscsi connection ...')
    controller_list = get_node_list('controller')
    compute_list = get_node_list('compute')
    node_list = controller_list + compute_list
    for node in node_list:
        cmd_show = 'iscsiadm -m session -o show'
        (out, err) = ssh_connect(node, cmd_show)
        if out.find(provider_location) > 0:
            cmd_delete = 'iscsiadm -m node -u -T %s' % provider_location
            (o, e) = ssh_connect(node, cmd_delete)
            if o.find('successful') < 0:
                LOG.error('   Can not delete the iscsi connection "%s" at host %s.' % (provider_location, node))
    # ssh to eqlx to delete the volume
    LOG.info('   Deleting backend(eqlx) volume ...')
    ## set eqlx volume status to offline
    cmd_set_eqlx_volume_offline = 'volume select volume-%s offline' % volume_id
    out = eqlx_ssh_execute(cmd_set_eqlx_volume_offline)
    if len(out) == 3:
        LOG.error('   ' + out[1])
        return False
    ## delete the eqlx volume
    cmd_delete_eqlx_volume = 'volume delete volume-%s' % volume_id
    result = eqlx_ssh_execute(cmd_delete_eqlx_volume)
    if not result or result[1] != 'Volume deletion succeeded.':
        LOG.error('   Delete backend volume faild !')
        return False
    else:
        return True
Esempio n. 3
0
def delete_backend_snapshots_eqlx(snapshots_id, volume_id):
    LOG.info('   Deleting backend(eqlx) snapshots ...')
    for snapshot_id in snapshots_id:
        LOG.info('   [%s]Deleting backend snapshot ...' % snapshot_id)
        cmd_delete_snapshot = 'volume select volume-%s snapshot delete snapshot-%s' % (volume_id, snapshot_id)
        result = eqlx_ssh_execute(cmd_delete_snapshot)
        if 'Snapshot deletion succeeded.' not in result:
            LOG.error('   Can not delete snapshot "%s" !' % snapshot_id)
            return False
        else:
            return True
Esempio n. 4
0
def delete_backend_snapshots_eqlx(snapshots_id, volume_id):
    LOG.info('   Deleting backend(eqlx) snapshots ...')
    for snapshot_id in snapshots_id:
        LOG.info('   [%s]Deleting backend snapshot ...' % snapshot_id)
        cmd_delete_snapshot = 'volume select volume-%s snapshot delete snapshot-%s' % (volume_id, snapshot_id)
        result = eqlx_ssh_execute(cmd_delete_snapshot)
        if 'Snapshot deletion succeeded.' not in result:
            LOG.error('   Can not delete snapshot "%s" !' % snapshot_id)
            return False
        else:
            return True