Skip to content

Commit

Permalink
support deploying cpu-only servers
Browse files Browse the repository at this point in the history
  • Loading branch information
caguiclajmg committed Jun 27, 2022
1 parent 185e8cb commit e364195
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
5 changes: 3 additions & 2 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ type DeployServerRequest struct {
AdminUser string `mapstructure:"admin_user"`
AdminPass string `mapstructure:"admin_pass"`
InstanceType string `mapstructure:"instance_type"`
GPUModel string `mapstructure:"gpu_model"`
GPUCount int `mapstructure:"gpu_count"`
GPUModel string `mapstructure:"gpu_model,omitempty"`
GPUCount int `mapstructure:"gpu_count,omitempty"`
CPUModel string `mapstructure:"cpu_model,omitempty"`
VCPUs int `mapstructure:"vcpus"`
RAM int `mapstructure:"ram"`
Storage int `mapstructure:"storage"`
Expand Down
24 changes: 20 additions & 4 deletions commands/servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func init() {
deployCmd.Flags().String("location", "na-us-chi-1", "Location")
deployCmd.Flags().String("instanceType", "gpu", "Either \"gpu\" or \"cpu\"")
deployCmd.Flags().Int("gpuCount", 1, "The number of GPUs of the model you specified earlier")
deployCmd.Flags().String("cpuModel", "Intel_Xeon_v4", "The CPU model that you would like to provision")
deployCmd.Flags().Int("vcpus", 2, "Number of vCPUs that you would like")
deployCmd.Flags().Int("storage", 20, "Number of GB of networked storage")
deployCmd.Flags().String("storageClass", "io1", "io1 or st1, depending on storage class desired")
Expand Down Expand Up @@ -224,6 +225,11 @@ func deployServer(cmd *cobra.Command, args []string) error {
return err
}

cpuModel, err := flags.GetString("cpuModel")
if err != nil {
return err
}

vcpus, err := flags.GetInt("vcpus")
if err != nil {
return err
Expand Down Expand Up @@ -258,20 +264,30 @@ func deployServer(cmd *cobra.Command, args []string) error {
adminUser := args[1]
adminPass := args[2]

res, err := client.DeployServer(api.DeployServerRequest{
req := api.DeployServerRequest{
AdminUser: adminUser,
AdminPass: adminPass,
InstanceType: instanceType,
GPUModel: gpuModel,
GPUCount: gpuCount,
VCPUs: vcpus,
RAM: ram,
Storage: storage,
StorageClass: storageClass,
OS: os,
Location: location,
Name: name,
})
}

switch instanceType {
case "cpu":
req.CPUModel = cpuModel
case "gpu":
req.GPUModel = gpuModel
req.GPUCount = gpuCount
default:
return errors.New("unknown instance type")
}

res, err := client.DeployServer(req)

if err != nil {
return err
Expand Down

0 comments on commit e364195

Please sign in to comment.