Skip to content

Commit

Permalink
Merge pull request #14 from HewlettPackard/update/documentation
Browse files Browse the repository at this point in the history
Update/documentation
  • Loading branch information
sijeesh committed Dec 20, 2019
2 parents 9cccc85 + b5bfe13 commit b7742c6
Show file tree
Hide file tree
Showing 10 changed files with 384 additions and 420 deletions.
16 changes: 14 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,22 @@ Extends support of the SDK to OneView REST API version 1200 (OneView v5.00).
2. Refactored base classes to make resource data available with the resource object.
This will help to add more helper methods for the resources and hide data complexity from the user.
3. Introduced mixin classes to include the optional features of the resources.

4. Added below methods for all the resources by introducing a base class for the resource client classes.
Appropriate exception will be raised, if any of the features are not available for a resource.

| Method | Returns |
| ------------------ | --------------------------------------------- |
| create | resource object |
| update | resource object |
| delete | boolean |
| get_all | list of resource data |
| get_by_name | resource object |
| get_by_uri | resource object |
| get_by | resource data |

#### Breaking
Enhancement made in this version breaks the previous version of the SDK.
From this version onwards, create/update/get_by_name/get_by_id will return an object of the resource instead of data.
From this version onwards, create/update/get_by_name/get_by_uri will return an object of the resource instead of data.

E.g.
```
Expand Down
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export ONEVIEWSDK_SESSIONID='123'


# Optional
export ONEVIEWSDK_API_VERSION='300'
export ONEVIEWSDK_API_VERSION='800'
export ONEVIEWSDK_AUTH_LOGIN_DOMAIN='authdomain'
export ONEVIEWSDK_SSL_CERTIFICATE='<path_to_cert.crt_file>'
export ONEVIEWSDK_PROXY='<proxy_host>:<proxy_port>'
Expand Down Expand Up @@ -193,30 +193,28 @@ export ONEVIEWSDK_PROXY='<proxy_host>:<proxy_port>'

### Setting your OneView version

The OneView Python SDK supports the API endpoints for HPE OneView 2.0, 3.0, 3.10, 4.0 and 4.10.
The OneView Python SDK supports the API endpoints for HPE OneView 4.10, 4.20 and 5.00.

The current `default` HPE OneView version used by the Python SDK is `3.00`, API `300`.
The current `default` HPE OneView version used by the Python SDK is `4.10`, API `800`.

To use a different API, you must set the API version on the OneViewClient configuration, either using the JSON configuration:

```json
"api_version": 600
"api_version": 800
```
OR using the Environment variable:

```bash
export ONEVIEWSDK_API_VERSION='600'
export ONEVIEWSDK_API_VERSION='800'
```

If this property is not specified, it will fall back to the ```300``` default value.
If this property is not specified, it will fall back to the ```800``` default value.

The API list is as follows:

- HPE OneView 2.0 API version: `200`
- HPE OneView 3.0 API version: `300`
- HPE OneView 3.10 API version: `500`
- HPE OneView 4.0 API version: `600`
- HPE OneView 4.10 API version: `800`
- HPE OneView 4.20 API version: `1000`
- HPE OneView 5.00 API version: `1200`

### HPE Synergy Image Streamer

Expand Down Expand Up @@ -278,7 +276,7 @@ try:
except HPOneViewException as e:
print(e.msg)
if e.oneview_response:
pprint(e.oneview_response)
pprint(e.oneview_response)
```

For compatibility purposes, the Exception args property is defined with the error arguments. For example:
Expand Down
536 changes: 268 additions & 268 deletions endpoints-support.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion hpOneView/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@


class connection(object):
def __init__(self, applianceIp, api_version=300, sslBundle=False, timeout=None):
def __init__(self, applianceIp, api_version=800, sslBundle=False, timeout=None):
self._session = None
self._host = applianceIp
self._cred = None
Expand Down
84 changes: 21 additions & 63 deletions hpOneView/oneview_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@


class OneViewClient(object):
DEFAULT_API_VERSION = 300
DEFAULT_API_VERSION = 800

