示例#1
0
class vmControl(object):
    def __init__(self):
        self.callbackKey = GenKey()
        self.log = logging.getLogger("vmStoreRsync.vmStoreRsync") 
        self.cfgModel = CfgModel()
        self.cfgModel.libvirtConStr.addCallback(self.callbackKey,self._onlibvirtConStr)
        self.libVirtModel = vhostMdl()
        self.archiveStore = archControler(self.cfgModel)
    def LoadConfigCfg(self,configfile):
        self.config = ConfigFile1(self.cfgModel)
        return self.config.upDateModel(configfile)

    def _onlibvirtConStr(self):
        connectionStr = self.cfgModel.libvirtConStr.get()
        if not isinstance( connectionStr, unicode ):
            print "asdaSDASD"
        self.libVirtControler = LibVirtCnt(connectionStr,self.libVirtModel)
        self.libVirtControler.updateModel()

    def Process(self,instructions):
        if not isinstance( instructions, dict ):
            return None
        if not 'vmControl' in instructions.keys():
            return None
        ting = StorageControler(self.cfgModel)
        
        self.ProcessState = vmState(self.libVirtControler,self.cfgModel,ting,self.archiveStore)
        output = {'vmControl' : self.ProcessState.process(instructions)}
        return output
        
    def ListBoxes(self):
        cfgBoxes = set(self.cfgModel.vmbyName.keys())
        livirtBoxes = set(self.libVirtModel.vmsbyName.keys())
        BoxesUnion = cfgBoxes.union(livirtBoxes)
        boxesOutput = {}
        for item in BoxesUnion:
            newBox = {'name': str(item)}
            if item in livirtBoxes:
                newBox['libvirt'] = 1
            else:
                newBox['libvirt'] = 0
            if item in cfgBoxes:
                newBox['disk'] = 1
            else:
                newBox['disk'] = 0
            boxesOutput[item] = newBox
        return boxesOutput
示例#2
0
 def _onlibvirtConStr(self):
     connectionStr = self.cfgModel.libvirtConStr.get()
     if not isinstance( connectionStr, unicode ):
         print "asdaSDASD"
     self.libVirtControler = LibVirtCnt(connectionStr,self.libVirtModel)
     self.libVirtControler.updateModel()