Skip to content

Commit

Permalink
Merge branch 'master' into PR
Browse files Browse the repository at this point in the history
  • Loading branch information
nabhajit-ray authored Nov 9, 2022
2 parents 309d267 + 25d9c6c commit c99cb34
Show file tree
Hide file tree
Showing 12 changed files with 784 additions and 277 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#### Notes
Extends support of the SDK to OneView REST API version 4600 (OneView v8.0.0)

#### Major changes
Added support for Rack Manager resources
Added support for San Manager resources

##### Features supported with the current release
- Appliance Configuration Timeconfig
- Appliance Health Status
Expand Down Expand Up @@ -57,7 +61,7 @@ Extends support of the SDK to OneView REST API version 4600 (OneView v8.0.0)
- Users
- Version
- Volumes

# 7.2.0
#### Notes
Extends support of the SDK to OneView REST API version 4400 (OneView v7.2.0)
Expand Down
3 changes: 3 additions & 0 deletions examples/config-rename.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
"server_hostname": "",
"server_username": "",
"server_password": "",
"rack_manager_hostname": "",
"rack_manager_username": "",
"rack_manager_password": "",
"storage_system_hostname": "",
"storage_system_username": "",
"storage_system_password": "",
Expand Down
146 changes: 146 additions & 0 deletions examples/rack_managers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# -*- coding: utf-8 -*-
###
# (C) Copyright [2022] Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###

from pprint import pprint

from hpeOneView.oneview_client import OneViewClient
from config_loader import try_load_from_file

config = {
"ip": "<oneview_ip>",
"credentials": {
"userName": "<username>",
"password": "<password>"
}
}

# Try load config from a file (if there is a config file)
config = try_load_from_file(config)

options = {
"hostname": config['rack_manager_hostname'],
"username": config['rack_manager_username'],
"password": config['rack_manager_password'],
"force": False
}

oneview_client = OneViewClient(config)

rack_managers = oneview_client.rack_managers

# Get all rack managers
rackmanagers = []
print("\n## Get all rack managers")
rack_managers_all = rack_managers.get_all()
# pprint(rack_managers_all)
for rm in rack_managers_all:
print('%s' % rm['name'])
rackmanagers.append(rm['name'])

# Adds a rack manager
# This is only supported on appliance which support managers
print("\n## Add a rack manager")
added_rack_manager = rack_managers.add(options)
print("Added rack manager '%s'.\n uri = '%s'" % (added_rack_manager.data['name'], added_rack_manager.data['uri']))

# Get list of chassis from all rack managers
print("\n## Get list of chassis from all rack managers")
chassis_all = rack_managers.get_all_chassis()
for ch in chassis_all['members']:
pprint("Name:{} , ChassisType:{}".format(ch['name'], ch['chassisType']))

# Get list of manager resources from all rack managers
print("\n## Get list of manager resources from all rack managers")
managers_all = rack_managers.get_all_managers()
for mn in managers_all['members']:
pprint("Name:{} , ManagerType:{}".format(mn['name'], mn['managerType']))

# Get collection of partition resources from all rack managers
print("\n## Get collection of partition resources from all rack managers")
partition_all = rack_managers.get_all_partitions()
for pn in partition_all['members']:
pprint("Name:{} , partitionNum:{}".format(pn['name'], pn['partitionNum']))


# Get recently added rack manager resource
if rackmanagers:
rackmanager = rack_managers.get_by_name(rackmanagers[0])
pprint(rackmanager.data)

# Get all chassis associated with recently added rack manager
print("\n## Get all chassis associated with recently added rack manager")
if rackmanager:
associated_chassis = rackmanager.get_associated_chassis()
pprint(associated_chassis)

# Retrieves a specific chassis that is part of the rack manager.
print("\n## Retrieves a specific chassis that is part of the rack manager")
if associated_chassis:
chassis_uri = associated_chassis['members'][0]['uri']
pprint(rack_managers.get_a_specific_resource(chassis_uri))

# Get the environmental configuration of a rack manager
print("\n## Get the environmental configuration of a rack manager")
if rackmanager:
env_conf = rackmanager.get_environmental_configuration()
pprint(env_conf)

# Get all chassis associated with recently added rack manager
print("\n## Get all managers associated with recently added rack manager")
if rackmanager:
associated_manager = rackmanager.get_associated_managers()
pprint(associated_manager)

# Retrieves a specific manager that is part of the rack manager.
print("\n## Retrieves a specific chassis that is part of the rack manager")
if associated_manager:
manager_uri = associated_manager['members'][0]['uri']
pprint(rack_managers.get_a_specific_resource(manager_uri))

# Get all chassis associated with recently added rack manager
print("\n## Get all partitions associated with recently added rack manager")
if rackmanager:
associated_partitions = rackmanager.get_associated_partitions()
pprint(associated_partitions)

# Retrieves a specific partition that is part of the rack manager.
print("\n## Retrieves a specific chassis that is part of the rack manager")
if associated_partitions:
partition_uri = associated_partitions['members'][0]['uri']
pprint(rack_managers.get_a_specific_resource(partition_uri))

# Get the environmental configuration of a rack manager
print("\n## Get the remote support settings of a rack manager")
if rackmanager:
remote_conf = rackmanager.get_remote_support_settings()
pprint(remote_conf)

