Beispiel #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)
Beispiel #2
0
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,
                                   root_helper=rootwrap.root_helper())
Beispiel #3
0
def link(src, dst):
    return execute('ln',
                   '-s',
                   src,
                   dst,
                   run_as_root=True,
                   root_helper=rootwrap.root_helper())
Beispiel #4
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)
Beispiel #5
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
Beispiel #6
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)
Beispiel #7
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())
Beispiel #8
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
Beispiel #9
0
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, root_helper=rootwrap.root_helper())
Beispiel #10
0
import os

from brick.iscsi.iscsi import TgtAdm

from vmthunder.singleton import singleton
from vmthunder.utils import rootwrap

from vmthunder.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, root_helper=rootwrap.root_helper())


def remove_iscsi_target(tid, lun, vol_id, vol_name, **kwargs):
    return tgt.remove_iscsi_target(tid, lun, vol_id, vol_name, **kwargs)


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


def is_connected(target_id):
Beispiel #11
0
def linkloop(loop_dev, path):
    putils.execute('losetup', loop_dev, path, run_as_root=True, root_helper=rootwrap.root_helper())
Beispiel #12
0
 def __init__(self):
     FCG.__init__(self, CONF.fcg_name, root_helper=rootwrap.root_helper())
Beispiel #13
0
import os

from brick.iscsi.iscsi import TgtAdm

from vmthunder.singleton import singleton
from vmthunder.utils import rootwrap

from vmthunder.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,
                                   root_helper=rootwrap.root_helper())


def remove_iscsi_target(tid, lun, vol_id, vol_name, **kwargs):
    return tgt.remove_iscsi_target(tid, lun, vol_id, vol_name, **kwargs)

Beispiel #14
0
 def __init__(self):
     ISCSIConnector.__init__(self, root_helper=rootwrap.root_helper())
Beispiel #15
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())
Beispiel #16
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())
Beispiel #17
0
def unlink(path):
    return execute('rm',
                   '-f',
                   path,
                   run_as_root=True,
                   root_helper=rootwrap.root_helper())
Beispiel #18
0
def link(src, dst):
    return execute('ln', '-s', src, dst, run_as_root=True, root_helper=rootwrap.root_helper())
Beispiel #19
0
 def __init__(self):
     ISCSIConnector.__init__(self, root_helper=rootwrap.root_helper())
Beispiel #20
0
 def __init__(self):
     dmsetup.Dmsetup.__init__(self, root_helper=rootwrap.root_helper())
Beispiel #21
0
def unlink(path):
    return execute('rm', '-f', path, run_as_root=True, root_helper=rootwrap.root_helper())
Beispiel #22
0
 def __init__(self):
     dmsetup.Dmsetup.__init__(self, root_helper=rootwrap.root_helper())
Beispiel #23
0
 def __init__(self):
     FCG.__init__(self, CONF.fcg_name, root_helper=rootwrap.root_helper())
Beispiel #24
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()