public static LibvirtMessageWrapper BuildMessage(LIBVIRT_MESSAGE_TYPE type, object Payload, string requestor, string requestorid) { LibvirtMessageWrapper wrapper = new LibvirtMessageWrapper(); switch (type) { case LIBVIRT_MESSAGE_TYPE.CREATE_VM: LibvirtCommand createVmMessage = new LibvirtCommand(); wrapper.Message = createVmMessage; wrapper.Command = MessageTypeToString(type); wrapper.Requestor = requestor; wrapper.RequestorId = requestorid; VirtualMachineBuilder builder = (VirtualMachineBuilder)Payload; wrapper.VirtualMachineBuilder = builder; break; } return(wrapper); }
public static LibvirtMessageWrapper BuildMessage(LIBVIRT_MESSAGE_TYPE type, string requestor, string requestorid) { LibvirtMessageWrapper wrapper = new LibvirtMessageWrapper(); switch (type) { case LIBVIRT_MESSAGE_TYPE.LIST: LibvirtCommand listDomainsMessage = new LibvirtCommand(); wrapper.Message = listDomainsMessage; wrapper.Command = MessageTypeToString(type); wrapper.Requestor = requestor; wrapper.RequestorId = requestorid; break; case LIBVIRT_MESSAGE_TYPE.START: LibvirtCommand startDomainMessage = new LibvirtCommand(); wrapper.Message = startDomainMessage; wrapper.Command = MessageTypeToString(type); wrapper.Requestor = requestor; wrapper.RequestorId = requestorid; break; case LIBVIRT_MESSAGE_TYPE.STOP: LibvirtCommand stopDomainMessage = new LibvirtCommand(); wrapper.Message = stopDomainMessage; wrapper.Command = MessageTypeToString(type); wrapper.Requestor = requestor; wrapper.RequestorId = requestorid; break; case LIBVIRT_MESSAGE_TYPE.PAUSE: LibvirtCommand pauseDomainMessage = new LibvirtCommand(); wrapper.Message = pauseDomainMessage; wrapper.Command = MessageTypeToString(type); wrapper.Requestor = requestor; wrapper.RequestorId = requestorid; break; case LIBVIRT_MESSAGE_TYPE.RESUME: LibvirtCommand resumeDomainMessage = new LibvirtCommand(); wrapper.Message = resumeDomainMessage; wrapper.Command = MessageTypeToString(type); wrapper.Requestor = requestor; wrapper.RequestorId = requestorid; break; case LIBVIRT_MESSAGE_TYPE.HOST_DETAILS: LibvirtCommand hostDetailsMessage = new LibvirtCommand(); wrapper.Message = hostDetailsMessage; wrapper.Command = MessageTypeToString(type); wrapper.Requestor = requestor; wrapper.RequestorId = requestorid; break; case LIBVIRT_MESSAGE_TYPE.LIST_DISKS: LibvirtCommand listDisksMessage = new LibvirtCommand(); wrapper.Message = listDisksMessage; wrapper.Command = MessageTypeToString(type); wrapper.Requestor = requestor; wrapper.RequestorId = requestorid; break; case LIBVIRT_MESSAGE_TYPE.LIST_IMAGES: LibvirtCommand listIsoMessage = new LibvirtCommand(); wrapper.Message = listIsoMessage; wrapper.Command = MessageTypeToString(type); wrapper.Requestor = requestor; wrapper.RequestorId = requestorid; break; case LIBVIRT_MESSAGE_TYPE.CREATE_VM: LibvirtCommand createVmMessage = new LibvirtCommand(); wrapper.Message = createVmMessage; wrapper.Command = MessageTypeToString(type); wrapper.Requestor = requestor; wrapper.RequestorId = requestorid; break; case LIBVIRT_MESSAGE_TYPE.FORCE_SHUTDOWN: LibvirtCommand ForceShutdownVmMessage = new LibvirtCommand(); wrapper.Message = ForceShutdownVmMessage; wrapper.Command = MessageTypeToString(type); wrapper.Requestor = requestor; wrapper.RequestorId = requestorid; break; case LIBVIRT_MESSAGE_TYPE.GET_VNC_PORT: LibvirtCommand vncPortMessage = new LibvirtCommand(); wrapper.Message = vncPortMessage; wrapper.Command = MessageTypeToString(type); wrapper.Requestor = requestor; wrapper.RequestorId = requestorid; break; case LIBVIRT_MESSAGE_TYPE.TRANSFER_FILE: LibvirtCommand transferFileMessage = new LibvirtCommand(); wrapper.Message = transferFileMessage; wrapper.Command = MessageTypeToString(type); wrapper.Requestor = requestor; wrapper.RequestorId = requestorid; break; case LIBVIRT_MESSAGE_TYPE.CLONE_VM: LibvirtCommand cloneMessage = new LibvirtCommand(); wrapper.Message = cloneMessage; wrapper.Command = MessageTypeToString(type); wrapper.Requestor = requestor; wrapper.RequestorId = requestorid; break; case LIBVIRT_MESSAGE_TYPE.DELETE_VM: LibvirtCommand deletMessage = new LibvirtCommand(); wrapper.Message = deletMessage; wrapper.Command = MessageTypeToString(type); wrapper.Requestor = requestor; wrapper.RequestorId = requestorid; break; case LIBVIRT_MESSAGE_TYPE.LIST_VM_STATISTICS: LibvirtCommand listStatsMessage = new LibvirtCommand(); wrapper.Message = listStatsMessage; wrapper.Command = MessageTypeToString(type); wrapper.Requestor = requestor; wrapper.RequestorId = requestorid; break; case LIBVIRT_MESSAGE_TYPE.LIST_DISK_USAGE: LibvirtCommand listDiskUsageMessage = new LibvirtCommand(); wrapper.Message = listDiskUsageMessage; wrapper.Command = MessageTypeToString(type); wrapper.Requestor = requestor; wrapper.RequestorId = requestorid; break; case LIBVIRT_MESSAGE_TYPE.LIST_VHD_STORAGE: LibvirtCommand listVHDMessage = new LibvirtCommand(); wrapper.Message = listVHDMessage; wrapper.Command = MessageTypeToString(type); wrapper.Requestor = requestor; wrapper.RequestorId = requestorid; break; } return(wrapper); }