def __init__(self, config):
self.__connection = connection(config["ip"], config.get('api_version', self.DEFAULT_API_VERSION), config.get('ssl_certificate', False),
Expand Down Expand Up @@ -350,9 +350,7 @@ def fcoe_networks(self):
Returns:
FcoeNetworks:
"""
if not self.__fcoe_networks:
self.__fcoe_networks = FcoeNetworks(self.__connection)
return self.__fcoe_networks
return FcoeNetworks(self.__connection)

@property
def ethernet_networks(self):
Expand Down Expand Up @@ -420,9 +418,7 @@ def network_sets(self):
Returns:
NetworkSets:
"""
if not self.__network_sets:
self.__network_sets = NetworkSets(self.__connection)
return self.__network_sets
return NetworkSets(self.__connection)

@property
def server_hardware(self):
Expand All @@ -432,9 +428,7 @@ def server_hardware(self):
Returns:
ServerHardware:
"""
if not self.__server_hardware:
self.__server_hardware = ServerHardware(self.__connection)
return self.__server_hardware
return ServerHardware(self.__connection)

@property
def server_hardware_types(self):
Expand All @@ -444,10 +438,7 @@ def server_hardware_types(self):
Returns:
ServerHardwareTypes:
"""
if not self.__server_hardware_types:
self.__server_hardware_types = ServerHardwareTypes(
self.__connection)
return self.__server_hardware_types
return ServerHardwareTypes(self.__connection)

@property
def id_pools_vsn_ranges(self):
Expand Down Expand Up @@ -553,9 +544,7 @@ def switch_types(self):
Returns:
SwitchTypes:
"""
if not self.__switch_types:
self.__switch_types = SwitchTypes(self.__connection)
return self.__switch_types
return SwitchTypes(self.__connection)

@property
def logical_switch_groups(self):
Expand Down Expand Up @@ -599,9 +588,7 @@ def enclosure_groups(self):
Returns:
EnclosureGroups:
"""
if not self.__enclosure_groups:
self.__enclosure_groups = EnclosureGroups(self.__connection)
return self.__enclosure_groups
return EnclosureGroups(self.__connection)

@property
def enclosures(self):
Expand All @@ -621,9 +608,7 @@ def logical_enclosures(self):
Returns:
LogicalEnclosures:
"""
if not self.__logical_enclosures:
self.__logical_enclosures = LogicalEnclosures(self.__connection)
return self.__logical_enclosures
return LogicalEnclosures(self.__connection)

@property
def metric_streaming(self):
Expand All @@ -645,9 +630,7 @@ def interconnects(self):
Returns:
Interconnects:
"""
if not self.__interconnects:
self.__interconnects = Interconnects(self.__connection)
return self.__interconnects
return Interconnects(self.__connection)

@property
def interconnect_types(self):
Expand Down Expand Up @@ -679,9 +662,7 @@ def sas_interconnect_types(self):
Returns:
SasInterconnectTypes:
"""
if not self.__sas_interconnect_types:
self.__sas_interconnect_types = SasInterconnectTypes(self.__connection)
return self.__sas_interconnect_types
return SasInterconnectTypes(self.__connection)

@property
def internal_link_sets(self):
Expand All @@ -691,9 +672,7 @@ def internal_link_sets(self):
Returns:
InternalLinkSets:
"""
if not self.__internal_link_sets:
self.__internal_link_sets = InternalLinkSets(self.__connection)
return self.__internal_link_sets
return InternalLinkSets(self.__connection)

@property
def logical_interconnect_groups(self):
Expand All @@ -703,10 +682,7 @@ def logical_interconnect_groups(self):
Returns:
LogicalInterconnectGroups:
"""
if not self.__logical_interconnect_groups:
self.__logical_interconnect_groups = LogicalInterconnectGroups(
self.__connection)
return self.__logical_interconnect_groups
return LogicalInterconnectGroups(self.__connection)

@property
def logical_interconnects(self):
Expand All @@ -726,9 +702,7 @@ def sas_logical_interconnects(self):
Returns:
SasLogicalInterconnects:
"""
if not self.__sas_logical_interconnects:
self.__sas_logical_interconnects = SasLogicalInterconnects(self.__connection)
return self.__sas_logical_interconnects
return SasLogicalInterconnects(self.__connection)

@property
def logical_downlinks(self):
Expand Down Expand Up @@ -831,9 +805,7 @@ def storage_systems(self):
Returns:
StorageSystems:
"""
if not self.__storage_systems:
self.__storage_systems = StorageSystems(self.__connection)
return self.__storage_systems
return StorageSystems(self.__connection)

@property
def storage_pools(self):
Expand All @@ -843,9 +815,7 @@ def storage_pools(self):
Returns:
StoragePools:
"""
if not self.__storage_pools:
self.__storage_pools = StoragePools(self.__connection)
return self.__storage_pools
return StoragePools(self.__connection)

@property
def storage_volume_templates(self):
Expand All @@ -855,9 +825,7 @@ def storage_volume_templates(self):
Returns:
StorageVolumeTemplates:
"""
if not self.__storage_volume_templates:
self.__storage_volume_templates = StorageVolumeTemplates(self.__connection)
return self.__storage_volume_templates
return StorageVolumeTemplates(self.__connection)

@property
def storage_volume_attachments(self):
Expand All @@ -867,9 +835,7 @@ def storage_volume_attachments(self):
Returns:
StorageVolumeAttachments:
"""
if not self.__storage_volume_attachments:
self.__storage_volume_attachments = StorageVolumeAttachments(self.__connection)
return self.__storage_volume_attachments
return StorageVolumeAttachments(self.__connection)

@property
def firmware_drivers(self):
Expand Down Expand Up @@ -913,9 +879,7 @@ def volumes(self):
Returns:
Volumes:
"""
if not self.__volumes:
self.__volumes = Volumes(self.__connection)
return self.__volumes
return Volumes(self.__connection)

@property
def sas_logical_jbod_attachments(self):
Expand All @@ -937,9 +901,7 @@ def managed_sans(self):
Returns:
ManagedSANs:
"""
if not self.__managed_sans:
self.__managed_sans = ManagedSANs(self.__connection)
return self.__managed_sans
return ManagedSANs(self.__connection)

@property
def migratable_vc_domains(self):
Expand All @@ -961,9 +923,7 @@ def sas_interconnects(self):
Returns:
SasInterconnects:
"""
if not self.__sas_interconnects:
self.__sas_interconnects = SasInterconnects(self.__connection)
return self.__sas_interconnects
return SasInterconnects(self.__connection)

@property
def sas_logical_interconnect_groups(self):
Expand All @@ -973,9 +933,7 @@ def sas_logical_interconnect_groups(self):
Returns:
SasLogicalInterconnectGroups:
"""
if not self.__sas_logical_interconnect_groups:
self.__sas_logical_interconnect_groups = SasLogicalInterconnectGroups(self.__connection)
return self.__sas_logical_interconnect_groups
return SasLogicalInterconnectGroups(self.__connection)

@property
def drive_enclosures(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/resources/networking/test_ethernet_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_create_should_use_given_values(self, mock_create):
"privateNetwork": False
}
resource_rest_call = resource.copy()
resource_rest_call['type'] = 'ethernet-networkV300'
resource_rest_call['type'] = 'ethernet-networkV4'
mock_create.return_value = {}

self._ethernet_networks.create(resource, timeout=12)
Expand All @@ -72,7 +72,7 @@ def test_create_bulk(self, mock_get_all, mock_create):
}
}
resource_rest_call = resource.copy()
resource_rest_call['type'] = 'bulk-ethernet-network'
resource_rest_call['type'] = 'bulk-ethernet-networkV1'

