<s> from django . db import models <EOL> from datetime import datetime <EOL> from vt_manager . models . faults import * <EOL> import logging <EOL> import uuid <EOL> class Action ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> class Meta : <EOL> """<STR_LIT>""" <EOL> app_label = '<STR_LIT>' <EOL> '''<STR_LIT>''' <EOL> QUEUED_STATUS = "<STR_LIT>" <EOL> ONGOING_STATUS = "<STR_LIT>" <EOL> SUCCESS_STATUS = "<STR_LIT>" <EOL> FAILED_STATUS = "<STR_LIT>" <EOL> __possibleStatus = ( QUEUED_STATUS , ONGOING_STATUS , SUCCESS_STATUS , FAILED_STATUS ) <EOL> '''<STR_LIT>''' <EOL> MONITORING_SERVER_VMS_TYPE = "<STR_LIT>" <EOL> __monitoringTypes = ( <EOL> MONITORING_SERVER_VMS_TYPE , <EOL> ) <EOL> PROVISIONING_VM_CREATE_TYPE = "<STR_LIT>" <EOL> PROVISIONING_VM_START_TYPE = "<STR_LIT:start>" <EOL> PROVISIONING_VM_DELETE_TYPE = "<STR_LIT>" <EOL> PROVISIONING_VM_STOP_TYPE = "<STR_LIT>" <EOL> PROVISIONING_VM_REBOOT_TYPE = "<STR_LIT>" <EOL> __provisioningTypes = ( <EOL> PROVISIONING_VM_CREATE_TYPE , <EOL> PROVISIONING_VM_START_TYPE , <EOL> PROVISIONING_VM_DELETE_TYPE , <EOL> PROVISIONING_VM_STOP_TYPE , <EOL> PROVISIONING_VM_REBOOT_TYPE , <EOL> ) <EOL> '''<STR_LIT>''' <EOL> __possibleTypes = ( <EOL> MONITORING_SERVER_VMS_TYPE , <EOL> PROVISIONING_VM_CREATE_TYPE , <EOL> PROVISIONING_VM_START_TYPE , <EOL> PROVISIONING_VM_DELETE_TYPE , <EOL> PROVISIONING_VM_STOP_TYPE , <EOL> PROVISIONING_VM_REBOOT_TYPE , <EOL> ) <EOL> type = models . CharField ( max_length = <NUM_LIT:16> , default = "<STR_LIT>" ) <EOL> uuid = models . CharField ( max_length = <NUM_LIT> , default = "<STR_LIT>" ) <EOL> callBackUrl = models . URLField ( ) <EOL> status = models . CharField ( max_length = <NUM_LIT:16> , default = "<STR_LIT>" ) <EOL> description = models . CharField ( max_length = <NUM_LIT> , default = "<STR_LIT>" , blank = True , null = True ) <EOL> objectUUID = models . CharField ( max_length = <NUM_LIT> , default = "<STR_LIT>" , blank = True , null = True ) <EOL> def checkActionIsPresentAndUnique ( self ) : <EOL> if Action . objects . filter ( uuid = self . uuid ) . count ( ) != <NUM_LIT:0> : <EOL> logging . error ( "<STR_LIT>" ) <EOL> raise Exception ( "<STR_LIT>" ) <EOL> @ staticmethod <EOL> def getAndCheckActionByUUID ( uuid ) : <EOL> actions = Action . objects . filter ( uuid = uuid ) <EOL> if actions . count ( ) == <NUM_LIT:1> : <EOL> return actions [ <NUM_LIT:0> ] <EOL> elif actions . count ( ) == <NUM_LIT:0> : <EOL> logging . error ( "<STR_LIT>" % uuid ) <EOL> raise Exception ( "<STR_LIT>" % uuid ) <EOL> elif actions . count ( ) > <NUM_LIT:1> : <EOL> logging . error ( "<STR_LIT>" % uuid ) <EOL> raise Exception ( "<STR_LIT>" % uuid ) <EOL> def setStatus ( self , status ) : <EOL> if status not in self . __possibleStatus : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> self . status = status <EOL> self . save ( ) <EOL> def getStatus ( self ) : <EOL> return self . status <EOL> def setType ( self , type ) : <EOL> if type not in self . __possibleTypes : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> self . type = type <EOL> self . save ( ) <EOL> def getType ( self ) : <EOL> return self . type <EOL> def isProvisioningType ( self ) : <EOL> return self . type in self . __provisioningTypes <EOL> def isMonitoringType ( self ) : <EOL> return self . type in self . __monitoringTypes <EOL> def setDescription ( self , description ) : <EOL> self . description = description <EOL> self . save ( ) <EOL> def getDescription ( self ) : <EOL> return self . descripion <EOL> def setUUID ( self , uuid ) : <EOL> self . uuid = uuid <EOL> self . save ( ) <EOL> def getUUID ( self ) : <EOL> return self . uuid <EOL> def setCallBackUrl ( self , url ) : <EOL> self . uuid = url <EOL> self . save ( ) <EOL> def getCallBackUrl ( self ) : <EOL> return self . url <EOL> def setObjectUUID ( self , objUUID ) : <EOL> self . objectUUID = objUUID <EOL> self . save ( ) <EOL> def getObjectUUID ( self ) : <EOL> return self . objectUUID <EOL> @ staticmethod <EOL> def constructor ( aType , status , objectUUID = None , description = "<STR_LIT>" ) : <EOL> action = Action ( ) <EOL> action . setType ( aType ) <EOL> action . setStatus ( status ) <EOL> action . setUUID ( uuid . uuid4 ( ) ) <EOL> if not objectUUID == None : <EOL> action . setObjectUUID ( objectUUID ) <EOL> if not description == "<STR_LIT>" : <EOL> action . setDescription ( description ) <EOL> return action <EOL> def destroy ( self ) : <EOL> self . delete ( ) </s>
