Skip to content

Commit

Permalink
enhancement(tpm): support for bare metal secure boot and tpm
Browse files Browse the repository at this point in the history
  • Loading branch information
uibm committed Feb 15, 2023
1 parent 4122741 commit 368722f
Show file tree
Hide file tree
Showing 8 changed files with 273 additions and 62 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/IBM/continuous-delivery-go-sdk v1.0.4
github.com/IBM/event-notifications-go-admin-sdk v0.1.7
github.com/IBM/eventstreams-go-sdk v1.2.0
github.com/IBM/go-sdk-core/v5 v5.10.2
github.com/IBM/go-sdk-core/v5 v5.12.0
github.com/IBM/ibm-cos-sdk-go v1.9.0
github.com/IBM/ibm-cos-sdk-go-config v1.2.0
github.com/IBM/ibm-hpcs-tke-sdk v0.0.0-20211109141421-a4b61b05f7d1
Expand All @@ -28,7 +28,7 @@ require (
github.com/IBM/scc-go-sdk/v4 v4.0.2
github.com/IBM/schematics-go-sdk v0.2.1
github.com/IBM/secrets-manager-go-sdk v0.1.19
github.com/IBM/vpc-go-sdk v0.30.0
github.com/IBM/vpc-go-sdk v0.31.0
github.com/ScaleFT/sshkeys v0.0.0-20200327173127-6142f742bca5
github.com/Shopify/sarama v1.29.1
github.com/apache/openwhisk-client-go v0.0.0-20200201143223-a804fb82d105
Expand Down
11 changes: 4 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/IBM-Cloud/bluemix-go v0.0.0-20230120122421-afb48116b8f1 h1:5cVMU5MglJjwzoBsDOk3yuH6T/1EeDZyYbQDowL4nW8=
github.com/IBM-Cloud/bluemix-go v0.0.0-20230120122421-afb48116b8f1/go.mod h1:cO5KCpiop9eP/pM/5W07TprYUkv/kHtajW1FiZgE59k=
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20220922071204-21813161c36f h1:VMMqaAUXrNQH84ba/EDbfe8lvQJF9FBUnaQbIa1iKZ0=
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20220922071204-21813161c36f/go.mod h1:xUQL9SGAjoZFd4GNjrjjtEpjpkgU7RFXRyHesbKTjiY=
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20230118060037-101bda076037 h1:C1gOsj2A5ouRUXrmKHebXjs4FXRE8ApMUC3GBUpd9Co=
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20230118060037-101bda076037/go.mod h1:xUQL9SGAjoZFd4GNjrjjtEpjpkgU7RFXRyHesbKTjiY=
github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.5.3/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs=
Expand All @@ -59,8 +57,6 @@ github.com/IBM/container-registry-go-sdk v0.0.15 h1:sfEXm4qNj9ZCwTlFOsdjF5P/lvaj
github.com/IBM/container-registry-go-sdk v0.0.15/go.mod h1:KqSZFO4VIK9QAyF8O1JW6jkyzkfE/BNKUIo+OdzIDk4=
github.com/IBM/continuous-delivery-go-sdk v1.0.4 h1:Qq6EG4dMyX6tD2HhNaMihFFEeoKXjQl2iLz3PWfyw6g=
github.com/IBM/continuous-delivery-go-sdk v1.0.4/go.mod h1:/pSji7d4POPVd1tQA9CLrNT1XMsCJMGLqOtTwXbWAdE=
github.com/IBM/event-notifications-go-admin-sdk v0.1.2 h1:LLA12WFqSD0+Uf16SNdErcu2MVK4EnyXHJmDIkKkudE=
github.com/IBM/event-notifications-go-admin-sdk v0.1.2/go.mod h1:VCtV/cAN8qSPeWEjIWeXOQGTq6LCWP9yZEk7wt3g0HM=
github.com/IBM/event-notifications-go-admin-sdk v0.1.7 h1:PkgkYzPAd3f6jhzV89oVwQoNS6oQg/82cy2JMWO2UzA=
github.com/IBM/event-notifications-go-admin-sdk v0.1.7/go.mod h1:Lh4dp5FaW1hB5FEm2oWKqxjbCz9WonZMisNkKiVgnnE=
github.com/IBM/eventstreams-go-sdk v1.2.0 h1:eP0afHArMGjwhGqvZAhhu/3EDKRch2JehpveqF1TUjs=
Expand All @@ -77,8 +73,9 @@ github.com/IBM/go-sdk-core/v5 v5.7.0/go.mod h1:+YbdhrjCHC84ls4MeBp+Hj4NZCni+tDAc
github.com/IBM/go-sdk-core/v5 v5.8.0/go.mod h1:+YbdhrjCHC84ls4MeBp+Hj4NZCni+tDAc0XQUqRO9Jc=
github.com/IBM/go-sdk-core/v5 v5.9.2/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV0j68/rlZsE=
github.com/IBM/go-sdk-core/v5 v5.9.5/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV0j68/rlZsE=
github.com/IBM/go-sdk-core/v5 v5.10.2 h1:bfqhYNwwpJ3zJQSYpF3umhmRIKaa762itvJkTAWCCLU=
github.com/IBM/go-sdk-core/v5 v5.10.2/go.mod h1:WZPFasUzsKab/2mzt29xPcfruSk5js2ywAPwW4VJjdI=
github.com/IBM/go-sdk-core/v5 v5.12.0 h1:S7sSYQUe0f/xLh87ubwoXWQeUmRCwDNUv3qB4LMC0SI=
github.com/IBM/go-sdk-core/v5 v5.12.0/go.mod h1:WZPFasUzsKab/2mzt29xPcfruSk5js2ywAPwW4VJjdI=
github.com/IBM/ibm-cos-sdk-go v1.3.1/go.mod h1:YLBAYobEA8bD27P7xpMwSQeNQu6W3DNBtBComXrRzRY=
github.com/IBM/ibm-cos-sdk-go v1.9.0 h1:kXTLB9GBwks3+YZopYz/eRbdyeVl2BXFALeqtQ8Duoc=
github.com/IBM/ibm-cos-sdk-go v1.9.0/go.mod h1:Oi8AC5WNDhmUJgbo1GL2FtBdo0nRgbzE/1HmCL1SERU=
Expand All @@ -104,8 +101,8 @@ github.com/IBM/schematics-go-sdk v0.2.1 h1:byATysGD+Z1k/wdtNqQmKALcAPjgSLuSyzcab
github.com/IBM/schematics-go-sdk v0.2.1/go.mod h1:Tw2OSAPdpC69AxcwoyqcYYaGTTW6YpERF9uNEU+BFRQ=
github.com/IBM/secrets-manager-go-sdk v0.1.19 h1:0GPs5EoTaWNsjo4QPj64GNxlWfN8VHJy4RDFLqddSe8=
github.com/IBM/secrets-manager-go-sdk v0.1.19/go.mod h1:eO3dBhzPrHkkt+yPex/jB2xD6qHZxBko+Aw+0tfqHeA=
github.com/IBM/vpc-go-sdk v0.30.0 h1:OCHTcU6j4tFmpoW/SJD58UjfmtuPz9SvRxc5V9qBY8g=
github.com/IBM/vpc-go-sdk v0.30.0/go.mod h1:jYjS3EySPkC7DuOg33gMHtm8DcIf75Tc+Gxo3zmMBTQ=
github.com/IBM/vpc-go-sdk v0.31.0 h1:MFF9dtuKQMVqBvsaDMpR5SKxVuvWyOCfY74lCdg5aAA=
github.com/IBM/vpc-go-sdk v0.31.0/go.mod h1:jYjS3EySPkC7DuOg33gMHtm8DcIf75Tc+Gxo3zmMBTQ=
github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56 h1:vuquMR410psHNax14XKNWa0Ae/kYgWJcXi0IFuX60N0=
github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56/go.mod h1:Zb3OT4l0mf7P/GOs2w2Ilj5sdm5Whoq3pa24dAEBHFc=
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
Expand Down
42 changes: 42 additions & 0 deletions ibm/service/vpc/data_source_ibm_is_bare_metal_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,31 @@ func DataSourceIBMIsBareMetalServer() *schema.Resource {
Computed: true,
Description: "The total bandwidth (in megabits per second)",
},
isBareMetalServerEnableSecureBoot: {
Type: schema.TypeBool,
Computed: true,
Description: "Indicates whether secure boot is enabled. If enabled, the image must support secure boot or the server will fail to boot.",
},

isBareMetalServerTrustedPlatformModule: {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
// isBareMetalServerTrustedPlatformModuleEnabled: {
// Type: schema.TypeBool,
// Computed: true,
// Description: "Indicates whether the trusted platform module (TPM) is enabled. If enabled, `mode` will also be set.",
// },
isBareMetalServerTrustedPlatformModuleMode: {
Type: schema.TypeString,
Computed: true,
Description: "The mode for the trusted platform module (TPM):- `tpm_2`: Standard TPM 2 capabilities- `tpm_2_with_txt`: Standard TPM 2 with Intel Trusted Execution Technology (TXT)The enumerated values for this property are expected to expand in the future. When processing this property, check for and log unknown values. Optionally halt processing and surface the error, or bypass the resource on which the unexpected property value was encountered.",
},
},
},
},

