From 0b60fae6310c9dba0fef967715570146154b2476 Mon Sep 17 00:00:00 2001 From: Carlos Lapao Date: Wed, 8 Nov 2023 19:38:20 +0000 Subject: [PATCH] fixed the packer template machine --- src/controllers/machines.go | 9 +++++---- src/serviceprovider/parallelsdesktop/main.go | 4 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/controllers/machines.go b/src/controllers/machines.go index 9b0bedb..a38d372 100644 --- a/src/controllers/machines.go +++ b/src/controllers/machines.go @@ -555,10 +555,11 @@ func CreateMachine() restapi.Controller { template.Name = request.Name template.Owner = request.Owner - template.Specs["memory"] = request.PackerTemplate.Memory - if err != nil { - ReturnApiError(ctx, w, models.NewFromError(err)) - return + if request.PackerTemplate.Cpu != "" { + template.Specs["cpu"] = request.PackerTemplate.Cpu + } + if request.PackerTemplate.Memory != "" { + template.Specs["memory"] = request.PackerTemplate.Memory } parallelsDesktopService := provider.ParallelsDesktopService diff --git a/src/serviceprovider/parallelsdesktop/main.go b/src/serviceprovider/parallelsdesktop/main.go index ad7e8dc..36fd5b3 100644 --- a/src/serviceprovider/parallelsdesktop/main.go +++ b/src/serviceprovider/parallelsdesktop/main.go @@ -748,7 +748,9 @@ func (s *ParallelsService) CreatePackerTemplateVm(ctx basecontext.ApiContext, te ctx.LogInfo("Creating Packer Virtual Machine %s", template.Name) existVm, err := s.findVm(ctx, template.Name) if existVm != nil || err != nil { - return nil, errors.Newf("Machine %v with ID %v already exists and is %s", template.Name, existVm.ID, existVm.State) + if errors.GetSystemErrorCode(err) != 404 { + return nil, errors.Newf("Machine %v with ID %v already exists and is %s", template.Name, existVm.ID, existVm.State) + } } git := git.Get()