github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/pkg/types/types.go (about) 1 package types 2 3 import ( 4 "fmt" 5 "time" 6 ) 7 8 type InstanceState string 9 10 const ( 11 InstanceState_Running InstanceState = "running" 12 InstanceState_Stopped InstanceState = "stopped" 13 InstanceState_Pending InstanceState = "pending" 14 InstanceState_Unknown InstanceState = "unknown" 15 InstanceState_Terminated InstanceState = "terminated" 16 InstanceState_Error InstanceState = "error" 17 InstanceState_Paused InstanceState = "paused" 18 InstanceState_Suspended InstanceState = "suspended" 19 ) 20 21 type Infrastructure string 22 23 const ( 24 Infrastructure_AWS Infrastructure = "AWS" 25 Infrastructure_GCLOUD Infrastructure = "GCLOUD" 26 Infrastructure_VSPHERE Infrastructure = "VSPHERE" 27 Infrastructure_VIRTUALBOX Infrastructure = "VIRTUALBOX" 28 Infrastructure_QEMU Infrastructure = "QEMU" 29 Infrastructure_PHOTON Infrastructure = "PHOTON" 30 Infrastructure_XEN Infrastructure = "XEN" 31 Infrastructure_OPENSTACK Infrastructure = "OPENSTACK" 32 Infrastructure_UKVM Infrastructure = "UKVM" 33 Infrastructure_FIRECRACKER Infrastructure = "FIRECRACKER" 34 ) 35 36 type Image struct { 37 Id string `json:"Id"` 38 Name string `json:"Name"` 39 SizeMb int64 `json:"SizeMb"` 40 Infrastructure Infrastructure `json:"Infrastructure"` 41 Created time.Time `json:"Created"` 42 StageSpec StageSpec `json:"StageSpec"` 43 RunSpec RunSpec `json:"RunSpec"` 44 } 45 46 // For Unik Hub 47 type UserImage struct { 48 *Image `json:"image"` 49 Owner string `json:"owner"` 50 } 51 52 func (image *Image) String() string { 53 if image == nil { 54 return "<nil>" 55 } 56 return fmt.Sprintf("%-v", *image) 57 } 58 59 type Instance struct { 60 Id string `json:"Id"` 61 Name string `json:"Name"` 62 State InstanceState `json:"State"` 63 IpAddress string `json:"IpAddress"` 64 ImageId string `json:"ImageId"` 65 Infrastructure Infrastructure `json:"Infrastructure"` 66 Created time.Time `json:"Created"` 67 } 68 69 func (instance *Instance) String() string { 70 if instance == nil { 71 return "<nil>" 72 } 73 return fmt.Sprintf("%+v", *instance) 74 } 75 76 type Volume struct { 77 Id string `json:"Id"` 78 Name string `json:"Name"` 79 SizeMb int64 `json:"SizeMb"` 80 Attachment string `json:"Attachment"` //instanceId 81 Infrastructure Infrastructure `json:"Infrastructure"` 82 Created time.Time `json:"Created"` 83 } 84 85 func (volume *Volume) String() string { 86 if volume == nil { 87 return "<nil>" 88 } 89 return fmt.Sprintf("%+v", *volume) 90 } 91 92 type RawImage struct { 93 LocalImagePath string `json:"LocalImagePath"` 94 StageSpec StageSpec `json:"StageSpec"` 95 RunSpec RunSpec `json:"RunSpec"` 96 } 97 98 type ImageFormat string 99 100 const ( 101 ImageFormat_RAW ImageFormat = "raw" 102 ImageFormat_QCOW2 ImageFormat = "qcow2" 103 ImageFormat_VHD ImageFormat = "vhd" 104 ImageFormat_VMDK ImageFormat = "vmdk" 105 ImageFormat_Folder ImageFormat = "folder" 106 ) 107 108 type XenVirtualizationType string 109 110 const ( 111 XenVirtualizationType_HVM = "hvm" 112 XenVirtualizationType_Paravirtual = "paravirtual" 113 ) 114 115 type StageSpec struct { 116 ImageFormat ImageFormat `json:"ImageFormat"` //required for all compilers 117 XenVirtualizationType XenVirtualizationType `json:"XenVirtualizationType,omitempty"` 118 } 119 120 type StorageDriver string 121 122 const ( 123 StorageDriver_SCSI = "SCSI" 124 StorageDriver_SATA = "SATA" 125 StorageDriver_IDE = "IDE" 126 ) 127 128 type VsphereNetworkType string 129 130 const ( 131 VsphereNetworkType_E1000 = "e1000" 132 VsphereNetworkType_VMXNET3 = "vmxnet3" 133 ) 134 135 type RunSpec struct { 136 DeviceMappings []DeviceMapping `json:"DeviceMappings"` //required for all compilers 137 // DefaultInstanceMemory is in MB 138 DefaultInstanceMemory int `json:"DefaultInstanceMemory"` //required for all compilers 139 MinInstanceDiskMB int `json:"MinInstanceDiskMB"` 140 StorageDriver StorageDriver `json:"StorageDriver,omitempty"` 141 VsphereNetworkType VsphereNetworkType `json:"VsphereNetworkType"` 142 Compiler string `json:"Compiler,omitempty"` 143 } 144 145 type DeviceMapping struct { 146 MountPoint string `json:"MountPoint"` 147 DeviceName string `json:"DeviceName"` 148 }