Ejemplo 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)
Ejemplo n.º 2
0
def is_looped(loop_dev):
    (out, err) = putils.execute("losetup", '-a', run_as_root=True,
                                root_helper=rootwrap.root_helper())
    looped_list = [line.split()[0].rstrip(":")
                   for line in out.strip().split('\n')]
    if loop_dev in looped_list:
        return True
    return False
Ejemplo n.º 3
0
def reload_multipath(name, disks):
    blk = Blockdev(root_helper=rootwrap.root_helper())
    size = blk.get_sector_count(disks[0])
    multipath_table = '0 %d multipath 0 0 1 1 queue-length 0 %d 1 ' % (size, len(disks))
    for disk in disks:
        multipath_table += disk + ' 128 '
    multipath_table += '\n'
    reload_table(name, multipath_table)
Ejemplo 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
Ejemplo n.º 5
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())
Ejemplo n.º 6
0
def linkloop(loop_dev, path):
        putils.execute('losetup', loop_dev, path,
                       run_as_root=True, root_helper=rootwrap.root_helper())
Ejemplo n.º 7
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()
Ejemplo n.º 8
0
 def __init__(self):
     dmsetup.Dmsetup.__init__(self, root_helper=rootwrap.root_helper())
Ejemplo n.º 9
0
def link(src, dst):
    return execute('ln', '-s', src, dst, run_as_root=True,
                   root_helper=rootwrap.root_helper())
Ejemplo n.º 10
0
def unlink(path):
    return execute('rm', '-f', path, run_as_root=True,
                   root_helper=rootwrap.root_helper())
Ejemplo n.º 11
0
from brick.iscsi.iscsi import TgtAdm

from virtman.utils import rootwrap
from virtman.utils import singleton

from virtman.openstack.common import processutils as putils


class TgtExecutor(TgtAdm):
    def __init__(self, root_helper='', volumes_dir='/etc/tgt/stack.d'):
        TgtAdm.__init__(self, root_helper, volumes_dir)


tgt = TgtExecutor(rootwrap.root_helper(), '/etc/tgt/stack.d')


def create_iscsi_target(iqn, path):
    # params included (iqn  tid  lun  path) but (tid lun) not need for
    # tgt to create target
    return tgt.create_iscsi_target(iqn, '', '', path)


def remove_iscsi_target(vol_id, vol_name):
    return tgt.remove_iscsi_target('', '', vol_id, vol_name)


def exists(iqn):
    return tgt.exist(iqn)

Ejemplo n.º 12
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())
Ejemplo n.º 13
0
 def __init__(self):
     ISCSIConnector.__init__(self, device_scan_attempts=5,
                             root_helper=rootwrap.root_helper())
Ejemplo n.º 14
0
 def __init__(self):
     FCG.__init__(self, CONF.fcg_name, root_helper=rootwrap.root_helper())
Ejemplo n.º 15
0
 def __init__(self):
     ISCSIConnector.__init__(self, root_helper=rootwrap.root_helper())