github.com/cloud-foundations/dominator@v0.0.0-20221004181915-6e4fee580046/imageunpacker/client/misc.go (about) 1 package client 2 3 import ( 4 "path" 5 6 "github.com/Cloud-Foundations/Dominator/lib/srpc" 7 proto "github.com/Cloud-Foundations/Dominator/proto/imageunpacker" 8 ) 9 10 func associateStreamWithDevice(srpcClient *srpc.Client, streamName string, 11 deviceId string) error { 12 request := proto.AssociateStreamWithDeviceRequest{ 13 StreamName: streamName, 14 DeviceId: deviceId, 15 } 16 var reply proto.AssociateStreamWithDeviceResponse 17 return srpcClient.RequestReply("ImageUnpacker.AssociateStreamWithDevice", 18 request, &reply) 19 } 20 21 func exportImage(srpcClient *srpc.Client, streamName, 22 exportType, exportDestination string) error { 23 request := proto.ExportImageRequest{ 24 StreamName: path.Clean(streamName), 25 Type: exportType, 26 Destination: exportDestination, 27 } 28 var reply proto.ExportImageResponse 29 return srpcClient.RequestReply("ImageUnpacker.ExportImage", request, &reply) 30 } 31 32 func getStatus(srpcClient *srpc.Client) (proto.GetStatusResponse, error) { 33 var request proto.GetStatusRequest 34 var reply proto.GetStatusResponse 35 err := srpcClient.RequestReply("ImageUnpacker.GetStatus", request, &reply) 36 return reply, err 37 } 38 39 func prepareForCapture(srpcClient *srpc.Client, streamName string) error { 40 request := proto.PrepareForCaptureRequest{StreamName: streamName} 41 var reply proto.PrepareForCaptureResponse 42 return srpcClient.RequestReply("ImageUnpacker.PrepareForCapture", request, 43 &reply) 44 } 45 46 func prepareForCopy(srpcClient *srpc.Client, streamName string) error { 47 request := proto.PrepareForCopyRequest{StreamName: streamName} 48 var reply proto.PrepareForCopyResponse 49 return srpcClient.RequestReply("ImageUnpacker.PrepareForCopy", request, 50 &reply) 51 } 52 53 func prepareForUnpack(srpcClient *srpc.Client, streamName string, 54 skipIfPrepared bool, doNotWaitForResult bool) error { 55 request := proto.PrepareForUnpackRequest{ 56 DoNotWaitForResult: doNotWaitForResult, 57 SkipIfPrepared: skipIfPrepared, 58 StreamName: streamName, 59 } 60 var reply proto.PrepareForUnpackResponse 61 return srpcClient.RequestReply("ImageUnpacker.PrepareForUnpack", request, 62 &reply) 63 } 64 65 func removeDevice(srpcClient *srpc.Client, deviceId string) error { 66 request := proto.RemoveDeviceRequest{DeviceId: deviceId} 67 var reply proto.RemoveDeviceResponse 68 return srpcClient.RequestReply("ImageUnpacker.RemoveDevice", request, 69 &reply) 70 } 71 72 func unpackImage(srpcClient *srpc.Client, streamName, 73 imageLeafName string) error { 74 request := proto.UnpackImageRequest{ 75 StreamName: path.Clean(streamName), 76 ImageLeafName: path.Clean(imageLeafName), 77 } 78 var reply proto.UnpackImageResponse 79 return srpcClient.RequestReply("ImageUnpacker.UnpackImage", request, &reply) 80 }