Exemple #1
0
def delete_lv(request):
    vg_name = request.matchdict['vg']
    lv_name = request.matchdict['lv']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    lv = vg.get_lv(lv_name)
    lv.delete()
    return Response(status=200)
Exemple #2
0
def delete_lv(request):
    vg_name = request.matchdict['vg']
    lv_name = request.matchdict['lv']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    lv = vg.get_lv(lv_name)
    lv.delete()
    return Response(status=200)
Exemple #3
0
def post_lv_snapshot(request):
    params = get_params_from_request(request, lv_snapshot_schema)
    vg_name = request.matchdict['vg']
    lv_name = request.matchdict['lv']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    lv = vg.get_lv(lv_name)
    lv.snapshot(params['name'], params['size'])
    return Response(status=200)
Exemple #4
0
def post_lv_snapshot(request):
    params = get_params_from_request(request, lv_snapshot_schema)
    vg_name = request.matchdict['vg']
    lv_name = request.matchdict['lv']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    lv = vg.get_lv(lv_name)
    lv.snapshot(params['name'], params['size'])
    return Response(status=200)
Exemple #5
0
def get_vg_info(request):
    vg_name = request.matchdict['vg']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    vg_info = {
        'name': vg.name,
        'uuid': vg.uuid,
        'size': vg.size,
        'free_size': vg.free_size,
    }
    return vg_info
Exemple #6
0
def post_vg_op(request):
    params = get_params_from_request(request, vg_op_schema)
    vg_name = request.matchdict['vg']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    if(params['opt']) == 'grow' :
        vg.grow(params['dev'])
    elif(params['opt']) == 'shrink' :
        vg.shrink(params['dev'])
               
    return Response(status=200)
Exemple #7
0
def get_vg_info(request):
    vg_name = request.matchdict['vg']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    vg_info = {
               'name':vg.name,
               'uuid':vg.uuid,
               'size':vg.size,
               'free_size':vg.free_size,
               }
    return vg_info
Exemple #8
0
def post_vg_op(request):
    params = get_params_from_request(request, vg_op_schema)
    vg_name = request.matchdict['vg']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    if (params['opt']) == 'grow':
        for dev in params['dev']:
            vg.grow(dev)
    elif (params['opt']) == 'shrink':
        for dev in params['dev']:
            vg.shrink(dev)
    return Response(status=200)
Exemple #9
0
def post_lv_op(request):
    params = get_params_from_request(request, lv_op_schema)
    vg_name = request.matchdict['vg']
    lv_name = request.matchdict['lv']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    lv = vg.get_lv(lv_name)
    if(params['opt']) == 'activate' :
        lv.activate()
    elif(params['opt']) == 'disable' :
        lv.deactivate()
               
    return Response(status=200)
Exemple #10
0
def get_vg_list(request):
    lvm_mng = lvm.lvm_mgr()
    vgs = lvm_mng.get_all_vg()
    vg_dict = []
    for vg in vgs:
        vg_info = {
            'name': vgs[vg].name,
            'uuid': vgs[vg].uuid,
            'size': vgs[vg].size,
            'free_size': vgs[vg].free_size,
        }
        vg_dict.append(vg_info)
    return vg_dict
Exemple #11
0
def get_vg_list(request):
    lvm_mng = lvm.lvm_mgr()
    vgs = lvm_mng.get_all_vg()
    vg_dict = []
    for vg in vgs:
        vg_info = {
                   'name':vgs[vg].name,
                   'uuid':vgs[vg].uuid,
                   'size':vgs[vg].size,
                   'free_size':vgs[vg].free_size,
                   }
        vg_dict.append(vg_info)
    return vg_dict
Exemple #12
0
def post_lv_op(request):
    params = get_params_from_request(request, lv_op_schema)
    vg_name = request.matchdict['vg']
    lv_name = request.matchdict['lv']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    lv = vg.get_lv(lv_name)
    if (params['opt']) == 'activate':
        lv.activate()
    elif (params['opt']) == 'disable':
        lv.deactivate()

    return Response(status=200)
