diff --git a/internal/cli/host.go b/internal/cli/host.go index 30676128..413d85f0 100644 --- a/internal/cli/host.go +++ b/internal/cli/host.go @@ -163,6 +163,16 @@ orch-cli set host host-1234abcd --project some-project --amt-state provisioned --amt-state - Set desired AMT state of host to provisioned|unprovisioned +#Set host AMT Control Mode to admin control mode +orch-cli set host host-1234abcd --project some-project --control-mode admin + +--control-mode - Set desired AMT control mode of host to admin|client + +#Set host AMT DNS suffix +orch-cli set host host-1234abcd --project some-project --dns-suffix example.com + +--dns-suffix - Set desired AMT DNS suffix of host + # Generate CSV input file using the --generate-csv flag - the default output will be a base test.csv file. orch-cli set host --project some-project --generate-csv @@ -173,11 +183,16 @@ orch-cli set host --project some-project --generate-csv=myhosts.csv Name - Name of the machine - mandatory field ResourceID - Unique Identifier of host - mandatory field -DesiredAmtState - Desired AMT state of host - provisioned|unprovisioned - mandatory field +DesiredAmtState - Desired AMT state of host - provisioned|unprovisioned - mandatory field or AMT_STATE_PROVISIONED|AMT_STATE_UNPROVISIONED +ControlMode - Desired AMT control mode of host - admin|client - optional field or AMT_CONTROL_MODE_ADMIN|AMT_CONTROL_MODE_CLIENT +DnsSuffix - Desired AMT DNS suffix of host - optional field -Name,ResourceID,DesiredAmtState +Name,ResourceID,DesiredAmtState,ControlMode,DnsSuffix host-1,host-1234abcd,provisioned +Name,ResourceID,DesiredAmtState,ControlMode,DnsSuffix +host-1,host-1234abcd,provisioned,admin,example.com + # --dry-run allows for verification of the validity of the input csv file without updating hosts orch-cli set host --project some-project --import-from-csv test.csv --dry-run @@ -265,12 +280,21 @@ func filterRegionsHelper(r string) (*string, error) { // Prints Host list in tabular format func printHosts(writer io.Writer, hosts *[]infra.HostResource, verbose bool) { - if verbose { - fmt.Fprintf(writer, "\n%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", "Resource ID", "Name", "Host Status", "Provisioning Status", - "Serial Number", "Operating System", "Site ID", "Site Name", "Workload", "Host ID", "UUID", "Processor", "Available Update", "Trusted Compute") + if isFeatureEnabled(ProvisioningFeature) { + if verbose { + fmt.Fprintf(writer, "\n%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", "Resource ID", "Name", "Host Status", "Provisioning Status", + "Serial Number", "Operating System", "Site ID", "Site Name", "Workload", "Host ID", "UUID", "Processor", "Available Update", "Trusted Compute") + } else { + var shortHeader = fmt.Sprintf("\n%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s", "Resource ID", "Name", "Host Status", "Provisioning Status", "Serial Number", "Operating System", "Site ID", "Site Name", "Workload") + fmt.Fprintf(writer, "%s\n", shortHeader) + } } else { - var shortHeader = fmt.Sprintf("\n%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s", "Resource ID", "Name", "Host Status", "Provisioning Status", "Serial Number", "Operating System", "Site ID", "Site Name", "Workload") - fmt.Fprintf(writer, "%s\n", shortHeader) + if verbose { + fmt.Fprintf(writer, "\n%s\t%s\t%s\t%s\t%s\t%s\n", "Resource ID", "Name", "Host Status", "Serial Number", "Host ID", "UUID") + } else { + var shortHeader = fmt.Sprintf("\n%s\t%s\t%s\t%s", "Resource ID", "Name", "Host Status", "Serial Number") + fmt.Fprintf(writer, "%s\n", shortHeader) + } } for _, h := range *hosts { //TODO clean this up @@ -305,19 +329,26 @@ func printHosts(writer io.Writer, hosts *[]infra.HostResource, verbose bool) { if h.Instance != nil && h.Instance.ProvisioningStatus != nil { provStat = *h.Instance.ProvisioningStatus } + if isFeatureEnabled(ProvisioningFeature) { + if !verbose { + fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%v\t%v\t%v\t%v\t%v\n", safeString(h.ResourceId), h.Name, host, provStat, safeString(h.SerialNumber), os, site, siteName, workload) + } else { + avupdt := "No update" + tcomp := "Not compatible" - if !verbose { - fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%v\t%v\t%v\t%v\t%v\n", *h.ResourceId, h.Name, host, provStat, *h.SerialNumber, os, site, siteName, workload) - } else { - avupdt := "No update" - tcomp := "Not compatible" + if h.Instance != nil && h.Instance.OsUpdateAvailable != nil && *h.Instance.OsUpdateAvailable != "" { + avupdt = "Available" + } - if h.Instance != nil && h.Instance.OsUpdateAvailable != nil && *h.Instance.OsUpdateAvailable != "" { - avupdt = "Available" + fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n", safeString(h.ResourceId), h.Name, host, provStat, safeString(h.SerialNumber), + os, site, siteName, workload, h.Name, safeString(h.Uuid), safeString(h.CpuModel), avupdt, tcomp) + } + } else { + if !verbose { + fmt.Fprintf(writer, "%s\t%s\t%s\t%v\n", safeString(h.ResourceId), h.Name, host, safeString(h.SerialNumber)) + } else { + fmt.Fprintf(writer, "%s\t%s\t%s\t%v\t%v\t%v\n", safeString(h.ResourceId), h.Name, host, safeString(h.SerialNumber), h.Name, safeString(h.Uuid)) } - - fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n", *h.ResourceId, h.Name, host, provStat, *h.SerialNumber, - os, site, siteName, workload, h.Name, *h.Uuid, *h.CpuModel, avupdt, tcomp) } } } @@ -349,7 +380,7 @@ func printHost(writer io.Writer, host *infra.HostResource) { osprofile = toJSON(host.Instance.Os.Name) } - if *host.HostStatus != "" { + if safeString(host.HostStatus) != "" { // Only display 'Waiting on node agents' when HostStatus is 'error' (case-insensitive), Instance is not nil, and InstanceStatusDetail contains 'of 10 components running' if strings.EqualFold(*host.HostStatus, "error") && host.Instance != nil && host.Instance.InstanceStatusDetail != nil && strings.Contains(*host.Instance.InstanceStatusDetail, "of 10 components running") { hoststatus = "Waiting on node agents" @@ -377,7 +408,7 @@ func printHost(writer io.Writer, host *infra.HostResource) { } if host.Instance != nil && host.Instance.UpdatePolicy != nil { - osupdatepolicy = *host.Instance.UpdatePolicy.ResourceId + osupdatepolicy = safeString(host.Instance.UpdatePolicy.ResourceId) } if host.HostNics != nil && len(*host.HostNics) > 0 { @@ -395,237 +426,295 @@ func printHost(writer io.Writer, host *infra.HostResource) { } _, _ = fmt.Fprintf(writer, "Host Info: \n\n") - _, _ = fmt.Fprintf(writer, "-\tHost Resource ID:\t %s\n", *host.ResourceId) + _, _ = fmt.Fprintf(writer, "-\tHost Resource ID:\t %s\n", safeString(host.ResourceId)) _, _ = fmt.Fprintf(writer, "-\tName:\t %s\n", host.Name) - _, _ = fmt.Fprintf(writer, "-\tOS Profile:\t %v\n", osprofile) - _, _ = fmt.Fprintf(writer, "-\tNIC Name and IP Address:\t %v\n", ip) - _, _ = fmt.Fprintf(writer, "-\tLVM Size:\t %v\n\n", lvmsize) - - _, _ = fmt.Fprintf(writer, "Status details: \n\n") + if isFeatureEnabled(ProvisioningFeature) { + _, _ = fmt.Fprintf(writer, "-\tOS Profile:\t %v\n", osprofile) + _, _ = fmt.Fprintf(writer, "-\tNIC Name and IP Address:\t %v\n", ip) + _, _ = fmt.Fprintf(writer, "-\tLVM Size:\t %v\n", lvmsize) + } + _, _ = fmt.Fprintf(writer, "\nStatus details: \n\n") _, _ = fmt.Fprintf(writer, "-\tHost Status:\t %s\n", hoststatus) _, _ = fmt.Fprintf(writer, "-\tHost Status Details:\t %s\n", hostdetails) - _, _ = fmt.Fprintf(writer, "-\tProvisioning Status:\t %s\n", provstatus) - _, _ = fmt.Fprintf(writer, "-\tUpdate Status:\t %s\n", updatestatus) - _, _ = fmt.Fprintf(writer, "-\tOS Update Policy:\t %s\n\n", osupdatepolicy) - - _, _ = fmt.Fprintf(writer, "Specification: \n\n") - _, _ = fmt.Fprintf(writer, "-\tSerial Number:\t %s\n", *host.SerialNumber) - _, _ = fmt.Fprintf(writer, "-\tUUID:\t %s\n", *host.Uuid) - _, _ = fmt.Fprintf(writer, "-\tOS:\t %v\n", currentOS) - _, _ = fmt.Fprintf(writer, "-\tBIOS Vendor:\t %v\n", *host.BiosVendor) - _, _ = fmt.Fprintf(writer, "-\tProduct Name:\t %v\n\n", *host.ProductName) - - _, _ = fmt.Fprintf(writer, "Customizations: \n\n") - _, _ = fmt.Fprintf(writer, "-\tCustom configs:\t %s\n\n", customcfg) - - _, _ = fmt.Fprintf(writer, "CPU Info: \n\n") - _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\n", "Model", "Cores", "Architecture", "Threads", "Sockets") - _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\n", "-----", "-----", "------------", "-------", "-------") - _, _ = fmt.Fprintf(writer, "%v\t%v\t%v\t%v\t%v\n\n", *host.CpuModel, *host.CpuCores, *host.CpuArchitecture, *host.CpuThreads, *host.CpuSockets) - - _, _ = fmt.Fprintf(writer, "Memory Info: \n\n") - _, _ = fmt.Fprintf(writer, "%s\n", "Total (GB)") - _, _ = fmt.Fprintf(writer, "%s\n", "-------------") - if host.MemoryBytes != nil { - memoryBytes, err := strconv.ParseInt(*host.MemoryBytes, 10, 64) - if err != nil { - _, _ = fmt.Fprintf(writer, "%v\n\n", "Error parsing memory") - } else { - memoryGB := float64(memoryBytes) / (1024 * 1024 * 1024) - memoryGBRounded := int(memoryGB + 0.5) // Round up to nearest integer - _, _ = fmt.Fprintf(writer, "%d\n\n", memoryGBRounded) - } + if isFeatureEnabled(ProvisioningFeature) { + _, _ = fmt.Fprintf(writer, "-\tProvisioning Status:\t %s\n", provstatus) + _, _ = fmt.Fprintf(writer, "-\tUpdate Status:\t %s\n", updatestatus) + _, _ = fmt.Fprintf(writer, "-\tOS Update Policy:\t %s\n", osupdatepolicy) } + _, _ = fmt.Fprintf(writer, "\nSpecification: \n\n") + _, _ = fmt.Fprintf(writer, "-\tSerial Number:\t %s\n", safeString(host.SerialNumber)) + _, _ = fmt.Fprintf(writer, "-\tUUID:\t %s\n", safeString(host.Uuid)) + if isFeatureEnabled(ProvisioningFeature) { + _, _ = fmt.Fprintf(writer, "-\tOS:\t %v\n", currentOS) + _, _ = fmt.Fprintf(writer, "-\tBIOS Vendor:\t %v\n", safeString(host.BiosVendor)) + _, _ = fmt.Fprintf(writer, "-\tProduct Name:\t %v\n\n", safeString(host.ProductName)) + + _, _ = fmt.Fprintf(writer, "Customizations: \n\n") + _, _ = fmt.Fprintf(writer, "-\tCustom configs:\t %s\n\n", customcfg) + + _, _ = fmt.Fprintf(writer, "CPU Info: \n\n") + _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\n", "Model", "Cores", "Architecture", "Threads", "Sockets") + _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\n", "-----", "-----", "------------", "-------", "-------") + _, _ = fmt.Fprintf(writer, "%v\t%v\t%v\t%v\t%v\n\n", + safeString(host.CpuModel), + safeInt(host.CpuCores), + safeString(host.CpuArchitecture), + safeInt(host.CpuThreads), + safeInt(host.CpuSockets)) + + _, _ = fmt.Fprintf(writer, "Memory Info: \n\n") + _, _ = fmt.Fprintf(writer, "%s\n", "Total (GB)") + _, _ = fmt.Fprintf(writer, "%s\n", "-------------") + if host.MemoryBytes != nil { + memoryBytes, err := strconv.ParseInt(*host.MemoryBytes, 10, 64) + if err != nil { + _, _ = fmt.Fprintf(writer, "%v\n\n", "Error parsing memory") + } else { + memoryGB := float64(memoryBytes) / (1024 * 1024 * 1024) + memoryGBRounded := int(memoryGB + 0.5) // Round up to nearest integer + _, _ = fmt.Fprintf(writer, "%d\n\n", memoryGBRounded) + } + } - _, _ = fmt.Fprintf(writer, "Storage Info: \n\n") - _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\n", "WWID", "Capacity", "Model", "Serial", "Vendor") - _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\n", "----", "--------", "-----", "------", "------") - if host.HostStorages != nil { - for _, storage := range *host.HostStorages { - wwid := "N/A" - capacity := "N/A" - model := "N/A" - serial := "N/A" - vendor := "N/A" + _, _ = fmt.Fprintf(writer, "Storage Info: \n\n") + _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\n", "WWID", "Capacity", "Model", "Serial", "Vendor") + _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\n", "----", "--------", "-----", "------", "------") + if host.HostStorages != nil { + for _, storage := range *host.HostStorages { + wwid := "N/A" + capacity := "N/A" + model := "N/A" + serial := "N/A" + vendor := "N/A" - if storage.Wwid != nil { - wwid = *storage.Wwid - } - if storage.CapacityBytes != nil { - capacityBytes, err := strconv.ParseInt(*storage.CapacityBytes, 10, 64) - if err != nil { - capacity = "Parse Error" - } else { - capacityGB := capacityBytes / (1024 * 1024 * 1024) - capacity = fmt.Sprintf("%d GB", capacityGB) + if storage.Wwid != nil { + wwid = *storage.Wwid + } + if storage.CapacityBytes != nil { + capacityBytes, err := strconv.ParseInt(*storage.CapacityBytes, 10, 64) + if err != nil { + capacity = "Parse Error" + } else { + capacityGB := capacityBytes / (1024 * 1024 * 1024) + capacity = fmt.Sprintf("%d GB", capacityGB) + } + } + if storage.Model != nil { + model = *storage.Model + } + if storage.Serial != nil { + serial = *storage.Serial + } + if storage.Vendor != nil { + vendor = *storage.Vendor } - } - if storage.Model != nil { - model = *storage.Model - } - if storage.Serial != nil { - serial = *storage.Serial - } - if storage.Vendor != nil { - vendor = *storage.Vendor - } - _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\n", wwid, capacity, model, serial, vendor) + _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\n", wwid, capacity, model, serial, vendor) + } + _, _ = fmt.Fprintf(writer, "\n") } - _, _ = fmt.Fprintf(writer, "\n") - } - _, _ = fmt.Fprintf(writer, "GPU Info: \n\n") - _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\n", "Device", "Vendor", "Capabilities", "PCI Address") - _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\n", "------", "------", "------------", "-----------") + _, _ = fmt.Fprintf(writer, "GPU Info: \n\n") + _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\n", "Device", "Vendor", "Capabilities", "PCI Address") + _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\n", "------", "------", "------------", "-----------") - if host.HostGpus != nil { - for _, gpu := range *host.HostGpus { - model := "N/A" - vendor := "N/A" - capabilities := "N/A" - pciAddress := "N/A" + if host.HostGpus != nil { + for _, gpu := range *host.HostGpus { + model := "N/A" + vendor := "N/A" + capabilities := "N/A" + pciAddress := "N/A" - if gpu.DeviceName != nil { - model = *gpu.DeviceName - } - if gpu.Vendor != nil { - vendor = *gpu.Vendor - } - if gpu.Capabilities != nil { - capabilities = strings.Join(*gpu.Capabilities, ",") - } - if gpu.PciId != nil { - pciAddress = *gpu.PciId + if gpu.DeviceName != nil { + model = *gpu.DeviceName + } + if gpu.Vendor != nil { + vendor = *gpu.Vendor + } + if gpu.Capabilities != nil { + capabilities = strings.Join(*gpu.Capabilities, ",") + } + if gpu.PciId != nil { + pciAddress = *gpu.PciId + } + _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\n", model, vendor, capabilities, pciAddress) + } + _, _ = fmt.Fprintf(writer, "\n") + } + _, _ = fmt.Fprintf(writer, "USB Info: \n\n") + _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\t%s\n", "Class", "Serial", "Vendor ID", "Product ID", "Bus", "Address") + _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\t%s\n", "-----", "------", "---------", "----------", "---", "-------") + if host.HostUsbs != nil { + for _, usb := range *host.HostUsbs { + class := "N/A" + serial := "N/A" + vendorID := "N/A" + productID := "N/A" + bus := "N/A" + address := "N/A" + + if usb.Class != nil && *usb.Class != "" { + class = *usb.Class + } + if usb.Serial != nil { + serial = *usb.Serial + } + if usb.IdVendor != nil { + vendorID = *usb.IdVendor + } + if usb.IdProduct != nil { + productID = *usb.IdProduct + } + if usb.Bus != nil { + bus = strconv.Itoa(*usb.Bus) + } + if usb.Addr != nil { + address = strconv.Itoa(*usb.Addr) + } + _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\t%s\n", class, serial, vendorID, productID, bus, address) } - _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\n", model, vendor, capabilities, pciAddress) + _, _ = fmt.Fprintf(writer, "\n") } - _, _ = fmt.Fprintf(writer, "\n") - } - _, _ = fmt.Fprintf(writer, "USB Info: \n\n") - _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\t%s\n", "Class", "Serial", "Vendor ID", "Product ID", "Bus", "Address") - _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\t%s\n", "-----", "------", "---------", "----------", "---", "-------") - if host.HostUsbs != nil { - for _, usb := range *host.HostUsbs { - class := "N/A" - serial := "N/A" - vendorID := "N/A" - productID := "N/A" - bus := "N/A" - address := "N/A" - if usb.Class != nil && *usb.Class != "" { - class = *usb.Class - } - if usb.Serial != nil { - serial = *usb.Serial - } - if usb.IdVendor != nil { - vendorID = *usb.IdVendor - } - if usb.IdProduct != nil { - productID = *usb.IdProduct - } - if usb.Bus != nil { - bus = strconv.Itoa(*usb.Bus) - } - if usb.Addr != nil { - address = strconv.Itoa(*usb.Addr) - } - _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\t%s\n", class, serial, vendorID, productID, bus, address) - } - _, _ = fmt.Fprintf(writer, "\n") - } + _, _ = fmt.Fprintf(writer, "Interfaces Info: \n\n") + _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", "Name", "Links State", "MTU", "MAC Address", "PCI Identifier", "SRIOV", "SRIOV VF Total", "SRIOV VF Number", "BMC Interface ") + _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", "----", "-----", "------", "---------", "----------", "---", "-------", "------------", "--------------") - _, _ = fmt.Fprintf(writer, "Interfaces Info: \n\n") - _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", "Name", "Links State", "MTU", "MAC Address", "PCI Identifier", "SRIOV", "SRIOV VF Total", "SRIOV VF Number", "BMC Interface ") - _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", "----", "-----", "------", "---------", "----------", "---", "-------", "------------", "--------------") + if host.HostNics != nil { + for _, nic := range *host.HostNics { + name := "N/A" + linksStatus := "N/A" + mtu := "N/A" + macAddress := "N/A" + pciID := "N/A" + sriov := "N/A" + sriovVFTotal := "N/A" + sriovVFNum := "N/A" + bmcInterface := "N/A" - if host.HostNics != nil { - for _, nic := range *host.HostNics { - name := "N/A" - linksStatus := "N/A" - mtu := "N/A" - macAddress := "N/A" - pciID := "N/A" - sriov := "N/A" - sriovVFTotal := "N/A" - sriovVFNum := "N/A" - bmcInterface := "N/A" - - if nic.DeviceName != nil { - name = *nic.DeviceName - } - if nic.LinkState != nil { - if string(*nic.LinkState.Type) == "NETWORK_INTERFACE_LINK_STATE_DOWN" { - linksStatus = "DOWN" + if nic.DeviceName != nil { + name = *nic.DeviceName } - if string(*nic.LinkState.Type) == "NETWORK_INTERFACE_LINK_STATE_UP" { - linksStatus = "UP" + if nic.LinkState != nil { + if string(*nic.LinkState.Type) == "NETWORK_INTERFACE_LINK_STATE_DOWN" { + linksStatus = "DOWN" + } + if string(*nic.LinkState.Type) == "NETWORK_INTERFACE_LINK_STATE_UP" { + linksStatus = "UP" + } + if string(*nic.LinkState.Type) == "NETWORK_INTERFACE_LINK_STATE_UNSPECIFIED" { + linksStatus = "UNSPECIFIED" + } } - if string(*nic.LinkState.Type) == "NETWORK_INTERFACE_LINK_STATE_UNSPECIFIED" { - linksStatus = "UNSPECIFIED" + if nic.Mtu != nil { + mtu = strconv.Itoa(*nic.Mtu) } + if nic.MacAddr != nil { + macAddress = *nic.MacAddr + } + if nic.PciIdentifier != nil { + pciID = *nic.PciIdentifier + } + if nic.SriovEnabled != nil { + sriov = strconv.FormatBool(*nic.SriovEnabled) + } + if nic.SriovVfsTotal != nil && nic.SriovEnabled != nil && *nic.SriovEnabled { + sriovVFTotal = strconv.Itoa(*nic.SriovVfsTotal) + } + if nic.SriovVfsNum != nil && nic.SriovEnabled != nil && *nic.SriovEnabled { + sriovVFNum = strconv.Itoa(*nic.SriovVfsNum) + } + if nic.BmcInterface != nil { + bmcInterface = strconv.FormatBool(*nic.BmcInterface) + } + _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", name, linksStatus, mtu, macAddress, pciID, sriov, sriovVFTotal, sriovVFNum, bmcInterface) } - if nic.Mtu != nil { - mtu = strconv.Itoa(*nic.Mtu) - } - if nic.MacAddr != nil { - macAddress = *nic.MacAddr - } - if nic.PciIdentifier != nil { - pciID = *nic.PciIdentifier - } - if nic.SriovEnabled != nil { - sriov = strconv.FormatBool(*nic.SriovEnabled) - } - if nic.SriovVfsTotal != nil && nic.SriovEnabled != nil && *nic.SriovEnabled { - sriovVFTotal = strconv.Itoa(*nic.SriovVfsTotal) - } - if nic.SriovVfsNum != nil && nic.SriovEnabled != nil && *nic.SriovEnabled { - sriovVFNum = strconv.Itoa(*nic.SriovVfsNum) - } - if nic.BmcInterface != nil { - bmcInterface = strconv.FormatBool(*nic.BmcInterface) - } - _, _ = fmt.Fprintf(writer, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", name, linksStatus, mtu, macAddress, pciID, sriov, sriovVFTotal, sriovVFNum, bmcInterface) + _, _ = fmt.Fprintf(writer, "\n") } - _, _ = fmt.Fprintf(writer, "\n") - } - if host.Instance != nil && host.Instance.ExistingCves != nil && host.Instance.Os != nil && host.Instance.Os.FixedCves != nil { + if host.Instance != nil && host.Instance.ExistingCves != nil && host.Instance.Os != nil && host.Instance.Os.FixedCves != nil { - if *host.Instance.ExistingCves != "" { - err := json.Unmarshal([]byte(*host.Instance.ExistingCves), &cveEntries) - if err != nil { - fmt.Println("Error unmarshaling JSON: existing CVE entries:", err) - return + if *host.Instance.ExistingCves != "" { + err := json.Unmarshal([]byte(*host.Instance.ExistingCves), &cveEntries) + if err != nil { + fmt.Println("Error unmarshaling JSON: existing CVE entries:", err) + return + } } - } - _, _ = fmt.Fprintf(writer, "CVE Info (existing CVEs): \n\n") - for _, cve := range cveEntries { - _, _ = fmt.Fprintf(writer, "-\tCVE ID:\t %v\n", cve.CVEID) - _, _ = fmt.Fprintf(writer, "-\tPriority:\t %v\n", cve.Priority) - _, _ = fmt.Fprintf(writer, "-\tAffected Packages:\t %v\n\n", cve.AffectedPackages) + _, _ = fmt.Fprintf(writer, "CVE Info (existing CVEs): \n\n") + for _, cve := range cveEntries { + _, _ = fmt.Fprintf(writer, "-\tCVE ID:\t %v\n", cve.CVEID) + _, _ = fmt.Fprintf(writer, "-\tPriority:\t %v\n", cve.Priority) + _, _ = fmt.Fprintf(writer, "-\tAffected Packages:\t %v\n", cve.AffectedPackages) + } } } + currentAmtState := "N/A" + if host.CurrentAmtState != nil { + currentAmtState = fmt.Sprintf("%v", *host.CurrentAmtState) + } + desiredAmtState := "N/A" + if host.DesiredAmtState != nil { + desiredAmtState = fmt.Sprintf("%v", *host.DesiredAmtState) + } + + amtControlMode := "N/A" + if host.AmtControlMode != nil { + amtControlMode = fmt.Sprintf("%v", *host.AmtControlMode) + } + dnsSuffix := "N/A" + if host.AmtDnsSuffix != nil { + dnsSuffix = fmt.Sprintf("%v", *host.AmtDnsSuffix) + } + + _, _ = fmt.Fprintf(writer, "\nAMT Info: \n\n") + _, _ = fmt.Fprintf(writer, "-\tAMT Status:\t %v\n", currentAmtState) + _, _ = fmt.Fprintf(writer, "-\tAMT Desired State :\t %v\n", desiredAmtState) + _, _ = fmt.Fprintf(writer, "-\tAMT Desired Control Mode:\t %v\n", amtControlMode) + _, _ = fmt.Fprintf(writer, "-\tAMT Desired DNS Suffix:\t %v\n", dnsSuffix) + if host.CurrentAmtState != nil && *host.CurrentAmtState == infra.AMTSTATEPROVISIONED { - _, _ = fmt.Fprintf(writer, "AMT Info: \n\n") - _, _ = fmt.Fprintf(writer, "-\tAMT Status:\t %v\n", *host.CurrentAmtState) - _, _ = fmt.Fprintf(writer, "-\tCurrent Power Status:\t %v\n", *host.CurrentPowerState) - _, _ = fmt.Fprintf(writer, "-\tDesired Power Status:\t %v\n", *host.DesiredPowerState) - _, _ = fmt.Fprintf(writer, "-\tPower Command Policy :\t %v\n", *host.PowerCommandPolicy) + currentPower := "N/A" + if host.CurrentPowerState != nil { + currentPower = fmt.Sprintf("%v", *host.CurrentPowerState) + } + desiredPower := "N/A" + if host.DesiredPowerState != nil { + desiredPower = fmt.Sprintf("%v", *host.DesiredPowerState) + } + powerPolicy := "N/A" + if host.PowerCommandPolicy != nil { + powerPolicy = fmt.Sprintf("%v", *host.PowerCommandPolicy) + } powerOnTimeStr := "N/A" if host.PowerOnTime != nil { powerOnTime := time.Unix(int64(*host.PowerOnTime), 0) powerOnTimeStr = powerOnTime.UTC().Format(time.RFC3339) } + + _, _ = fmt.Fprintf(writer, "-\tCurrent Power Status:\t %v\n", currentPower) + _, _ = fmt.Fprintf(writer, "-\tDesired Power Status:\t %v\n", desiredPower) + _, _ = fmt.Fprintf(writer, "-\tPower Command Policy :\t %v\n", powerPolicy) _, _ = fmt.Fprintf(writer, "-\tPowerOn Time :\t %v\n", powerOnTimeStr) - _, _ = fmt.Fprintf(writer, "-\tDesired AMT State :\t %v\n", *host.DesiredAmtState) - } - if host.CurrentAmtState != nil && *host.CurrentAmtState != infra.AMTSTATEPROVISIONED { + if host.HostDevice != nil { + _, _ = fmt.Fprintf(writer, "-\tBuild Number:\t %v\n", safeString(host.HostDevice.BuildNumber)) + _, _ = fmt.Fprintf(writer, "-\tControl Mode:\t %v\n", safeString(host.HostDevice.ControlMode)) + _, _ = fmt.Fprintf(writer, "-\tDevice GUID:\t %v\n", safeString(host.HostDevice.DeviceGuid)) + _, _ = fmt.Fprintf(writer, "-\tDevice DNS Suffix:\t %v\n", safeString(host.HostDevice.DnsSuffix)) + _, _ = fmt.Fprintf(writer, "-\tFeatures:\t %v\n", safeString(host.HostDevice.Features)) + _, _ = fmt.Fprintf(writer, "-\tHostname:\t %v\n", safeString(host.HostDevice.Hostname)) + _, _ = fmt.Fprintf(writer, "-\tMPS Hostname:\t %v\n", safeString(host.HostDevice.MpsHostname)) + _, _ = fmt.Fprintf(writer, "-\tNetwork Status:\t %v\n", safeString(host.HostDevice.NetworkStatus)) + _, _ = fmt.Fprintf(writer, "-\tOperational State:\t %v\n", safeString(host.HostDevice.OperationalState)) + _, _ = fmt.Fprintf(writer, "-\tRemote Status:\t %v\n", safeString(host.HostDevice.RemoteStatus)) + _, _ = fmt.Fprintf(writer, "-\tRemote Trigger:\t %v\n", safeString(host.HostDevice.RemoteTrigger)) + _, _ = fmt.Fprintf(writer, "-\tDevice SKU:\t %v\n", safeString(host.HostDevice.Sku)) + _, _ = fmt.Fprintf(writer, "-\tVersion:\t %v\n", safeString(host.HostDevice.Version)) + } + + } else if host.CurrentAmtState != nil && *host.CurrentAmtState != infra.AMTSTATEPROVISIONED { _, _ = fmt.Fprintf(writer, "AMT not active and/or not supported: No info available \n\n") } @@ -1376,6 +1465,8 @@ func getSetHostCommand() *cobra.Command { cmd.PersistentFlags().StringP("power", "r", viper.GetString("power"), "Power on|off|cycle|hibernate|reset|sleep") cmd.PersistentFlags().StringP("power-policy", "c", viper.GetString("power-policy"), "Set power policy immediate|ordered") cmd.PersistentFlags().StringP("amt-state", "a", viper.GetString("amt-state"), "Set AMT state ") + cmd.PersistentFlags().StringP("dns-suffix", "s", viper.GetString("dns-suffix"), "Set AMT DNS suffix ") + cmd.PersistentFlags().StringP("control-mode", "m", viper.GetString("control-mode"), "Set AMT control mode client|admin") } if isFeatureEnabled(Day2Feature) { cmd.PersistentFlags().StringP("osupdatepolicy", "u", viper.GetString("osupdatepolicy"), "Set OS update policy ") @@ -1809,6 +1900,8 @@ func runSetHostCommand(cmd *cobra.Command, args []string) error { powerFlag, _ := cmd.Flags().GetString("power") updFlag, _ := cmd.Flags().GetString("osupdatepolicy") amtFlag, _ := cmd.Flags().GetString("amt-state") + amtModeFlag, _ := cmd.Flags().GetString("control-mode") + dnsSuffixFlag, _ := cmd.Flags().GetString("dns-suffix") // Bulk CSV generation if generateCSV != "" { @@ -1853,18 +1946,26 @@ func runSetHostCommand(cmd *cobra.Command, args []string) error { return err } defer f.Close() - fmt.Fprintln(f, "Name,ResourceID,DesiredAmtState") + fmt.Fprintln(f, "Name,ResourceID,DesiredAmtState,ControlMode,DnsSuffix") for _, h := range hosts { name := h.Name resourceID := "" desiredAmtState := "" + controlMode := "" + dnsSuffix := "" if h.ResourceId != nil { resourceID = *h.ResourceId } if h.DesiredAmtState != nil { desiredAmtState = string(*h.DesiredAmtState) } - fmt.Fprintf(f, "%s,%s,%s\n", name, resourceID, desiredAmtState) + if h.AmtControlMode != nil { + controlMode = string(*h.AmtControlMode) + } + if h.AmtDnsSuffix != nil { + dnsSuffix = *h.AmtDnsSuffix + } + fmt.Fprintf(f, "%s,%s,%s,%s,%s\n", name, resourceID, desiredAmtState, controlMode, dnsSuffix) } fmt.Printf("CSV template generated: %s\n", generateCSV) return nil @@ -1890,15 +1991,36 @@ func runSetHostCommand(cmd *cobra.Command, args []string) error { fmt.Printf("Skipping invalid line %d: %s\n", lineNum, line) continue } + desiredControlMode := "" + desiredDNSSuffix := "" name := strings.TrimSpace(fields[0]) resourceID := strings.TrimSpace(fields[1]) desiredAmtState := strings.TrimSpace(fields[2]) + if len(fields) >= 4 { + desiredControlMode = strings.TrimSpace(fields[3]) + } + if len(fields) >= 5 { + desiredDNSSuffix = strings.TrimSpace(fields[4]) + } // Validate desiredAmtState amtState, err := resolveAmtState(desiredAmtState) if err != nil { fmt.Printf("Invalid AMT state for host %s: %s\n", name, desiredAmtState) continue } + var amtMode *infra.AmtControlMode + var dnsSuffix *string + if desiredControlMode != "" { + mode, err := resolveAmtControlMode(desiredControlMode) + if err != nil { + fmt.Printf("Invalid control mode for host %s: %s\n", name, desiredControlMode) + continue + } + amtMode = &mode + } + if desiredDNSSuffix != "" { + dnsSuffix = &desiredDNSSuffix + } // Patch host ctx, hostClient, projectName, err := InfraFactory(cmd) if err != nil { @@ -1907,6 +2029,9 @@ func runSetHostCommand(cmd *cobra.Command, args []string) error { } resp, err := hostClient.HostServicePatchHostWithResponse(ctx, projectName, resourceID, &infra.HostServicePatchHostParams{}, infra.HostServicePatchHostJSONRequestBody{ DesiredAmtState: &amtState, + AmtControlMode: amtMode, + AmtDnsSuffix: dnsSuffix, + Name: name, }, auth.AddAuthHeader) if err != nil { fmt.Printf("Failed to patch host %s: %v\n", name, err) @@ -1929,7 +2054,7 @@ func runSetHostCommand(cmd *cobra.Command, args []string) error { } hostID := args[0] - if (policyFlag == "" || strings.HasPrefix(policyFlag, "--")) && (powerFlag == "" || strings.HasPrefix(powerFlag, "--")) && updFlag == "" && (amtFlag == "" || strings.HasPrefix(amtFlag, "--")) { + if (policyFlag == "" || strings.HasPrefix(policyFlag, "--")) && (powerFlag == "" || strings.HasPrefix(powerFlag, "--")) && updFlag == "" && (amtFlag == "" || strings.HasPrefix(amtFlag, "--")) && (amtModeFlag == "" || strings.HasPrefix(amtModeFlag, "--")) && (dnsSuffixFlag == "" || strings.HasPrefix(dnsSuffixFlag, "--")) { return errors.New("a flag must be provided with the set host command and value cannot be \"\"") } @@ -1937,6 +2062,8 @@ func runSetHostCommand(cmd *cobra.Command, args []string) error { var policy *infra.PowerCommandPolicy var updatePolicy *string var amtState *infra.AmtState + var amtMode *infra.AmtControlMode + var dnsSuffix *string if policyFlag != "" { pol, err := resolvePowerPolicy(policyFlag) @@ -1966,6 +2093,18 @@ func runSetHostCommand(cmd *cobra.Command, args []string) error { amtState = &amt } + if amtModeFlag != "" { + mode, err := resolveAmtControlMode(amtModeFlag) + if err != nil { + return err + } + amtMode = &mode + } + + if dnsSuffixFlag != "" { + dnsSuffix = &dnsSuffixFlag + } + ctx, hostClient, projectName, err := InfraFactory(cmd) if err != nil { return err @@ -1981,7 +2120,7 @@ func runSetHostCommand(cmd *cobra.Command, args []string) error { } host := *iresp.JSON200 - if (powerFlag != "" || policyFlag != "") && host.Instance != nil { + if (powerFlag != "" || policyFlag != "") && host.CurrentAmtState != nil && *host.CurrentAmtState == infra.AMTSTATEPROVISIONED { resp, err := hostClient.HostServicePatchHostWithResponse(ctx, projectName, hostID, &infra.HostServicePatchHostParams{}, infra.HostServicePatchHostJSONRequestBody{ PowerCommandPolicy: policy, DesiredPowerState: power, @@ -1993,6 +2132,8 @@ func runSetHostCommand(cmd *cobra.Command, args []string) error { if err := checkResponse(resp.HTTPResponse, resp.Body, "error while executing host set for AMT"); err != nil { return err } + } else if (powerFlag != "" || policyFlag != "") && host.CurrentAmtState != nil && *host.CurrentAmtState != infra.AMTSTATEPROVISIONED { + return fmt.Errorf("host %s does not seem to have AMT enabled, power toggle and policy not supported", hostID) } if updatePolicy != nil && host.Instance != nil && host.Instance.InstanceID != nil && updFlag != "" { @@ -2007,9 +2148,11 @@ func runSetHostCommand(cmd *cobra.Command, args []string) error { } } - if amtState != nil && host.Instance != nil { + if amtState != nil || amtMode != nil || dnsSuffix != nil { resp, err := hostClient.HostServicePatchHostWithResponse(ctx, projectName, hostID, &infra.HostServicePatchHostParams{}, infra.HostServicePatchHostJSONRequestBody{ DesiredAmtState: amtState, + AmtControlMode: amtMode, + AmtDnsSuffix: dnsSuffix, Name: host.Name, }, auth.AddAuthHeader) if err != nil { @@ -2729,3 +2872,14 @@ func resolveAmtState(amt string) (infra.AmtState, error) { return "", errors.New("incorrect AMT state provided with --amt-state flag use one of provisioned|unprovisioned") } } + +func resolveAmtControlMode(mode string) (infra.AmtControlMode, error) { + switch mode { + case "admin", "AMT_CONTROL_MODE_ACM": + return infra.AMTCONTROLMODEACM, nil + case "client", "AMT_CONTROL_MODE_CCM": + return infra.AMTCONTROLMODECCM, nil + default: + return "", errors.New("incorrect AMT control mode provided with --control-mode flag use one of admin|client") + } +} diff --git a/internal/cli/host_test.go b/internal/cli/host_test.go index 4722851f..d8ed1beb 100644 --- a/internal/cli/host_test.go +++ b/internal/cli/host_test.go @@ -414,11 +414,26 @@ func (s *CLITestSuite) TestHost() { "eth0": "UNSPECIFIED |1500 |30:d0:42:d9:02:7c |0000:19:00.0 |true |8 |4 |true", "AMT Info:": "", "- AMT Status:": "AMT_STATE_PROVISIONED", + "- AMT Desired State :": "AMT_STATE_PROVISIONED", + "- AMT Desired Control Mode:": "AMT_CONTROL_MODE_CCM", + "- AMT Desired DNS Suffix:": "example.com", "- Current Power Status:": "POWER_STATE_ON", "- Desired Power Status:": "POWER_STATE_ON", "- Power Command Policy :": "POWER_COMMAND_POLICY_ALWAYS_ON", "- PowerOn Time :": "2025-12-03T08:25:13Z", - "- Desired AMT State :": "AMT_STATE_PROVISIONED", + "- Build Number:": "3000", + "- Control Mode:": "admin", + "- Device GUID:": "4c4c4544-0000-1111-8053-b7c04f564d31", + "- Device DNS Suffix:": "example.com", + "- Features:": "AMT,KVM,SOL", + "- Hostname:": "edge-host-001", + "- MPS Hostname:": "mps.example.com", + "- Network Status:": "connected", + "- Operational State:": "enabled", + "- Remote Status:": "connected", + "- Remote Trigger:": "user", + "- Device SKU:": "16392", + "- Version:": "16.1.25", } s.compareGetOutput(expectedOutput, parsedOutput) diff --git a/internal/cli/mocks/infra/infra_mock.go b/internal/cli/mocks/infra/infra_mock.go index ec51810f..331fc047 100644 --- a/internal/cli/mocks/infra/infra_mock.go +++ b/internal/cli/mocks/infra/infra_mock.go @@ -604,8 +604,26 @@ func CreateInfraMock(mctrl *gomock.Controller, timestamp time.Time) interfaces.I CurrentAmtState: (*infra.AmtState)(stringPtr("AMT_STATE_PROVISIONED")), DesiredAmtState: (*infra.AmtState)(stringPtr("AMT_STATE_PROVISIONED")), DesiredPowerState: (*infra.PowerState)(stringPtr("POWER_STATE_ON")), + AmtControlMode: (*infra.AmtControlMode)(stringPtr("AMT_CONTROL_MODE_CCM")), + AmtDnsSuffix: stringPtr("example.com"), + AmtSku: (*infra.AmtSku)(stringPtr("SKU")), PowerCommandPolicy: (*infra.PowerCommandPolicy)(stringPtr("POWER_COMMAND_POLICY_ALWAYS_ON")), PowerOnTime: func() *int { i := 1764750313; return &i }(), + HostDevice: &infra.HostdeviceResource{ + BuildNumber: stringPtr("3000"), + ControlMode: stringPtr("admin"), + DeviceGuid: stringPtr("4c4c4544-0000-1111-8053-b7c04f564d31"), + DnsSuffix: stringPtr("example.com"), + Features: stringPtr("AMT,KVM,SOL"), + Hostname: stringPtr("edge-host-001"), + MpsHostname: stringPtr("mps.example.com"), + NetworkStatus: stringPtr("connected"), + OperationalState: stringPtr("enabled"), + RemoteStatus: stringPtr("connected"), + RemoteTrigger: stringPtr("user"), + Sku: stringPtr("16392"), + Version: stringPtr("16.1.25"), + }, HostNics: &[]infra.HostnicResource{ { DeviceName: stringPtr("eth0"), diff --git a/internal/cli/utils.go b/internal/cli/utils.go index 51e59756..260a65a7 100644 --- a/internal/cli/utils.go +++ b/internal/cli/utils.go @@ -734,3 +734,16 @@ func isCommandDisabledWithParent(parentCmd *cobra.Command, subCmd string) bool { parentName := parentCmd.Name() return isCommandDisabled(parentName, subCmd) } + +func safeString(s *string) string { + if s == nil { + return "" + } + return *s +} +func safeInt(s *int) int { + if s == nil { + return 0 + } + return *s +} diff --git a/pkg/rest/infra/amc-infra-core-edge-infrastructure-manager-openapi-all.yaml b/pkg/rest/infra/amc-infra-core-edge-infrastructure-manager-openapi-all.yaml index 573d3702..d5ae25d8 100644 --- a/pkg/rest/infra/amc-infra-core-edge-infrastructure-manager-openapi-all.yaml +++ b/pkg/rest/infra/amc-infra-core-edge-infrastructure-manager-openapi-all.yaml @@ -15947,6 +15947,13 @@ components: $ref: '#/components/schemas/google.protobuf.Timestamp' title: Timestamps additionalProperties: false + AmtControlMode: + type: string + title: AmtControlMode + enum: + - AMT_CONTROL_MODE_UNSPECIFIED + - AMT_CONTROL_MODE_ACM + - AMT_CONTROL_MODE_CCM AmtSku: type: string title: AmtSku @@ -16222,6 +16229,11 @@ components: title: host_gpus description: Back-reference to attached host GPU resources. readOnly: true + hostDevice: + title: host_device + description: Back-reference to attached host vPRO support resources. + readOnly: true + $ref: '#/components/schemas/HostdeviceResource' instance: title: instance description: The instance associated with the host. @@ -16262,6 +16274,15 @@ components: title: user_lvm_size description: LVM size in GB. readOnly: true + amtControlMode: + title: amt_control_mode + description: (OPTIONAL) coming from user selection + $ref: '#/components/schemas/AmtControlMode' + amtDnsSuffix: + type: string + title: amt_dns_suffix + maxLength: 1024 + description: (OPTIONAL) textual message that describes dns_suffix for ACM mode. siteId: type: string title: site_id @@ -16303,6 +16324,77 @@ components: - HOST_STATE_UNTRUSTED - HOST_STATE_REGISTERED description: States of the host. + HostdeviceResource: + type: object + properties: + version: + type: string + title: version + description: Version number of AMT on the host. + readOnly: true + hostname: + type: string + title: hostname + description: Host name of the host. + readOnly: true + operationalState: + type: string + title: operational_state + description: Operational state of AMT on the host, either enabled or disabled. + readOnly: true + buildNumber: + type: string + title: build_number + description: Build Number of AMT on the host. + readOnly: true + sku: + type: string + title: sku + description: Integer number of the SKU of the host. + readOnly: true + features: + type: string + title: features + description: AMT features available on host. + readOnly: true + deviceGuid: + type: string + title: device_guid + description: Unique device ID for host. + readOnly: true + controlMode: + type: string + title: control_mode + description: Control mode selected for vPRO on host, either client or admin. + readOnly: true + dnsSuffix: + type: string + title: dns_suffix + description: DNS Suffix for the host. + readOnly: true + networkStatus: + type: string + title: network_status + description: Networking status for RAS on host. + readOnly: true + remoteStatus: + type: string + title: remote_status + description: Remote connection status for RAS on host. + readOnly: true + remoteTrigger: + type: string + title: remote_trigger + description: Trigger for enabling remote connection for RAS on host. + readOnly: true + mpsHostname: + type: string + title: mps_hostname + description: Host name for MPS instance remotely connected to host. + readOnly: true + title: HostdeviceResource + additionalProperties: false + description: The vPRO support details of host. HostgpuResource: type: object properties: diff --git a/pkg/rest/infra/types.go b/pkg/rest/infra/types.go index c20da2a4..64ba580f 100644 --- a/pkg/rest/infra/types.go +++ b/pkg/rest/infra/types.go @@ -7,6 +7,13 @@ import ( "time" ) +// Defines values for AmtControlMode. +const ( + AMTCONTROLMODEACM AmtControlMode = "AMT_CONTROL_MODE_ACM" + AMTCONTROLMODECCM AmtControlMode = "AMT_CONTROL_MODE_CCM" + AMTCONTROLMODEUNSPECIFIED AmtControlMode = "AMT_CONTROL_MODE_UNSPECIFIED" +) + // Defines values for AmtSku. const ( AMTSKUAMT AmtSku = "AMT_SKU_AMT" @@ -190,6 +197,9 @@ const ( WORKLOADMEMBERKINDUNSPECIFIED WorkloadMemberKind = "WORKLOAD_MEMBER_KIND_UNSPECIFIED" ) +// AmtControlMode defines model for AmtControlMode. +type AmtControlMode string + // AmtSku defines model for AmtSku. type AmtSku string @@ -307,7 +317,11 @@ type HostRegister struct { // HostResource A Host resource. type HostResource struct { - AmtSku *AmtSku `json:"amtSku,omitempty"` + AmtControlMode *AmtControlMode `json:"amtControlMode,omitempty"` + + // AmtDnsSuffix (OPTIONAL) textual message that describes dns_suffix for ACM mode. + AmtDnsSuffix *string `json:"amtDnsSuffix,omitempty"` + AmtSku *AmtSku `json:"amtSku,omitempty"` // AmtStatus coming from device introspection. Set only by the DM RM. AmtStatus *string `json:"amtStatus,omitempty"` @@ -372,6 +386,9 @@ type HostResource struct { // DesiredState States of the host. DesiredState *HostState `json:"desiredState,omitempty"` + // HostDevice The vPRO support details of host. + HostDevice *HostdeviceResource `json:"hostDevice,omitempty"` + // HostGpus Back-reference to attached host GPU resources. HostGpus *[]HostgpuResource `json:"hostGpus,omitempty"` @@ -477,6 +494,48 @@ type HostResource struct { // HostState States of the host. type HostState string +// HostdeviceResource The vPRO support details of host. +type HostdeviceResource struct { + // BuildNumber Build Number of AMT on the host. + BuildNumber *string `json:"buildNumber,omitempty"` + + // ControlMode Control mode selected for vPRO on host, either client or admin. + ControlMode *string `json:"controlMode,omitempty"` + + // DeviceGuid Unique device ID for host. + DeviceGuid *string `json:"deviceGuid,omitempty"` + + // DnsSuffix DNS Suffix for the host. + DnsSuffix *string `json:"dnsSuffix,omitempty"` + + // Features AMT features available on host. + Features *string `json:"features,omitempty"` + + // Hostname Host name of the host. + Hostname *string `json:"hostname,omitempty"` + + // MpsHostname Host name for MPS instance remotely connected to host. + MpsHostname *string `json:"mpsHostname,omitempty"` + + // NetworkStatus Networking status for RAS on host. + NetworkStatus *string `json:"networkStatus,omitempty"` + + // OperationalState Operational state of AMT on the host, either enabled or disabled. + OperationalState *string `json:"operationalState,omitempty"` + + // RemoteStatus Remote connection status for RAS on host. + RemoteStatus *string `json:"remoteStatus,omitempty"` + + // RemoteTrigger Trigger for enabling remote connection for RAS on host. + RemoteTrigger *string `json:"remoteTrigger,omitempty"` + + // Sku Integer number of the SKU of the host. + Sku *string `json:"sku,omitempty"` + + // Version Version number of AMT on the host. + Version *string `json:"version,omitempty"` +} + // HostgpuResource The set of available host GPU cards. type HostgpuResource struct { // Capabilities The features of this GPU device, comma separated.