HewlettPackard / oneview-golang

Golang bindings for OneView api's

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CreateProfileFromTemplate not working w OV 5.20

stephan-koch opened this issue · comments

Scenario/Intent

CreateProfileFromTemplate

Environment Details

  • **Golang binding for HPE OneView Version: go version go1.13.11 linux/amd64
  • **OneView SDK Version: latest
  • **OneView Appliance Version: 5.20
  • **OneView Client API Version:1600
  • **Golang Version:go version go1.13.11 linux/amd64
  • **Platform:linux

Steps to Reproduce

package main

import (
"fmt"
"github.com/HewlettPackard/oneview-golang/ov"
//"github.com/HewlettPackard/oneview-golang/utils"
"os"
)

func main() {
var (
ClientOV *ov.OVClient
template_name = "ANSIBLE_OS_Deploy_via_iLO"
profile_name = "Roundtable - API Demo Server"
blade = "CTC H5 HE21, bay 1"

)
ovc := ClientOV.NewOVClient(
    os.Getenv("ONEVIEW_OV_USER"),
    os.Getenv("ONEVIEW_OV_PASSWORD"),
    os.Getenv("ONEVIEW_OV_DOMAIN"),
    os.Getenv("ONEVIEW_OV_ENDPOINT"),
    false,
    1600,
    "")
    
//sort := "name:desc"


spt, err := ovc.GetProfileTemplateByName(template_name)
//fmt.Println(spt)
if err != nil {
    fmt.Println("Server Profile Template Retrieval By Name Failed: ", err)
} else {
    serverName, err := ovc.GetServerHardwareByName(blade)
    if err != nil {
        fmt.Println("Failed to fetch server hardware name: ", err)
    } else {
        err = ovc.CreateProfileFromTemplate(profile_name, spt, serverName)
        if err != nil {
            fmt.Println("Server Profile Create Failed: ", err)
        } else {
            fmt.Println("#----------------Server Profile Created---------------#")
        }
    }
}

}

Output:

Initializing creation of server profile for Roundtable - API Demo Server.
Error submitting new profile request: Error in response: Invalid JSON type.
Response Status: 400 Bad Request
Response Details: The "type" field content, "ServerProfileTemplateV8", included in this request is not valid.
Server Profile Create Failed: Error in response: Invalid JSON type.
Response Status: 400 Bad Request
Response Details: The "type" field content, "ServerProfileTemplateV8", included in this request is not valid.

Expected Result

SP created

Actual Result

Initializing creation of server profile for Roundtable - API Demo Server.
Error submitting new profile request: Error in response: Invalid JSON type.
Response Status: 400 Bad Request
Response Details: The "type" field content, "ServerProfileTemplateV8", included in this request is not valid.
Server Profile Create Failed: Error in response: Invalid JSON type.
Response Status: 400 Bad Request
Response Details: The "type" field content, "ServerProfileTemplateV8", included in this request is not valid.

