def index(self, guestName, sourceGuestID, memory=None, vCPU=None, inbound=None, outbound=None): detail = { 'command': 'guest_duplicate', 'guestName': guestName, 'sourceGuestID': sourceGuestID, } if memory != None: detail['memory'] = memory if vCPU != None: detail['vCPU'] = vCPU if inbound != None: detail['inbound'] = inbound if outbound != None: detail['outbound'] = outbound taskID = queue.enqueue(detail) return shortcut.responseTaskID(taskID)
def index(self, guestIP, targetHostID=None): #resolve for guestID infoHost = cacheFile.getDatabaseIP() db = MySQLdb.connect(infoHost, setting.DB_USERNAME, setting.DB_PASSWORD, setting.DB_NAME) cursor = db.cursor() cursor.execute( "SELECT `guestID` FROM `guests` WHERE `IPAddress`='%s' " % (guestIP)) guestID = cursor.fetchone() db.close() if guestID != None: guestID = guestID[0] else: return shortcut.response('error', '', 'guestIP not found') detail = {'command': 'guest_start', 'guestID': guestID} if targetHostID != None: detail['targetHostID'] = targetHostID taskID = queue.enqueue(detail) return shortcut.responseTaskID(taskID)
def index(self, guestID): detail = {'command': 'guest_shutoff', 'guestID': guestID} taskID = queue.enqueue(detail) return shortcut.responseTaskID(taskID)
def index(self, targetHostID): detail = { 'command': 'global_migrate', 'targetHostID': targetHostID } taskID = queue.enqueue(detail) return shortcut.responseTaskID(taskID)
def index(self, guestID, targetHostID=None): detail = {'command': 'guest_start', 'guestID': guestID} if targetHostID != None: detail['targetHostID'] = targetHostID taskID = queue.enqueue(detail) return shortcut.responseTaskID(taskID)
def index(self, guestID, memory): detail = { 'command': 'guest_scale_memory', 'guestID': guestID, 'memory': memory, } taskID = queue.enqueue(detail) return shortcut.responseTaskID(taskID)
def index(self, guestID, vCPU): detail = { 'command': 'guest_scale_cpu', 'guestID': guestID, 'vCPU': vCPU, } taskID = queue.enqueue(detail) return shortcut.responseTaskID(taskID)
def index(self,sourceGuestID,description): detail={ 'command':'template_create_from_guest', 'sourceGuestID':sourceGuestID, 'description':description } taskID=queue.enqueue(detail) return shortcut.responseTaskID(taskID)
def index(self, hostName, MACAddress, IPAddress): detail = { 'command': 'host_add', 'hostName': hostName, 'MACAddress': MACAddress, 'IPAddress': IPAddress } taskID = queue.enqueue(detail) return shortcut.responseTaskID(taskID)
def index( self, guestID, targetHostID=None ): #I think I can restore guest at other host (if last host is not running it cannot restore [now]) detail = {'command': 'guest_restore', 'guestID': guestID} if targetHostID != None: detail['targetHostID'] = targetHostID taskID = queue.enqueue(detail) return shortcut.responseTaskID(taskID)
def index(self, hostID, mode): if mode not in ['standby', 'hibernate', 'shutdown']: return shortcut.response('error', '', 'invalid mode') detail = { 'command': 'host_close', 'hostID': hostID, 'mode': mode #{'standby','hibernate','shutdown'} } taskID = queue.enqueue(detail) return shortcut.responseTaskID(taskID)
def index(self,templateID): infoHost=cacheFile.getDatabaseIP() db = MySQLdb.connect(infoHost, setting.DB_USERNAME, setting.DB_PASSWORD, setting.DB_NAME ) cursor = db.cursor() cursor.execute("SELECT `guestID` FROM `guests` WHERE `templateID`=%s"%(str(templateID))) tmp=cursor.fetchone() db.close() if tmp!=None: return shortcut.response('error', '', 'There are guests that use this template') detail={ 'command':'template_remove', 'templateID':templateID } taskID=queue.enqueue(detail) return shortcut.responseTaskID(taskID)
def index(self, guestName, templateID, memory, vCPU, inbound=None, outbound=None): detail = { 'command': 'guest_create', 'guestName': guestName, 'templateID': templateID, 'memory': memory, 'vCPU': vCPU } if inbound != None: detail['inbound'] = inbound if outbound != None: detail['outbound'] = outbound taskID = queue.enqueue(detail) return shortcut.responseTaskID(taskID)
def index(self, hostID): detail = {'command': 'host_remove', 'hostID': hostID} taskID = queue.enqueue(detail) return shortcut.responseTaskID(taskID)