Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Synergy profile provisioned from template using Python SDK is not consistent #304

Open
kmullican opened this issue Aug 21, 2017 · 5 comments

Comments

@kmullican
Copy link

Scenario/Intent

Provisioning a Synergy profile from template using Python SDK should result in a profile containing the OS Deployment Plan, connections, and local storage that was defined in the template.

Environment Details

  • OneView SDK Version: 3.3.0
  • OneView Appliance Version: 3.10.04-0299553
  • OneView Client API Version: 500
  • Python Version: 3.4.5
  • Platform: CentOS 7.3 x86_64

Steps to Reproduce

Create a template in OneView containing an OS Deployment Plan, connections, and local storage
Provision a profile in Python:
oneview_client = OneViewClient.from_json_file('connection.json')
new_profile_options = dict(
name=PROFILE_NAME,
serverProfileTemplateUri=TEMPLATE_URI,
serverHardwareUri=SRVR_HWARE_URI
)
new_profile = oneview_client.server_profiles.create(new_profile_options)

Expected Result

New profile contains same OS Deployment Plan, connections, and local storage as the template

Actual Result

New profile has OS Deployment Plan set to "None", no connections, and no local storage

@kmullican
Copy link
Author

kmullican commented Aug 21, 2017

This has been resolved by using the following combination of steps:

First, create a new profile from the template, which will be unassigned
new_profile = oneview_client.server_profile_templates.get_new_profile(TEMPLATE_URI)

Now update the serverHardwareUri, name, and custom attributes before assigning the new profile to hardware
new_profile['serverHardwareUri'] = SRVR_HWARE_URI
new_profile['name'] = PROFILE_NAME
new_profile['osDeploymentSettings']['osCustomAttributes'] = dict(name='key1',value=VALUE1),dict(name='key2',value=VALUE2),dict(name='key3',value=VALUE3)
oneview_client.server_profiles.update(resource=new_profile, id_or_uri=new_profile['uri'])

Create the profile (assign it to hardware)
created_profile = oneview_client.server_profiles.create(new_profile)

@kmullican
Copy link
Author

I'd like to make a suggestion that oneview_client.server_profile_templates.get_new_profile should perhaps be renamed to oneview_client.server_profile_templates.create_new_profile? The verbage "get" is not intuitive since this is actually used to "create" a new profile from a template.

@fgbulsoni
Copy link
Contributor

Hello @kmullican , the "get_new_profile" doesn't actually create a new profile.

It is a binding to the GET endpoint /rest/server-profile-templates/{id}/new-profile on the Server Profile Template.

What this does is actually just return a dictionary which is based on the server profile template, but ready to be used as base for a server profile.

In this case, when you run:

new_profile = oneview_client.server_profile_templates.get_new_profile(TEMPLATE_URI)

You have not yet created the Server Profile in OneView, you've just created a local dictionary containing the info you require to create that profile, and assigned it to the variable new_profile.

The profile is actually being created when you call:

created_profile = oneview_client.server_profiles.create(new_profile)

Which is using all of the info on the variable new_profile, both what was retrieved and what you edited, to create a Server Profile on the OneView appliance.

Hope this helps clear things up a bit. :octocat:

@kmullican
Copy link
Author

@fgbulsoni yes, true, thx. It's a "get in preparation to create", lol. would it be best for me to close this issue since it has been resolved? just wanted to leave some breadcrumbs in the notes in case anyone else would like example of getting the profile defined and created from template.

@fgbulsoni
Copy link
Contributor

I'll update the example and try to make this path more clear, as that should help as well.

These breadcrumbs are definitely important and will be searchable for anyone that gets in the repo, so that is great as well. :octocat:

I'd wait for that example file update to close this though.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants