Example #1
0
def try_linkloop(loop_dev):
    path = '/root/blocks/'
    if not os.path.exists(path):
        putils.execute('mkdir', '-p', path, run_as_root=True, root_helper=rootwrap.root_helper())
    path = path + 'snap' + loop_dev[9:] + '.blk'
    if not os.path.exists(path):
        putils.execute('dd', 'if=/dev/zero', 'of=' + path, 'bs=1M', 'count=512',
                       run_as_root=True, root_helper=rootwrap.root_helper())
    linkloop(loop_dev, path)
Example #2
0
def is_connected(target_id):
    """This method is to judge whether a target is hanging by other VMs"""
    #TODO: try to call brick.iscsi
    #cmd = "tgtadm --lld iscsi --mode conn --op show --tid " + str(target_id)
    (output, error) = putils.execute("tgtadm", '--lld', 'iscsi', '--mode', 'conn', '--op', 'show', '--tid',
                                     str(target_id), run_as_root=True, root_helper=rootwrap.root_helper())
    if len(output) == 0:
        return False
    return True
Example #3
0
 def cmd():
     return putils.execute()
Example #4
0
def execute(*cmd, **kwargs):
    return putils.execute(*cmd, **kwargs)
Example #5
0
def disconnect_volume(connection, device_info):
    #TODO: Fix this problem
    #cmd = "iscsiadm -m node -T " + connection['target_iqn'] + " -p " + connection['target_portal'][:-5] + " --logout"
    putils.execute("iscsiadm", '-m', 'node', '-T', connection['target_iqn'], '-p', connection['target_portal'],
                   '--logout', run_as_root=True, root_helper=rootwrap.root_helper())
Example #6
0
def unlinkloop(loop_dev):
    if is_looped(loop_dev):
        putils.execute('losetup', '-d', loop_dev, run_as_root=True, root_helper=rootwrap.root_helper())
Example #7
0
def linkloop(loop_dev, path):
    putils.execute('losetup', loop_dev, path, run_as_root=True, root_helper=rootwrap.root_helper())
Example #8
0
def findloop():
    #Licyh NOTE: openstack.common.processutils & subprocess.Popen only supports 'ls' not 'cat a.py' but 'cat','a.py',
    (out, err) = putils.execute('losetup', '-f', run_as_root=True, root_helper=rootwrap.root_helper())
    return out.strip()