Exemple #13
0
def create_vg(request):
    lvm_mng = lvm.lvm_mgr()
    params = get_params_from_request(request, new_vg_schema)
    vg = lvm_mng.new_vg(params['vgname'], params['dev'])

    if vg is None:
        return Response(status=500)
    else:
        vg_info = {
            'name': vg.name,
            'uuid': vg.uuid,
            'size': vg.size,
            'free_size': vg.free_size,
        }
        return vg_info
Exemple #14
0
def create_vg(request):
    lvm_mng = lvm.lvm_mgr()
    params = get_params_from_request(request, new_vg_schema)
    vg = lvm_mng.new_vg(params['vgname'], params['dev'])
    
    if vg is None:
        return Response(status=500)
    else:
        vg_info = {
                   'name':vg.name,
                   'uuid':vg.uuid,
                   'size':vg.size,
                   'free_size':vg.free_size,
                   }
        return vg_info
Exemple #15
0
def get_lv(request):
    vg_name = request.matchdict['vg']
    lv_name = request.matchdict['lv']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    lv = vg.get_lv(lv_name)
    lv_info = {
        'name': lv.name,
        'uuid': lv.uuid,
        'size': lv.size,
        'state': lv.is_activate,
        'origin': lv.origin,
        'attr': lv.attr,
        'snap_percent': lv.snap_percent
    }
    return lv_info
Exemple #16
0
def get_lv(request):
    vg_name = request.matchdict['vg']
    lv_name = request.matchdict['lv']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    lv = vg.get_lv(lv_name)
    lv_info = {
           'name':lv.name,
           'uuid':lv.uuid,
           'size':lv.size,
           'state':lv.is_activate,
           'origin':lv.origin,
           'attr':lv.attr,
           'snap_percent':lv.snap_percent
           }
    return lv_info
Exemple #17
0
def get_lv_list(request):
    vg_name = request.matchdict['vg']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    lv_dict = []
    lvs = vg.lvs
    for lv in lvs:
        lv_info = {
            'name': lvs[lv].name,
            'uuid': lvs[lv].uuid,
            'size': lvs[lv].size,
            'state': lvs[lv].is_activate,
            'origin': lvs[lv].origin,
            'attr': lvs[lv].attr,
            'snap_percent': lvs[lv].snap_percent
        }
        lv_dict.append(lv_info)
    return lv_dict
Exemple #18
0
def get_lv_list(request):
    vg_name = request.matchdict['vg']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    lv_dict = []
    lvs = vg.lvs
    for lv in lvs:
        lv_info = {
               'name':lvs[lv].name,
               'uuid':lvs[lv].uuid,
               'size':lvs[lv].size,
               'state':lvs[lv].is_activate,
               'origin':lvs[lv].origin,
               'attr':lvs[lv].attr,
               'snap_percent':lvs[lv].snap_percent
               }
        lv_dict.append(lv_info)
    return lv_dict
Exemple #19
0
def add_lv(request):
    vg_name = request.matchdict['vg']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    params = get_params_from_request(request, add_lv_schema)
    lv = vg.create_lv(params['lvname'],params['size'])
    if vg is None:
        return Response(status=500)
    else:
        lv_info = {
                   'name':lv.name,
                   'uuid':lv.uuid,
                   'size':lv.size,
                   'state':lv.is_activate,
                   'origin':lv.origin,
                   'attr':lv.attr,
                   'snap_percent':lv.snap_percent
                   }
        return lv_info
Exemple #20
0
def add_lv(request):
    vg_name = request.matchdict['vg']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    params = get_params_from_request(request, add_lv_schema)
    lv = vg.create_lv(params['lvname'], params['size'])
    if vg is None:
        return Response(status=500)
    else:
        lv_info = {
            'name': lv.name,
            'uuid': lv.uuid,
            'size': lv.size,
            'state': lv.is_activate,
            'origin': lv.origin,
            'attr': lv.attr,
            'snap_percent': lv.snap_percent
        }
        return lv_info
