-
Notifications
You must be signed in to change notification settings - Fork 7
MRPHS-5166 : GCP cloud creation via c3ntry <DO NOT MERGE> #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| package gcp | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "errors" | ||
| "fmt" | ||
| "net" | ||
|
|
@@ -45,6 +46,7 @@ var ( | |
| type VM struct { | ||
| Name string | ||
| Description string | ||
| Region string | ||
| Zone string | ||
| MachineType string | ||
| Preemptible bool // Preemptible instances will be terminates after they run for 24 hours. | ||
|
|
@@ -64,7 +66,7 @@ type VM struct { | |
| Tags []string //Instance Tags | ||
|
|
||
| AccountFile string | ||
| account accountFile | ||
| Account AccountFile | ||
| SSHCreds ssh.Credentials | ||
| SSHPublicKey string | ||
|
|
||
|
|
@@ -206,7 +208,7 @@ type Account struct { | |
| AccountFile string | ||
| // account: Represents a structure containing private key, client email | ||
| // and client ID parsed from AccountFile | ||
| account accountFile | ||
| Account AccountFile | ||
| // Scopes: Represents access scopes with which API call is made | ||
| Scopes []string | ||
| } | ||
|
|
@@ -225,11 +227,47 @@ type Project struct { | |
| CreateTime string `json:"create_time,omitempty"` | ||
| } | ||
|
|
||
| // Packer visor image config for GCP cloud | ||
| type GcpConfig struct { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GcpPackerConfig ? |
||
| AccountFile string `json:"account_file"` | ||
| ProjectID string `json:"project_id"` | ||
| SourceImage string `json:"source_image"` | ||
| SSHUsername string `json:"ssh_username,omitempty"` | ||
| Type string `json:"type"` | ||
| Zone string `json:"zone"` | ||
| StartupScript string `json:"startup_script_file"` | ||
| ImageName string `json:"image_name,omitempty"` | ||
| } | ||
|
|
||
| // Packer visor image config for GCP cloud | ||
| type VisorImageConfig struct { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PackerConfig ? |
||
| Builders []GcpConfig `json:"builders"` | ||
| } | ||
|
|
||
| // GetName returns the name of the virtual machine. | ||
| func (vm *VM) GetName() string { | ||
| return vm.Name | ||
| } | ||
|
|
||
| // Creates a visor image config required for packer | ||
| func (vm *VM) CreateVisorImageConfig(accountFile, packerConf string) ([]byte, error) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we return only the gcp builder here and merge where we are dumping this in a file (c3ntry) ? |
||
| var vig VisorImageConfig | ||
| var conf GcpConfig | ||
|
|
||
| conf.ImageName = vm.Name | ||
| conf.AccountFile = accountFile | ||
| conf.Zone = vm.Zone | ||
| conf.SourceImage = vm.SourceImage | ||
| conf.ProjectID = vm.Project | ||
| conf.Type = "googlecompute" | ||
| conf.StartupScript = packerConf | ||
| conf.SSHUsername = "apporbit" | ||
|
|
||
| vig.Builders = append(vig.Builders, conf) | ||
|
|
||
| return json.Marshal(vig) | ||
| } | ||
|
|
||
| // Provision creates a virtual machine on GCE. It returns an error if | ||
| // there was a problem during creation. | ||
| func (vm *VM) Provision() error { | ||
|
|
@@ -524,6 +562,7 @@ func (vm *VM) GetZoneList() ([]Zone, error) { | |
| Region: regionName, | ||
| Status: zone.Status, | ||
| }) | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. delete extra line. |
||
| } | ||
|
|
||
| return response, nil | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any specific reason to expose the struct ?