Exemple #1
0
 def map_crm_d(self, resname):
     cd = crm()
     for disk in resname:
         if cd.delres(disk):
             print("delete ", disk)
         else:
             return False
     return True
 def crm_up(self, js):
     cd = crm()
     crm_config_statu = cd.get_data_crm()
     if 'ERROR' in crm_config_statu:
         print("Could not perform requested operations, are you root?")
         return False
     else:
         redata = cd.re_data(crm_config_statu)
         js.up_crmconfig(redata)
         return redata
 def map_crm_d(self, resname):
     cd = crm()
     crm_config_statu = cd.get_data_crm()
     if 'ERROR' in crm_config_statu:
         print("Could not perform requested operations, are you root?")
         return False
     else:
         for disk in resname:
             if cd.delres(disk):
                 print("delete ", disk)
             else:
                 return False
         return True
 def judge_ds(self, args, js):
     cd = crm()
     # data = cd.lsdata()
     data = cd.get_data_linstor()
     linstorlv = GetLinstor(data)
     disks = {}
     for d in linstorlv.get_data():
         disks.update({d[1]: d[5]})
     js.up_data('Disk', disks)
     if args.show == 'all' or args.show == None:
         print("	" + "{:<15}".format("Diskname") + "Path")
         print("	" + "{:<15}".format("---------------") + "---------------")
         for k in disks:
             print("	" + "{:<15}".format(k) + disks[k])
     else:
         if js.check_key('Disk', args.show):
             print(args.show, ":", js.get_data('Disk').get(args.show))
         else:
             print("Fail! Can't find " + args.show)
 def map_crm_c(self, mapdata):
     cd = crm()
     for i in mapdata['target']:
         target = i[0]
         targetiqn = i[1]
     # print(mapdata['disk'])
     for disk in mapdata['disk']:
         res = [disk, mapdata['disk'].get(disk)[0], mapdata['disk'].get(disk)[1]]
         if cd.createres(res, mapdata['host_iqn'], targetiqn):
             c = cd.createco(res[0], target)
             o = cd.createor(res[0], target)
             s = cd.resstart(res[0])
             if c and o and s:
                 print('create colocation and order success:', disk)
             else:
                 print("create colocation and order fail")
                 return False
         else:
             print('create resource Fail!')
             return False
     return True
 def map_data(self, js, crmdata, hg, dg):
     mapdata = {}
     hostiqn = []
     for h in js.get_data('HostGroup').get(hg):
         iqn = js.get_data('Host').get(h)
         hostiqn.append(iqn)
     mapdata.update({'host_iqn': hostiqn})
     disk = js.get_data('DiskGroup').get(dg)
     cd = crm()
     data = cd.get_data_linstor()
     linstorlv = GetLinstor(data)
     print("get linstor r lv data")
     # print(linstorlv.get_data())
     diskd = {}
     for d in linstorlv.get_data():
         for i in disk:
             if i in d:
                 diskd.update({d[1]: [d[4], d[5]]})
     mapdata.update({'disk': diskd})
     mapdata.update({'target': crmdata[2]})
     # print(mapdata)
     return mapdata
Exemple #7
0
 def crm_up(self, js):
     cd = crm()
     crm_config_statu = cd.re_data()
     # pprint(crm_config_statu)
     js.up_crmconfig(crm_config_statu)
     return crm_config_statu