From 5de1a954112c1ee72074f1b3fb9123c46466180a Mon Sep 17 00:00:00 2001 From: zhangli Date: Tue, 21 Nov 2023 14:24:03 +0800 Subject: [PATCH] feat: LMGR-656: Creating lpar failed due to cryptoConfigration field in request body Signed-off-by: zhangli --- pkg/zhmcclient/fakes/lpar.go | 20 ++++----- pkg/zhmcclient/fakes/zhmc.go | 20 ++++----- pkg/zhmcclient/lpar.go | 8 ++-- pkg/zhmcclient/model.go | 87 +++++++++++++++++++++++++++++++++++- pkg/zhmcclient/zhmc.go | 2 +- 5 files changed, 111 insertions(+), 26 deletions(-) diff --git a/pkg/zhmcclient/fakes/lpar.go b/pkg/zhmcclient/fakes/lpar.go index c8445c2..88b8550 100644 --- a/pkg/zhmcclient/fakes/lpar.go +++ b/pkg/zhmcclient/fakes/lpar.go @@ -111,18 +111,18 @@ type LparAPI struct { result2 int result3 *zhmcclient.HmcError } - GetLparPropertiesStub func(string) (*zhmcclient.LparProperties, int, *zhmcclient.HmcError) + GetLparPropertiesStub func(string) (*zhmcclient.LparObjectProperties, int, *zhmcclient.HmcError) getLparPropertiesMutex sync.RWMutex getLparPropertiesArgsForCall []struct { arg1 string } getLparPropertiesReturns struct { - result1 *zhmcclient.LparProperties + result1 *zhmcclient.LparObjectProperties result2 int result3 *zhmcclient.HmcError } getLparPropertiesReturnsOnCall map[int]struct { - result1 *zhmcclient.LparProperties + result1 *zhmcclient.LparObjectProperties result2 int result3 *zhmcclient.HmcError } @@ -696,7 +696,7 @@ func (fake *LparAPI) GetEnergyDetailsforLPARReturnsOnCall(i int, result1 uint64, }{result1, result2, result3} } -func (fake *LparAPI) GetLparProperties(arg1 string) (*zhmcclient.LparProperties, int, *zhmcclient.HmcError) { +func (fake *LparAPI) GetLparProperties(arg1 string) (*zhmcclient.LparObjectProperties, int, *zhmcclient.HmcError) { fake.getLparPropertiesMutex.Lock() ret, specificReturn := fake.getLparPropertiesReturnsOnCall[len(fake.getLparPropertiesArgsForCall)] fake.getLparPropertiesArgsForCall = append(fake.getLparPropertiesArgsForCall, struct { @@ -721,7 +721,7 @@ func (fake *LparAPI) GetLparPropertiesCallCount() int { return len(fake.getLparPropertiesArgsForCall) } -func (fake *LparAPI) GetLparPropertiesCalls(stub func(string) (*zhmcclient.LparProperties, int, *zhmcclient.HmcError)) { +func (fake *LparAPI) GetLparPropertiesCalls(stub func(string) (*zhmcclient.LparObjectProperties, int, *zhmcclient.HmcError)) { fake.getLparPropertiesMutex.Lock() defer fake.getLparPropertiesMutex.Unlock() fake.GetLparPropertiesStub = stub @@ -734,30 +734,30 @@ func (fake *LparAPI) GetLparPropertiesArgsForCall(i int) string { return argsForCall.arg1 } -func (fake *LparAPI) GetLparPropertiesReturns(result1 *zhmcclient.LparProperties, result2 int, result3 *zhmcclient.HmcError) { +func (fake *LparAPI) GetLparPropertiesReturns(result1 *zhmcclient.LparObjectProperties, result2 int, result3 *zhmcclient.HmcError) { fake.getLparPropertiesMutex.Lock() defer fake.getLparPropertiesMutex.Unlock() fake.GetLparPropertiesStub = nil fake.getLparPropertiesReturns = struct { - result1 *zhmcclient.LparProperties + result1 *zhmcclient.LparObjectProperties result2 int result3 *zhmcclient.HmcError }{result1, result2, result3} } -func (fake *LparAPI) GetLparPropertiesReturnsOnCall(i int, result1 *zhmcclient.LparProperties, result2 int, result3 *zhmcclient.HmcError) { +func (fake *LparAPI) GetLparPropertiesReturnsOnCall(i int, result1 *zhmcclient.LparObjectProperties, result2 int, result3 *zhmcclient.HmcError) { fake.getLparPropertiesMutex.Lock() defer fake.getLparPropertiesMutex.Unlock() fake.GetLparPropertiesStub = nil if fake.getLparPropertiesReturnsOnCall == nil { fake.getLparPropertiesReturnsOnCall = make(map[int]struct { - result1 *zhmcclient.LparProperties + result1 *zhmcclient.LparObjectProperties result2 int result3 *zhmcclient.HmcError }) } fake.getLparPropertiesReturnsOnCall[i] = struct { - result1 *zhmcclient.LparProperties + result1 *zhmcclient.LparObjectProperties result2 int result3 *zhmcclient.HmcError }{result1, result2, result3} diff --git a/pkg/zhmcclient/fakes/zhmc.go b/pkg/zhmcclient/fakes/zhmc.go index 978d1b4..cf62698 100644 --- a/pkg/zhmcclient/fakes/zhmc.go +++ b/pkg/zhmcclient/fakes/zhmc.go @@ -283,18 +283,18 @@ type ZhmcAPI struct { result2 int result3 *zhmcclient.HmcError } - GetLparPropertiesStub func(string) (*zhmcclient.LparProperties, int, *zhmcclient.HmcError) + GetLparPropertiesStub func(string) (*zhmcclient.LparObjectProperties, int, *zhmcclient.HmcError) getLparPropertiesMutex sync.RWMutex getLparPropertiesArgsForCall []struct { arg1 string } getLparPropertiesReturns struct { - result1 *zhmcclient.LparProperties + result1 *zhmcclient.LparObjectProperties result2 int result3 *zhmcclient.HmcError } getLparPropertiesReturnsOnCall map[int]struct { - result1 *zhmcclient.LparProperties + result1 *zhmcclient.LparObjectProperties result2 int result3 *zhmcclient.HmcError } @@ -1885,7 +1885,7 @@ func (fake *ZhmcAPI) GetLiveEnergyDetailsforLPARReturnsOnCall(i int, result1 uin }{result1, result2, result3} } -func (fake *ZhmcAPI) GetLparProperties(arg1 string) (*zhmcclient.LparProperties, int, *zhmcclient.HmcError) { +func (fake *ZhmcAPI) GetLparProperties(arg1 string) (*zhmcclient.LparObjectProperties, int, *zhmcclient.HmcError) { fake.getLparPropertiesMutex.Lock() ret, specificReturn := fake.getLparPropertiesReturnsOnCall[len(fake.getLparPropertiesArgsForCall)] fake.getLparPropertiesArgsForCall = append(fake.getLparPropertiesArgsForCall, struct { @@ -1910,7 +1910,7 @@ func (fake *ZhmcAPI) GetLparPropertiesCallCount() int { return len(fake.getLparPropertiesArgsForCall) } -func (fake *ZhmcAPI) GetLparPropertiesCalls(stub func(string) (*zhmcclient.LparProperties, int, *zhmcclient.HmcError)) { +func (fake *ZhmcAPI) GetLparPropertiesCalls(stub func(string) (*zhmcclient.LparObjectProperties, int, *zhmcclient.HmcError)) { fake.getLparPropertiesMutex.Lock() defer fake.getLparPropertiesMutex.Unlock() fake.GetLparPropertiesStub = stub @@ -1923,30 +1923,30 @@ func (fake *ZhmcAPI) GetLparPropertiesArgsForCall(i int) string { return argsForCall.arg1 } -func (fake *ZhmcAPI) GetLparPropertiesReturns(result1 *zhmcclient.LparProperties, result2 int, result3 *zhmcclient.HmcError) { +func (fake *ZhmcAPI) GetLparPropertiesReturns(result1 *zhmcclient.LparObjectProperties, result2 int, result3 *zhmcclient.HmcError) { fake.getLparPropertiesMutex.Lock() defer fake.getLparPropertiesMutex.Unlock() fake.GetLparPropertiesStub = nil fake.getLparPropertiesReturns = struct { - result1 *zhmcclient.LparProperties + result1 *zhmcclient.LparObjectProperties result2 int result3 *zhmcclient.HmcError }{result1, result2, result3} } -func (fake *ZhmcAPI) GetLparPropertiesReturnsOnCall(i int, result1 *zhmcclient.LparProperties, result2 int, result3 *zhmcclient.HmcError) { +func (fake *ZhmcAPI) GetLparPropertiesReturnsOnCall(i int, result1 *zhmcclient.LparObjectProperties, result2 int, result3 *zhmcclient.HmcError) { fake.getLparPropertiesMutex.Lock() defer fake.getLparPropertiesMutex.Unlock() fake.GetLparPropertiesStub = nil if fake.getLparPropertiesReturnsOnCall == nil { fake.getLparPropertiesReturnsOnCall = make(map[int]struct { - result1 *zhmcclient.LparProperties + result1 *zhmcclient.LparObjectProperties result2 int result3 *zhmcclient.HmcError }) } fake.getLparPropertiesReturnsOnCall[i] = struct { - result1 *zhmcclient.LparProperties + result1 *zhmcclient.LparObjectProperties result2 int result3 *zhmcclient.HmcError }{result1, result2, result3} diff --git a/pkg/zhmcclient/lpar.go b/pkg/zhmcclient/lpar.go index 888ddd7..213ab72 100644 --- a/pkg/zhmcclient/lpar.go +++ b/pkg/zhmcclient/lpar.go @@ -30,7 +30,7 @@ import ( type LparAPI interface { CreateLPAR(cpcURI string, props *LparProperties) (string, int, *HmcError) ListLPARs(cpcURI string, query map[string]string) ([]LPAR, int, *HmcError) - GetLparProperties(lparURI string) (*LparProperties, int, *HmcError) + GetLparProperties(lparURI string) (*LparObjectProperties, int, *HmcError) UpdateLparProperties(lparURI string, props *LparProperties) (int, *HmcError) StartLPAR(lparURI string) (string, int, *HmcError) StopLPAR(lparURI string) (string, int, *HmcError) @@ -119,10 +119,10 @@ func (m *LparManager) ListLPARs(cpcURI string, query map[string]string) ([]LPAR, /** * GET /api/partitions/{partition-id} * @lparURI is the object-uri -* Return: 200 and LparProperties +* Return: 200 and LparObjectProperties * or: 400, 404, */ -func (m *LparManager) GetLparProperties(lparURI string) (*LparProperties, int, *HmcError) { +func (m *LparManager) GetLparProperties(lparURI string) (*LparObjectProperties, int, *HmcError) { requestUrl := m.client.CloneEndpointURL() requestUrl.Path = path.Join(requestUrl.Path, lparURI) @@ -138,7 +138,7 @@ func (m *LparManager) GetLparProperties(lparURI string) (*LparProperties, int, * } if status == http.StatusOK { - lparProps := LparProperties{} + lparProps := LparObjectProperties{} err := json.Unmarshal(responseBody, &lparProps) if err != nil { return nil, status, getHmcErrorFromErr(ERR_CODE_HMC_UNMARSHAL_FAIL, err) diff --git a/pkg/zhmcclient/model.go b/pkg/zhmcclient/model.go index 80ff285..052c9d9 100644 --- a/pkg/zhmcclient/model.go +++ b/pkg/zhmcclient/model.go @@ -741,7 +741,7 @@ type PartitionFeatureInfo struct { State bool `json:"state,omitempty"` } -type LparProperties struct { +type LparObjectProperties struct { URI string `json:"object-uri,omitempty"` CpcURI string `json:"parent,omitempty"` Class string `json:"class,omitempty"` @@ -826,6 +826,91 @@ type LparProperties struct { Secureboot bool `json:"secure-boot,omitempty"` } +type LparProperties struct { + URI string `json:"object-uri,omitempty"` + CpcURI string `json:"parent,omitempty"` + Class string `json:"class,omitempty"` + Name string `json:"name,omitempty"` + Description string `json:"description,omitempty"` + Status PartitionStatus `json:"status,omitempty"` + Type PartitionType `json:"type,omitempty"` + ShortName string `json:"short-name,omitempty"` + ID string `json:"partition-id,omitempty"` + AutoGenerateID bool `json:"autogenerate-partition-id,omitempty"` + OsName string `json:"os-name,omitempty"` + OsType string `json:"os-type,omitempty"` + OsVersion string `json:"os-version,omitempty"` + ReserveResources bool `json:"reserve-resources,omitempty"` + DegradedAdapters []string `json:"degraded-adapters,omitempty"` + ProcessorMode PartitionProcessorMode `json:"processor-mode,omitempty"` + CpProcessors int `json:"cp-processors,omitempty"` + IflProcessors int `json:"ifl-processors,omitempty"` + IflAbsoluteProcessorCapping bool `json:"ifl-absolute-processor-capping,omitempty"` + CpAbsoluteProcessorCapping bool `json:"cp-absolute-processor-capping,omitempty"` + IflAbsoluteProcessorCappingValue float64 `json:"ifl-absolute-processor-capping-value,omitempty"` + CpAbsoluteProcessorCappingValue float64 `json:"cp-absolute-processor-capping-value,omitempty"` + IflProcessingWeightCapped bool `json:"ifl-processing-weight-capped,omitempty"` + CpProcessingWeightCapped bool `json:"cp-processing-weight-capped,omitempty"` + MinimumIflProcessingWeight int `json:"minimum-ifl-processing-weight,omitempty"` + MinimumCpProcessingWeight int `json:"minimum-cp-processing-weight,omitempty"` + InitialIflProcessingWeight int `json:"initial-ifl-processing-weight,omitempty"` + InitialCpProcessingWeight int `json:"initial-cp-processing-weight,omitempty"` + CurrentIflProcessingWeight int `json:"current-ifl-processing-weight,omitempty"` + CurrentCpProcessingWeight int `json:"current-cp-processing-weight,omitempty"` + MaximumIflProcessingWeight int `json:"maximum-ifl-processing-weight,omitempty"` + MaximumCpProcessingWeight int `json:"maximum-cp-processing-weight,omitempty"` + ProcessorManagementEnabled bool `json:"processor-management-enabled,omitempty"` + InitialMemory int `json:"initial-memory,omitempty"` + ReservedMemory int `json:"reserved-memory,omitempty"` + MaximumMemory int `json:"maximum-memory,omitempty"` + AutoStart bool `json:"auto-start,omitempty"` + BootDevice PartitionBootDevice `json:"boot-device,omitempty"` + BootNetworkDevice string `json:"boot-network-device,omitempty"` + BootFtpHost string `json:"boot-ftp-host,omitempty"` + BootFtpUsername string `json:"boot-ftp-username,omitempty"` + BootFtpPassword string `json:"boot-ftp-password,omitempty"` + BootFtpInsfile string `json:"boot-ftp-insfile,omitempty"` + BootRemovableMedia string `json:"boot-removable-media,omitempty"` + BootRemovableMediaType PartionBootRemovableMediaType `json:"boot-removable-media-type,omitempty"` + BootTimeout int `json:"boot-timeout,omitempty"` + BootStorageDevice string `json:"boot-storage-device,omitempty"` + BootStorageVolume string `json:"boot-storage-volume,omitempty"` + BootLogicalUnitNumber string `json:"boot-logical-unit-number,omitempty"` + BootWorldWidePortName string `json:"boot-world-wide-port-name,omitempty"` + BootConfigurationSelector int `json:"boot-configuration-selector,omitempty"` + BootRecordLba string `json:"boot-record-lba,omitempty"` + BootLoadParameters string `json:"boot-load-parameters,omitempty"` + BootOsSpecificParameters string `json:"boot-os-specific-parameters,omitempty"` + BootIsoImageName string `json:"boot-iso-image-name,omitempty"` + BootIsoInsFile string `json:"boot-iso-ins-file,omitempty"` + AccessGlobalPerformanceData bool `json:"access-global-performance-data,omitempty"` + PermitCrossPartitionCommands bool `json:"permit-cross-partition-commands,omitempty"` + AccessBasicCounterSet bool `json:"access-basic-counter-set,omitempty"` + AccessProblemStateCounterSet bool `json:"access-problem-state-counter-set,omitempty"` + AccessCryptoActivityCounterSet bool `json:"access-crypto-activity-counter-set,omitempty"` + AccessExtendedCounterSet bool `json:"access-extended-counter-set,omitempty"` + AccessCoprocessorGroupSet bool `json:"access-coprocessor-group-set,omitempty"` + AccessBasicSampling bool `json:"access-basic-sampling,omitempty"` + AccessDiagnosticSampling bool `json:"access-diagnostic-sampling,omitempty"` + PermitDesKeyImportFunctions bool `json:"permit-des-key-import-functions,omitempty"` + PermitAesKeyImportFunctions bool `json:"permit-aes-key-import-functions,omitempty"` + ThreadsPerProcessor int `json:"threads-per-processor,omitempty"` + VirtualFunctionUris []string `json:"virtual-function-uris,omitempty"` + NicUris []string `json:"nic-uris,omitempty"` + HbaUris []string `json:"hba-uris,omitempty"` + StorageGroupURIs []string `json:"storage-group-uris,omitempty"` + CryptoConfiguration CryptoConfig `json:"-"` + SscHostName string `json:"ssc-host-name,omitempty"` + SscBootSelection SscBootSelection `json:"ssc-boot-selection,omitempty"` + SscIpv4Gateway string `json:"ssc-ipv4-gateway,omitempty"` + SscIpv6Gateway string `json:"ssc-ipv6-gateway,omitempty"` + SscDnsServers []string `json:"ssc-dns-servers,omitempty"` + SscMasterUserid string `json:"ssc-master-userid,omitempty"` + SscMasterPw string `json:"ssc-master-pw,omitempty"` + AvailableFeaturesList []PartitionFeatureInfo `json:"available-features-list,omitempty"` + Secureboot bool `json:"secure-boot,omitempty"` +} + type StartStopLparResponse struct { URI string `json:"job-uri"` Message string `json:"message"` diff --git a/pkg/zhmcclient/zhmc.go b/pkg/zhmcclient/zhmc.go index 762e429..1b23b1d 100644 --- a/pkg/zhmcclient/zhmc.go +++ b/pkg/zhmcclient/zhmc.go @@ -74,7 +74,7 @@ func (m *ZhmcManager) GetCPCProperties(cpcURI string) (*CPCProperties, int, *Hmc func (m *ZhmcManager) ListLPARs(cpcURI string, query map[string]string) ([]LPAR, int, *HmcError) { return m.lparManager.ListLPARs(cpcURI, query) } -func (m *ZhmcManager) GetLparProperties(lparURI string) (*LparProperties, int, *HmcError) { +func (m *ZhmcManager) GetLparProperties(lparURI string) (*LparObjectProperties, int, *HmcError) { return m.lparManager.GetLparProperties(lparURI) } func (m *ZhmcManager) UpdateLparProperties(lparURI string, props *LparProperties) (int, *HmcError) {