Skip to content

Commit

Permalink
Merge pull request #160 from HewlettPackard/ha_node
Browse files Browse the repository at this point in the history
refactored appliance node info
  • Loading branch information
VenkateshRavula authored Jun 30, 2021
2 parents b045857 + 95e8c7d commit 5a37f0d
Show file tree
Hide file tree
Showing 14 changed files with 362 additions and 48 deletions.
23 changes: 8 additions & 15 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,15 @@ jobs:
- name: Run tox tests
run: tox

# - name: Deploy to GitHub Pages
# if: success()
# uses: crazy-max/ghaction-github-pages@v2
# with:
# target_branch: gh-pages
# keep_history: true
# build_dir: docs/build/html/.
# env:
# GH_PAT: ${{ secrets.ONEVIEW_DEPLOY_TOKEN }}

- name: Deploy to GitHub pages
uses: peaceiris/actions-gh-pages@v3
- name: Deploy to GitHub Pages
if: success()
uses: crazy-max/ghaction-github-pages@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/build/html/.
keep_files: true
target_branch: gh-pages
keep_history: true
build_dir: docs/build/html/.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: coveralls
uses: AndreMiras/coveralls-python-action@develop
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# 6.2.0(unreleased)
#### Notes
Extends support of the SDK to OneView REST API version 3000 (OneView v6.20)

