Esempio n. 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)
Esempio n. 2
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())
Esempio n. 3
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
Esempio n. 4
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
Esempio n. 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())
Esempio n. 6
0
def execute(*cmd, **kwargs):
    """Convenience wrapper around oslo's execute() method."""
    if 'run_as_root' in kwargs and not 'root_helper' in kwargs:
        kwargs['root_helper'] = get_root_helper()
    return processutils.execute(*cmd, **kwargs)
Esempio n. 7
0
def execute(*cmd, **kwargs):
    return putils.execute(*cmd, **kwargs)
Esempio n. 8
0
def execute(*cmd, **kwargs):
    return putils.execute(*cmd, **kwargs)
Esempio n. 9
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())
Esempio n. 10
0
def linkloop(loop_dev, path):
    putils.execute('losetup', loop_dev, path, run_as_root=True, root_helper=rootwrap.root_helper())
Esempio n. 11
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()