Workaround:
add lines:
} else if c.APIVersion == 1600 {
new_template.Type = "ServerProfileV12"
in profiles.go" line 325; /usr/lib/golang/src/github.com/HewlettPackard/oneview-golang/ov

with above described "workaround" I am getting an additional error I think because of an SPT with an boot-from-SAN config:

Initializing creation of server profile for Roundtable - API Demo Server.
Waiting on, Create, 0%,
Server Profile Create Failed: The attachment with ID 2 is missing one or more required fields: [volumeUri].
Specify all required fields for the attachment.

Please fix.

Will be fixed in next bug fixing release

Hi Stephan, the issue is fixed in the latest master branch. Please let us know if it is still not working.

Thanks, loaded the master code and did an try, but got the follwong now:

Initializing creation of server profile for Roundtable - API Demo Server.
Working on power state.
Desired Power State already set -> Off
Power Task Execution Completed
Waiting on, Create, 0%, Create
Server Profile Create Failed: The specified template version does not match the version of the template with ID '1d3e0085-ee68-4ce3-9d9c-ab5d008edec6'. Volume "Ansbible_Deploy_Boot-Vol" with attachment ID 2.
Ensure the specified template version matches the version found in the template properties and retry the request.

Hmm, can you share the json body of template "ANSIBLE_OS_Deploy_via_iLO" ? While I somewhat understand the fix that is needed, having the json body will help me recreate the scenario which you are attempting .
You can obtain the template by using postman client or curl command by doing a GET opertion against the template resource.

{
"type": "ServerProfileTemplateV8",
"uri": "/rest/server-profile-templates/950ac7c2-30f9-47f4-927d-480d255f0361",
"name": "ANSIBLE_OS_Deploy_via_iLO",
"description": "",
"serverProfileDescription": "",
"serverHardwareTypeUri": "/rest/server-hardware-types/D5DAB541-6AC3-413D-A69B-C50C654D81E0",
"enclosureGroupUri": "/rest/enclosure-groups/796b7388-1d6a-4d14-9147-f7a23491d0c6",
"affinity": "Bay",
"hideUnusedFlexNics": true,
"macType": "Virtual",
"wwnType": "Virtual",
"serialNumberType": "Virtual",
"iscsiInitiatorNameType": "AutoGenerated",
"osDeploymentSettings": null,
"firmware": {
"complianceControl": "Unchecked",
"manageFirmware": false,
"forceInstallFirmware": false
},
"connectionSettings": {
"complianceControl": "CheckedMinimum",
"manageConnections": true,
"connections": [
{
"id": 1,
"name": "Net36",
"functionType": "Ethernet",
"networkUri": "/rest/ethernet-networks/8ab63515-e00e-4759-869b-f9bb5e1257b6",
"portId": "Mezz 3:1-a",
"requestedVFs": "0",
"requestedMbps": "10000",
"boot": {
"priority": "NotBootable",
"bootVlanId": null
},
"lagName": null,
"managed": true,
"isolatedTrunk": false,
"networkName": null
},
{
"id": 2,
"name": "",
"functionType": "FibreChannel",
"networkUri": "/rest/fc-networks/10f72439-00f4-45b2-81b5-ac917f80f7fa",
"portId": "Mezz 3:1-b",
"requestedVFs": null,
"requestedMbps": "8000",
"boot": {
"bootVolumeSource": "ManagedVolume",
"priority": "Primary",
"bootVlanId": null
},
"lagName": null,
"managed": true,
"isolatedTrunk": false,
"networkName": null
},
{
"id": 3,
"name": "",
"functionType": "FibreChannel",
"networkUri": "/rest/fc-networks/6da9c8be-081f-440b-b60a-c00bad899543",
"portId": "Mezz 3:2-b",
"requestedVFs": null,
"requestedMbps": "8000",
"boot": {
"bootVolumeSource": "ManagedVolume",
"priority": "Secondary",
"bootVlanId": null
},
"lagName": null,
"managed": true,
"isolatedTrunk": false,
"networkName": null
}
]
},
"bootMode": {
"complianceControl": "Checked",
"manageMode": true,
"mode": "UEFIOptimized",
"pxeBootPolicy": "Auto",
"secureBoot": "Unmanaged"
},
"boot": {
"complianceControl": "Checked",
"manageBoot": true,
"order": [
"SD"
]
},
"bios": {
"complianceControl": "Unchecked",
"manageBios": false,
"overriddenSettings": []
},
"managementProcessor": {
"complianceControl": "Checked",
"manageMp": true,
"mpSettings": [
{
"settingType": "LocalAccounts",
"args": {
"localAccounts": [
{
"userName": "skoch",
"displayName": "p",
"password": null,
"userConfigPriv": true,
"remoteConsolePriv": true,
"virtualMediaPriv": true,
"virtualPowerAndResetPriv": true,
"iLOConfigPriv": true,
"loginPriv": true,
"hostBIOSConfigPriv": true,
"hostNICConfigPriv": true,
"hostStorageConfigPriv": true
}
]
}
}
]
},
"localStorage": {
"complianceControl": "Unchecked",
"sasLogicalJBODs": [],
"controllers": []
},
"sanStorage": {
"complianceControl": "CheckedMinimum",
"manageSanStorage": true,
"hostOSType": "RHE Linux (5.x, 6.x, 7.x)",
"sanSystemCredentials": [],
"volumeAttachments": [
{
"id": 2,
"associatedTemplateAttachmentId": "9135e03d-e8a3-4104-aad2-3598ad03fae9",
"lun": null,
"lunType": "Auto",
"storagePaths": [
{
"connectionId": 2,
"networkUri": "/rest/fc-networks/10f72439-00f4-45b2-81b5-ac917f80f7fa",
"isEnabled": true,
"targetSelector": "Auto",
"targets": []
},
{
"connectionId": 3,
"networkUri": "/rest/fc-networks/6da9c8be-081f-440b-b60a-c00bad899543",
"isEnabled": true,
"targetSelector": "Auto",
"targets": []
}
],
"volumeUri": null,
"volume": {
"templateUri": "/rest/storage-volume-templates/1d3e0085-ee68-4ce3-9d9c-ab5d008edec6",
"properties": {
"name": "Ansbible_Deploy_Boot-Vol",
"description": "",
"storagePool": "/rest/storage-pools/08E4A609-988E-4C88-BF26-AB5D008EDEC0",
"size": 42949672960,
"isShareable": false,
"templateVersion": "3.0",
"snapshotPool": "/rest/storage-pools/08E4A609-988E-4C88-BF26-AB5D008EDEC0",
"isDataReductionEnabled": false
},
"initialScopeUris": null,
"isPermanent": false
},
"volumeStorageSystemUri": "/rest/storage-systems/1c3cfa75-7dd6-4b93-84fe-ab5d008e1472",
"bootVolumePriority": "Primary"
}
]
},
"category": "server-profile-templates",
"created": "2020-01-07T08:33:34.148Z",
"modified": "2020-05-24T15:39:32.754Z",
"status": "OK",
"state": null,
"scopesUri": "/rest/scopes/resources/rest/server-profile-templates/950ac7c2-30f9-47f4-927d-480d255f0361",
"eTag": "1587105906257/14"
}

The issue is fixed with the latest PR and Stephan have also validated it. Closing the issue.