Comments (2)
Issue here seems to be that server_profile['osDeploymentSettings']['osCustomAttributes'] is a list
of dicts
, so its indexes would actually be numbers.
In the case presented:
profile_to_update['osDeploymentSettings']['osCustomAttributes'] = dict(name='key2',value='new2')
profile_updated = oneview_client.server_profiles.update(resource=profile_to_update, id_or_uri=profile_to_update['uri'])
This first line is actively rewriting all the contents of profile_to_update['osDeploymentSettings']['osCustomAttributes']
to match the new value of dict(name='key2',value='new2')
.
Changing only the second value could be achieved by pointing to the specific position we want changed, 1
in this case, since lists start at 0
:
profile_to_update['osDeploymentSettings']['osCustomAttributes'][1] = dict(name='key2',value='new2')
A worse case is when we aren't sure which position we actually want to change, just the value of the key.
In that case, one option is to iterate through each item of the list and if the key matches what we want, we alter the value referenced by that key:
>>> my_list
[{'name': 'key1', 'value': 'value1'}, {'name': 'key2', 'value': 'value2'}, {'name': 'key3', 'value': 'value3'}]
>>> for i in my_list:
... if i['name'] is 'key2':
... i['value'] = 'new_value'
...
>>> my_list
[{'name': 'key1', 'value': 'value1'}, {'name': 'key2', 'value': 'new_value'}, {'name': 'key3', 'value': 'value3'}]
So, for now "updating select custom attributes" can be achieved in relatively straightforward ways. Not entirely sure how much benefit a helper method would bring.
@kmullican, let me know your thoughts on this after these solutions.
from python-hponeview.
This feature request has been idle for a while and it appears to be resolved by this comment, so I'm closing it down.
If the solution provided does not satisfy your needs, this issue should be reopened or referenced through a new issue.
from python-hponeview.
Related Issues (20)
- Creating a server profile from a profile template with a local storage logical drive HOT 1
- OneView API unable to handle concurrent 'interconnect.get_statistics' calls HOT 1
- Exception raised when attempting to get a resource URI from a remote respository entity HOT 1
- I3S extract artifact bundle API missing required parameters HOT 1
- OneView version requires credentials HOT 1
- Simple example to create a network fails HOT 2
- Oneview 4.20 support HOT 5
- "type" field in migratable vc domains is invalid HOT 1
- Unable to retrieve Server Hardware details by filter “ServerName” but able to do it through filter “name” HOT 5
- Trying to load config HOT 6
- Get Info for fan failure, array controller failure, smart storage battery status low or dead HOT 1
- get_by function for id_pools_ipv4_ranges HOT 1
- Identify an IPv4 range without knowing its URI HOT 1
- server_profile_templates does not have a function get_by_name HOT 1
- get attributes of JBOD disk in server profiles - Erase on delete and permanent HOT 1
- Functions 'get_by_*' in example server_hardware.py do not exist HOT 1
- Where can I get a backup URI to restore devices on oneview ? HOT 2
- id_pools_vmac_ranges and id_pools_WWNN_ranges and id_pools_sn_ranges do not have a get_all function HOT 3
- my build failed in Travis with the following that I am not sure what to do about...
- SDK does not Support API version 1200 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-hponeview.