コード例 #1
0
def extendLV(args, options):
    ArgsInfo = str(args)
    cells = ArgsInfo.split(',')
    nums = len(cells)
    if nums != 6:
        raise Exception("Invalid args!")

    host = options.host
    port = int(options.port)

    projectId = cells[0]
    volumeId = cells[1]

    lvName = cells[2]
    lvNewSize = diskSizeToByters(cells[3])
    vmInstanceId = cells[4]
    deviceName = cells[5]

    (client, transport) = connectServer(host, port)
    newSize = client.extendLV(projectId, volumeId, lvName, lvNewSize, vmInstanceId, deviceName)
    if options.json:
        dt = {'action' :'extendLV',
              'new_size' : newSize
              }
        print json.dumps(dt)
    else:
        print "extend LV : %s, New Size: %d" % (ArgsInfo, newSize)
    transport.close()
コード例 #2
0
def extendLV(args, options):
    ArgsInfo = str(args)
    cells = ArgsInfo.split(',')
    nums = len(cells)
    if nums != 6:
        raise Exception("Invalid args!")

    host = options.host
    port = int(options.port)

    projectId = cells[0]
    volumeId = cells[1]

    lvName = cells[2]
    lvNewSize = diskSizeToByters(cells[3])
    vmInstanceId = cells[4]
    deviceName = cells[5]

    (client, transport) = connectServer(host, port)
    newSize = client.extendLV(projectId, volumeId, lvName, lvNewSize,
                              vmInstanceId, deviceName)
    if options.json:
        dt = {'action': 'extendLV', 'new_size': newSize}
        print json.dumps(dt)
    else:
        print "extend LV : %s, New Size: %d" % (ArgsInfo, newSize)
    transport.close()
コード例 #3
0
def attachVolume(args, options):
    ArgsInfo = str(args)
    cells = ArgsInfo.split(',')
    nums = len(cells)
    if nums < 9 or ((nums - 3) % 6) != 0:
        raise Exception("Invalid args!")

    host = options.host
    port = options.port

    projectId = cells[0]
    volumeId = cells[1]
    vmInstanceId = cells[2]
    chunkNums = (nums - 3) / 6
    pos = 3
    chunkList = []
    for i in range(0, chunkNums):
        diskChunk = DiskChunk()
        diskChunk.targetName = cells[pos]
        pos = pos + 1
        diskChunk.ip = cells[pos]
        pos = pos + 1
        diskChunk.port = int(cells[pos])
        pos = pos + 1
        diskChunk.size = diskSizeToByters(cells[pos])
        pos = pos + 1
        diskChunk.chapUser = cells[pos]
        pos = pos + 1
        diskChunk.chapPass = cells[pos]
        pos = pos + 1
        chunkList.append(diskChunk)

    (client, transport) = connectServer(host, port)
    DevicePath = client.attachVolume(projectId, volumeId, vmInstanceId, chunkList)
    if options.json:
        dt = {'action' :'attachVolume',
              'device_path' : DevicePath
              }
        print json.dumps(dt)
    else:
        print "Attach Volume : %s ." % (ArgsInfo)
        print "DevicePath : %s" % (DevicePath)

    transport.close()
コード例 #4
0
def attachVolume(args, options):
    ArgsInfo = str(args)
    cells = ArgsInfo.split(',')
    nums = len(cells)
    if nums < 9 or ((nums - 3) % 6) != 0:
        raise Exception("Invalid args!")

    host = options.host
    port = options.port

    projectId = cells[0]
    volumeId = cells[1]
    vmInstanceId = cells[2]
    chunkNums = (nums - 3) / 6
    pos = 3
    chunkList = []
    for i in range(0, chunkNums):
        diskChunk = DiskChunk()
        diskChunk.targetName = cells[pos]
        pos = pos + 1
        diskChunk.ip = cells[pos]
        pos = pos + 1
        diskChunk.port = int(cells[pos])
        pos = pos + 1
        diskChunk.size = diskSizeToByters(cells[pos])
        pos = pos + 1
        diskChunk.chapUser = cells[pos]
        pos = pos + 1
        diskChunk.chapPass = cells[pos]
        pos = pos + 1
        chunkList.append(diskChunk)

    (client, transport) = connectServer(host, port)
    DevicePath = client.attachVolume(projectId, volumeId, vmInstanceId,
                                     chunkList)
    if options.json:
        dt = {'action': 'attachVolume', 'device_path': DevicePath}
        print json.dumps(dt)
    else:
        print "Attach Volume : %s ." % (ArgsInfo)
        print "DevicePath : %s" % (DevicePath)

    transport.close()
コード例 #5
0
def extendVolume(args, options):
    ArgsInfo = str(args)
    cells = ArgsInfo.split(',')
    nums = len(cells)
    if nums != 10:
        raise Exception("Invalid args!")

    host = options.host
    port = options.port

    projectId = cells[0]
    volumeId = cells[1]
    vmInstanceId = cells[2]
    chunkNums = (nums - 3) / 6
    pos = 3
    diskChunk = DiskChunk()
    diskChunk.targetName = cells[pos]
    pos = pos + 1
    diskChunk.ip = cells[pos]
    pos = pos + 1
    diskChunk.port = int(cells[pos])
    pos = pos + 1
    diskChunk.size = diskSizeToByters(cells[pos])
    pos = pos + 1
    diskChunk.chapUser = cells[pos]
    pos = pos + 1
    diskChunk.chapPass = cells[pos]
    pos = pos + 1
    deviceName = cells[pos]

    (client, transport) = connectServer(host, port)

    newSize = client.extendVolume(projectId, volumeId, vmInstanceId, diskChunk,
                                  deviceName)
    print "extend Volume : %s ." % (ArgsInfo)
    print "New Size : %d" % (newSize)
    transport.close()
コード例 #6
0
def extendVolume(args, options):
    ArgsInfo = str(args)
    cells = ArgsInfo.split(',')
    nums = len(cells)
    if nums != 10:
        raise Exception("Invalid args!")

    host = options.host
    port = options.port

    projectId = cells[0]
    volumeId = cells[1]
    vmInstanceId = cells[2]
    chunkNums = (nums - 3) / 6
    pos = 3
    diskChunk = DiskChunk()
    diskChunk.targetName = cells[pos]
    pos = pos + 1
    diskChunk.ip = cells[pos]
    pos = pos + 1
    diskChunk.port = int(cells[pos])
    pos = pos + 1
    diskChunk.size = diskSizeToByters(cells[pos])
    pos = pos + 1
    diskChunk.chapUser = cells[pos]
    pos = pos + 1
    diskChunk.chapPass = cells[pos]
    pos = pos + 1
    deviceName = cells[pos]

    (client, transport) = connectServer(host, port)

    newSize = client.extendVolume(projectId, volumeId, vmInstanceId, diskChunk, deviceName)
    print "extend Volume : %s ." % (ArgsInfo)
    print "New Size : %d" % (newSize)
    transport.close()