public static Vm UpdatedVM(Common.Vm commonVm) { if (commonVm == null) { throw new System.ArgumentNullException(); } var vm = new Vm { Id = commonVm.Id, Comment = JsonConvert.SerializeObject(new CommentClass { Admin = commonVm.Admin?.Sam, Manager = commonVm.Manager?.Sam, Owner = commonVm.Owner?.Sam, Domain = commonVm.Domain, Project = commonVm.Project, Services = commonVm.Services, AuditDate = commonVm.AuditDate, Deadline = commonVm.Deadline }), Memory = (double)commonVm.MemoryGb * KB_IN_GB }; return(vm); }
public static Vm CreatedVM(Common.Vm commonVm) { var device = new List <string> { "hd" }; var vM = new Vm(); if (commonVm != null) { double memoryKiB = (double)commonVm.MemoryGb * KB_IN_GB; vM = new Vm { Id = commonVm.Id, Name = $"{commonVm.Cluster.ShortName}-{commonVm.PoolShortName}-{commonVm.Name}", Memory = memoryKiB, MemoryPolicy = new MemoryPolicy { Max = memoryKiB }, Os = new Os { Boot = new Boot { Devices = new Devices { Device = device } } }, Cpu = new Cpu { Topology = new Topology { Sockets = commonVm.Cpu, Cores = 1, Threads = 1 } }, Template = commonVm.Template != null ? new Template { Name = commonVm.Template?.Name } : null, Cluster = new Cluster { Name = commonVm.Cluster.Name }, Comment = JsonConvert.SerializeObject(new CommentClass { Admin = commonVm.Admin?.Sam, Manager = commonVm.Manager?.Sam, Owner = commonVm.Owner?.Sam, Domain = commonVm.Domain, Project = commonVm.Project, Services = commonVm.Services, AuditDate = commonVm.AuditDate, Deadline = commonVm.Deadline }) }; } return(vM); }