Exemple #21
0
 def test_lvm(self):
     lvm = lvm_mgr()
     # create VG
     device = get_block_dev()
     if device == "":
         return  # no test
     lvm.new_vg('test_vg', [device])
     vg = lvm.get_vg('test_vg')
     self.assertIn(os.path.basename(device), vg.pvs)
     pv = vg.get_pv(device)
     self.assertEqual(pv.dev_file, device)
     # create LV
     vg.create_lv('test_lv1', 64*1024*1024*10)
     self.assertIn('test_lv1', vg.lvs)
     lv = vg.get_lv('test_lv1')
     self.assertEqual(lv.name, 'test_lv1')
     # resize LV
     lv.resize(64*1024*1024*15)
     self.assertEqual(lv.size, 64*1024*1024*15)
     # remove LV
     lv.delete()
     self.assertNotIn('test_lv1', vg.lvs)
     # grow VG
     device_extra = get_extra_block_dev()
     if device_extra != "":
         vg.grow(device_extra)
         vg = lvm.get_vg('test_vg')
         self.assertEqual(len(vg.pvs), 2)
         self.assertIn(os.path.basename(device), vg.pvs)
         self.assertIn(os.path.basename(device_extra), vg.pvs)
         # shrink VG
         vg.shrink(device)
         vg = lvm.get_vg('test_vg')
         self.assertIn(os.path.basename(device_extra), vg.pvs)
         self.assertNotIn(os.path.basename(device), vg.pvs)
     # delete VG
     vg.delete()
     self.assertRaises(StorLeverError, lvm.get_vg, 'test_vg')
Exemple #22
0
 def test_lvm(self):
     lvm = lvm_mgr()
     # create VG
     device = get_block_dev()
     if device == "":
         return  # no test
     lvm.new_vg('test_vg', [device])
     vg = lvm.get_vg('test_vg')
     self.assertIn(os.path.basename(device), vg.pvs)
     pv = vg.get_pv(device)
     self.assertEqual(pv.dev_file, device)
     # create LV
     vg.create_lv('test_lv1', 64 * 1024 * 1024 * 10)
     self.assertIn('test_lv1', vg.lvs)
     lv = vg.get_lv('test_lv1')
     self.assertEqual(lv.name, 'test_lv1')
     # resize LV
     lv.resize(64 * 1024 * 1024 * 15)
     self.assertEqual(lv.size, 64 * 1024 * 1024 * 15)
     # remove LV
     lv.delete()
     self.assertNotIn('test_lv1', vg.lvs)
     # grow VG
     device_extra = get_extra_block_dev()
     if device_extra != "":
         vg.grow(device_extra)
         vg = lvm.get_vg('test_vg')
         self.assertEqual(len(vg.pvs), 2)
         self.assertIn(os.path.basename(device), vg.pvs)
         self.assertIn(os.path.basename(device_extra), vg.pvs)
         # shrink VG
         vg.shrink(device)
         vg = lvm.get_vg('test_vg')
         self.assertIn(os.path.basename(device_extra), vg.pvs)
         self.assertNotIn(os.path.basename(device), vg.pvs)
     # delete VG
     vg.delete()
     self.assertRaises(StorLeverError, lvm.get_vg, 'test_vg')
Exemple #23
0
def delete_vg_rest(request):
    vg_name = request.matchdict['vg']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    vg.delete()
    return Response(status=200)
Exemple #24
0
def delete_vg_rest(request):
    vg_name = request.matchdict['vg']
    lvm_mng = lvm.lvm_mgr()
    vg = lvm_mng.get_vg(vg_name)
    vg.delete()
    return Response(status=200)