mock_create.return_value = {}
mock_get_all.return_value = []
Expand Down
9 changes: 4 additions & 5 deletions tests/unit/resources/networking/test_logical_interconnects.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_update_settings(self, mock_update):
}
settings_rest_call = settings.copy()
settings_rest_call["type"] = "type"
settings_rest_call["ethernetSettings"]["type"] = "EthernetInterconnectSettingsV201"
settings_rest_call["ethernetSettings"]["type"] = "EthernetInterconnectSettingsV4"
self._logical_interconnect.update_settings(settings)

mock_update.assert_called_once_with(settings_rest_call, uri=uri_rest_call, force=False, timeout=-1)
Expand All @@ -142,7 +142,7 @@ def test_update_settings(self, mock_update):
def test_update_settings_with_force(self, mock_update):
self._logical_interconnect.update_settings({}, force=True)

mock_update.assert_called_once_with({"type": "InterconnectSettingsV201"},
mock_update.assert_called_once_with({},
uri="/rest/logical-interconnects/ad28cf21-8b15-4f92-bdcf-51cb2042db32/settings",
force=True, timeout=-1)

Expand All @@ -155,10 +155,9 @@ def test_update_settings_with_default_values(self, mock_update):
}
settings_with_default_values = {
"ethernetSettings": {
"type": "EthernetInterconnectSettingsV201",
"type": "EthernetInterconnectSettingsV4",
"macRefreshInterval": "5"
},
"type": "InterconnectSettingsV201"
}
}
self._logical_interconnect.update_settings(settings)

Expand Down
2 changes: 0 additions & 2 deletions tests/unit/resources/networking/test_logical_switches.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def test_create_should_use_default_values(self, mock_create):
resource_with_default_values = {
"logicalSwitch": {
"name": "Test Logical Switch",
"type": "logical-switchV300"
}
}
mock_create.return_value = {}
Expand Down Expand Up @@ -110,7 +109,6 @@ def test_update_should_use_default_values(self, mock_update):
resource_with_default_values = {
"logicalSwitch": {
"name": "Test Logical Switch",
"type": "logical-switchV300",
"uri": uri
},
"uri": "a_uri"
Expand Down
Loading

0 comments on commit b7742c6

Please sign in to comment.