isBareMetalServerBootTarget: {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -505,6 +530,23 @@ func dataSourceIBMISBareMetalServerRead(context context.Context, d *schema.Resou
if err = d.Set("identifier", *bms.ID); err != nil {
return diag.FromErr(fmt.Errorf("[ERROR] Error setting identifier: %s", err))
}

//enable secure boot
if err = d.Set(isBareMetalServerEnableSecureBoot, bms.EnableSecureBoot); err != nil {
return diag.FromErr(fmt.Errorf("[ERROR] Error setting enable_secure_boot: %s", err))
}

// tpm
if bms.TrustedPlatformModule != nil {
trustedPlatformModuleMap, err := resourceIBMIsBareMetalServerBareMetalServerTrustedPlatformModulePrototypeToMap(bms.TrustedPlatformModule)
if err != nil {
return diag.FromErr(err)
}
if err = d.Set(isBareMetalServerTrustedPlatformModule, []map[string]interface{}{trustedPlatformModuleMap}); err != nil {
return diag.FromErr(fmt.Errorf("[ERROR] Error setting trusted_platform_module: %s", err))
}
}

//pni

if bms.PrimaryNetworkInterface != nil {
Expand Down
39 changes: 39 additions & 0 deletions ibm/service/vpc/data_source_ibm_is_bare_metal_servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,30 @@ func DataSourceIBMIsBareMetalServers() *schema.Resource {
Computed: true,
Description: "The total bandwidth (in megabits per second)",
},
isBareMetalServerEnableSecureBoot: {
Type: schema.TypeBool,
Computed: true,
Description: "Indicates whether secure boot is enabled. If enabled, the image must support secure boot or the server will fail to boot.",
},

isBareMetalServerTrustedPlatformModule: {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
// isBareMetalServerTrustedPlatformModuleEnabled: {
// Type: schema.TypeBool,
// Computed: true,
// Description: "Indicates whether the trusted platform module (TPM) is enabled. If enabled, `mode` will also be set.",
// },
isBareMetalServerTrustedPlatformModuleMode: {
Type: schema.TypeString,
Computed: true,
Description: "The mode for the trusted platform module (TPM):- `tpm_2`: Standard TPM 2 capabilities- `tpm_2_with_txt`: Standard TPM 2 with Intel Trusted Execution Technology (TXT)The enumerated values for this property are expected to expand in the future. When processing this property, check for and log unknown values. Optionally halt processing and surface the error, or bypass the resource on which the unexpected property value was encountered.",
},
},
},
},
isBareMetalServerBootTarget: {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -527,6 +551,21 @@ func dataSourceIBMISBareMetalServersRead(context context.Context, d *schema.Reso
l[isBareMetalServerHref] = *bms.Href
l[isBareMetalServerMemory] = *bms.Memory
l[isBareMetalServerProfile] = *bms.Profile.Name

//enable secure boot
if bms.EnableSecureBoot != nil {
l[isBareMetalServerEnableSecureBoot] = bms.EnableSecureBoot
}

// tpm
if bms.TrustedPlatformModule != nil {
trustedPlatformModuleMap, err := resourceIBMIsBareMetalServerBareMetalServerTrustedPlatformModulePrototypeToMap(bms.TrustedPlatformModule)
if err != nil {
return diag.FromErr(err)
}
l[isBareMetalServerTrustedPlatformModule] = []map[string]interface{}{trustedPlatformModuleMap}
}

//pni

if bms.PrimaryNetworkInterface != nil && bms.PrimaryNetworkInterface.ID != nil {
Expand Down
Loading

0 comments on commit 368722f

Please sign in to comment.