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)
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
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)
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
def unlinkloop(loop_dev): if is_looped(loop_dev): putils.execute('losetup', '-d', loop_dev, run_as_root=True, root_helper=rootwrap.root_helper())
def linkloop(loop_dev, path): putils.execute('losetup', loop_dev, path, run_as_root=True, root_helper=rootwrap.root_helper())
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()
def __init__(self): dmsetup.Dmsetup.__init__(self, root_helper=rootwrap.root_helper())
def link(src, dst): return execute('ln', '-s', src, dst, run_as_root=True, root_helper=rootwrap.root_helper())
def unlink(path): return execute('rm', '-f', path, run_as_root=True, root_helper=rootwrap.root_helper())
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)
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())
def __init__(self): ISCSIConnector.__init__(self, device_scan_attempts=5, root_helper=rootwrap.root_helper())
def __init__(self): FCG.__init__(self, CONF.fcg_name, root_helper=rootwrap.root_helper())
def __init__(self): ISCSIConnector.__init__(self, root_helper=rootwrap.root_helper())