# Refreshes a rack manager
print("\n## Refreshes a rack manager")
if rackmanagers:
rm_name = rackmanagers[0]
rm_to_refresh = rack_managers.get_by_name(rm_name)
rm_to_refresh.patch('RefreshRackManagerOp', '', '')
print("Succesfully refreshed rack manager.")

# remove a recently added rack manager
print("\n## Remove a recently added rack manager")
if rackmanagers:
rm_name = rackmanagers[0]
rm_to_remove = rack_managers.get_by_name(rm_name)
rm_to_remove.remove()
print("Succesfully removed rack manager")
71 changes: 44 additions & 27 deletions examples/san_managers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
###
# (C) Copyright [2019] Hewlett Packard Enterprise Development LP
# (C) Copyright [2022] Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -21,7 +21,7 @@
from hpeOneView.oneview_client import OneViewClient

# This example has options pre-defined for 'Brocade Network Advisor' and 'Cisco' type SAN Managers
PROVIDER_NAME = 'Cisco'
PROVIDER_NAME = 'Brocade FOS Switch'

config = {
"ip": "<oneview_ip>",
Expand All @@ -34,44 +34,60 @@
# # To run this sample you must define the following resources for a Brocade Network Advisor
manager_host = '<san_manager_hostname_or_ip>'
manager_port = '<port_number_not_quoted>'
manager_username = '<san_manager_user_name>'
manager_username = '<san_manager_username>'
manager_password = '<san_manager_password>'

# Try load config from a file (if there is a config file)
config = try_load_from_file(config)

oneview_client = OneViewClient(config)
san_providers = oneview_client.san_providers
san_managers = oneview_client.san_managers


# Print default connection info for Brocade Network Advisor
print("\nGet {} default connection info:".format(PROVIDER_NAME))
default_info = oneview_client.san_managers.get_default_connection_info(PROVIDER_NAME)
default_info = san_providers.get_default_connection_info(PROVIDER_NAME)
print(default_info)
for property in default_info:
print(" '{name}' - '{value}'".format(**property))
# Add a Brocade Network Advisor
provider_uri = oneview_client.san_managers.get_provider_uri(PROVIDER_NAME)
provider_uri = san_providers.get_provider_uri(PROVIDER_NAME)

options_for_brocade = {
'providerDisplayName': PROVIDER_NAME,
'connectionInfo': [
{
'name': 'Host',
'value': manager_host
"name": "Host",
"displayName": "Host",
"required": True,
"value": manager_host,
"valueType": "String",
"valueFormat": "IPAddressOrHostname"
},
{
'name': 'Port',
'value': manager_port
"name": "Username",
"displayName": "Username",
"required": True,
"value": manager_username,
"valueType": "String",
"valueFormat": "None"
},
{
'name': 'Username',
'value': manager_username
"name": "Password",
"displayName": "Password",
"required": True,
"value": manager_password,
"valueType": "String",
"valueFormat": "SecuritySensitive"
},
{
'name': 'Password',
'value': manager_password
},
{
'name': 'UseSsl',
'value': True
"name": "UseHttps",
"displayName": "UseHttps",
"required": True,
"value": True,
"valueType": "Boolean",
"valueFormat": "None"
}
]
}
Expand Down Expand Up @@ -146,10 +162,10 @@
]
}

if PROVIDER_NAME == 'Brocade Network Advisor':
san_manager = oneview_client.san_managers.add(options_for_brocade, provider_uri)
if PROVIDER_NAME == 'Brocade FOS Switch':
san_manager = san_providers.add(options_for_brocade, provider_uri)
elif PROVIDER_NAME == 'Cisco':
san_manager = oneview_client.san_managers.add(options_for_cisco, provider_uri)
san_manager = san_providers.add(options_for_cisco, provider_uri)
else:
provider_error_msg = 'Options for the "%s" provider not pre-added to this example file. Validate '
provider_error_msg < 'and or create options for that provider and remove this exception.' % PROVIDER_NAME
Expand All @@ -161,22 +177,23 @@
info = {
'refreshState': "RefreshPending"
}
san_manager = oneview_client.san_managers.update(resource=info, id_or_uri=san_manager['uri'])
san_manager = san_managers.update(resource=info, id_or_uri=san_manager['uri'])
print(" 'refreshState' successfully updated to '{refreshState}'".format(**san_manager))

print("\nGet SAN manager by uri")
san_manager_byuri = oneview_client.san_managers.get(san_manager['uri'])
print(" Found '{name}' at uri: {uri}".format(**san_manager_byuri))
san_manager_byuri = san_managers.get_by_uri(san_manager['uri'])

print(" Found '{name}' at uri: {uri}".format(**san_manager_byuri.data))

print("\nGet all SAN managers")
san_managers = oneview_client.san_managers.get_all()
for manager in san_managers:
san_manager_all = san_managers.get_all()
for manager in san_manager_all:
print(" '{name}' at uri: {uri}".format(**manager))

print("\nGet a SAN Manager by name")
san_managers_by_name = oneview_client.san_managers.get_by_name(manager_host)
san_managers_by_name = san_managers.get_by_name(manager_host)
pprint(san_managers_by_name)

print("\nDelete the SAN Manager previously created...")
oneview_client.san_managers.remove(san_manager)
san_managers_by_name.remove()
print("The SAN Manager was deleted successfully.")
Loading

0 comments on commit c99cb34

Please sign in to comment.