#### Bug fixes & Enhancements
- [#157] (https://github.com/HewlettPackard/oneview-python/issues/157) Add appliance ha-nodes endpoint to sdk

#### Features supported
- Appliance Node Information
- Appliance Health Status
- HA Nodes

# 6.1.0
#### Notes
Extends support of the SDK to OneView REST API version 2800 (OneView v6.10) and ImageStreamer REST API version 2020 (I3S v6.10).
Expand Down
15 changes: 13 additions & 2 deletions endpoints-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@

## HPE OneView

| Endpoints | Verb | V800 | V1000 | V1200 | V1600 | V1800 | V2000 | V2200 | V2400 | V2600 | V2800 |
| --------------------------------------------------------------------------------------- | ------------------ | :------------------: | :------------------:| :------------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: |
| Endpoints | Verb | V800 | V1000 | V1200 | V1600 | V1800 | V2000 | V2200 | V2400 | V2600 | V2800 | V3000 |
| --------------------------------------------------------------------------------------- | ------------------ | :------------------: | :------------------:| :------------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: | :-----------------: |
| **Appliance Configuration Timeconfig**
|<sub>/rest/appliance/configuration/timeconfig/locales</sub> |GET | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| **Appliance Node Information**
|<sub>/rest/appliance/nodeinfo/status</sub> |GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/appliance/nodeinfo/version</sub> |GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| **Appliance Health-Status**
|<sub>/rest/appliance/health-status</sub> |GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| **Appliance SNMPv1 Trap Destinations**
|<sub>/rest/appliance/trap-destinations</sub> |GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/appliance/trap-destinations/validation</sub> |POST | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
Expand Down Expand Up @@ -117,6 +122,12 @@
|<sub>/rest/firmware-drivers/schema</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/firmware-drivers/{id}</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/firmware-drivers/{id}</sub> | DELETE | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| **HA Nodes**
|<sub>/rest/appliance/ha-nodes</sub> |GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/appliance/ha-nodes/{id}</sub> |GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/appliance/ha-nodes/{id}</sub> |PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/appliance/ha-nodes/{id}</sub> |PATCH | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/appliance/ha-nodes/{id}</sub> |DELETE | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| **Hypervisor Cluster Profiles**
|<sub>/rest/hypervisor-cluster-profiles</sub> |POST | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/hypervisor-cluster-profiles</sub> |GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
Expand Down
38 changes: 38 additions & 0 deletions examples/appliance_health_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
###
# (C) Copyright [2021] 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)
oneview_client = OneViewClient(config)
app_health = oneview_client.appliance_health_status

# Get health status information from appliance
print("\nGet health status information from appliance:\n ")
health_status = app_health.get_health_status()
pprint(health_status.data)
12 changes: 6 additions & 6 deletions examples/appliance_node_information.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 [2021] 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 Down Expand Up @@ -29,15 +29,15 @@

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

oneview_client = OneViewClient(config)
app_node_info = oneview_client.appliance_node_information

# Get node status information from appliance
print("\nGet node status information from appliance:\n ")
node_status = oneview_client.appliance_node_information.get_status()
pprint(node_status)
node_status = app_node_info.get_status()
pprint(node_status.data)

# Get node version information from appliance
print("\nGet node version information from appliance\n")
node_version = oneview_client.appliance_node_information.get_version()
pprint(node_version)
node_version = app_node_info.get_version()
pprint(node_version.data)
59 changes: 59 additions & 0 deletions examples/ha_nodes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*-
###
# (C) Copyright [2021] 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)
oneview_client = OneViewClient(config)
ha_nodes = oneview_client.ha_nodes

# Get all HA nodes from appliance
print("\nGet all HA nodes from appliance:\n ")
all_nodes = ha_nodes.get_all()
for node in all_nodes:
print(" - {}".format(node['name']))

# Get HA node by uri from appliance
print("\nGet HA node by uri from appliance\n")
node_by_uri = ha_nodes.get_by_uri(all_nodes[0]['uri'])
pprint(node_by_uri.data)

# update role of HA node
data = {'role': 'Standby'}
ha_node = node_by_uri.update(data)
print("\n## Update HA node successfully!")
pprint(ha_node.data)

# Patch update role
print("\nUpdate the HA node using patch")
ha_node.patch(operation="replace", path="/role", value="Active")
pprint(ha_node.data)

# Delete HA node
ha_node.delete()
print("\n## Delete HA node successfully!")
32 changes: 26 additions & 6 deletions hpeOneView/oneview_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
from hpeOneView.resources.settings.appliance_device_snmp_v3_trap_destinations import ApplianceDeviceSNMPv3TrapDestinations
from hpeOneView.resources.settings.appliance_device_snmp_v3_users import ApplianceDeviceSNMPv3Users
from hpeOneView.resources.settings.appliance_node_information import ApplianceNodeInformation
from hpeOneView.resources.settings.appliance_health_status import ApplianceHealthStatus
from hpeOneView.resources.settings.ha_nodes import HANodes
from hpeOneView.resources.settings.appliance_time_and_locale_configuration import ApplianceTimeAndLocaleConfiguration
from hpeOneView.resources.settings.versions import Versions
from hpeOneView.resources.hypervisors.hypervisor_managers import HypervisorManagers
Expand Down Expand Up @@ -201,6 +203,7 @@ def __init__(self, config):
self.__appliance_device_snmp_v3_users = None
self.__appliance_time_and_locale_configuration = None
self.__appliance_node_information = None
self.__appliance_health_status = None
self.__versions = None
self.__backups = None
self.__login_details = None
Expand All @@ -209,6 +212,7 @@ def __init__(self, config):
self.__certificates_server = None
self.__appliance_configuration_timeconfig = None
self.__appliance_ssh_access = None
self.__ha_nodes = None

@classmethod
def from_json_file(cls, file_name):
Expand Down Expand Up @@ -1094,9 +1098,7 @@ def appliance_device_snmp_v3_users(self):
Returns:
ApplianceDeviceSNMPv3Users:
"""
if not self.__appliance_device_snmp_v3_users:
self.__appliance_device_snmp_v3_users = ApplianceDeviceSNMPv3Users(self.__connection)
return self.__appliance_device_snmp_v3_users
return ApplianceDeviceSNMPv3Users(self.__connection)

@property
def appliance_node_information(self):
Expand All @@ -1106,9 +1108,27 @@ def appliance_node_information(self):
Returns:
ApplianceNodeInformation:
"""
if not self.__appliance_node_information:
self.__appliance_node_information = ApplianceNodeInformation(self.__connection)
return self.__appliance_node_information
return ApplianceNodeInformation(self.__connection)

@property
def appliance_health_status(self):
"""
Gets the ApplianceHealthStatus API client.
Returns:
ApplianceHealthStatus:
"""
return ApplianceHealthStatus(self.__connection)

@property
def ha_nodes(self):
"""
Gets the HANodes API client.
Returns:
HANodes:
"""
return HANodes(self.__connection)

@property
def appliance_time_and_locale_configuration(self):
Expand Down
47 changes: 47 additions & 0 deletions hpeOneView/resources/settings/appliance_health_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
###
# (C) Copyright [2021] 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 __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from future import standard_library

standard_library.install_aliases()

from hpeOneView.resources.resource import Resource


class ApplianceHealthStatus(Resource):
"""
Retrieves the health information from the appliance.
"""
URI = '/rest/appliance/health-status'

def __init__(self, connection, data=None):
super(ApplianceHealthStatus, self).__init__(connection, data)

def get_health_status(self):
"""
Retrieves appliance health status
Returns:
dict: appliance health status
"""
return super(ApplianceHealthStatus, self).get_by_uri(self.URI)
17 changes: 9 additions & 8 deletions hpeOneView/resources/settings/appliance_node_information.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 [2021] 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 @@ -24,18 +24,19 @@

standard_library.install_aliases()

from hpeOneView.resources.resource import ResourceClient
from hpeOneView.resources.resource import Resource


class ApplianceNodeInformation(object):
class ApplianceNodeInformation(Resource):
"""
ApplianceNodeInformation API client.
The nodeinfo resource manager provides REST APIs to
retrieve information about the nodes of the appliance.
"""
URI = '/rest/appliance/nodeinfo'

def __init__(self, con):
self._client = ResourceClient(con, self.URI)
def __init__(self, connection, data=None):
super(ApplianceNodeInformation, self).__init__(connection, data)

def get_status(self):
"""
Expand All @@ -45,7 +46,7 @@ def get_status(self):
dict: Node's status information
"""
uri = self.URI + '/status'
return self._client.get(uri)
return super(ApplianceNodeInformation, self).get_by_uri(uri)

def get_version(self):
"""
Expand All @@ -55,4 +56,4 @@ def get_version(self):
dict: Node's version information
"""
uri = self.URI + '/version'
return self._client.get(uri)
return super(ApplianceNodeInformation, self).get_by_uri(uri)
Loading

0 comments on commit 5a37f0d

Please sign in to comment.