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

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: HewlettPackard/python-hpOneView
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: chrisarnott86/python-hpOneView
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 13 commits
  • 7 files changed
  • 2 contributors

Commits on Nov 5, 2018

  1. Create appliance_network_interfaces.py

    method for getting appliance network information
    chrisarnott86 authored Nov 5, 2018
    Copy the full SHA
    c84585e View commit details
  2. Update appliance_network_interfaces.py

    tidy, remove stray return line
    chrisarnott86 authored Nov 5, 2018
    Copy the full SHA
    ddbdde2 View commit details
  3. Update oneview_client.py

    add appliance network information class link
    chrisarnott86 authored Nov 5, 2018
    Copy the full SHA
    28b6787 View commit details
  4. Copy the full SHA
    9476371 View commit details
  5. Update oneview_client.py

    add appliance_network_information attribute
    chrisarnott86 authored Nov 5, 2018
    Copy the full SHA
    7e4f548 View commit details

Commits on Nov 6, 2018

  1. Copy the full SHA
    b0a0fe0 View commit details
  2. add ignores to tox.ini for line breaks after binary operator (W504) a…

    …nd invalid escape sequence (W605). One instance of W605 in hpOneView/resources/networking/ethernet_networks.py:175:32
    chrisarnott86 committed Nov 6, 2018
    Copy the full SHA
    6463bc3 View commit details
  3. Create appliance_network_interfaces to allow querying of

    GET https://{appl}/rest/appliance/network-interfaces
    chrisarnott86 committed Nov 6, 2018
    Copy the full SHA
    91a974b View commit details
  4. Copy the full SHA
    e91fc49 View commit details
  5. Copy the full SHA
    72a4ed9 View commit details
  6. Copy the full SHA
    e5dd49e View commit details
  7. Copy the full SHA
    a72a0fb View commit details
  8. Copy the full SHA
    1c91a05 View commit details
2 changes: 2 additions & 0 deletions endpoints-support.md
Original file line number Diff line number Diff line change
@@ -27,6 +27,8 @@
|<sub>/rest/alerts/{id} </sub> |PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/alerts/{id} </sub> |DELETE | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/alerts/AlertChangeLog/{id}</sub> |DELETE | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| **Appliance Network Interfaces** |
|<sub>/rest/appliance/network-interfaces</sub> |GET | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| **Appliance Time and Locale Configuration** |
|<sub>/rest/appliance/configuration/time-locale</sub> |GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/appliance/configuration/time-locale</sub> |POST | :white_check_mark: | :white_check_mark: | :white_check_mark: |
44 changes: 44 additions & 0 deletions examples/appliance_network_interfaces.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
###
# (C) Copyright (2012-2017) Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
###

from pprint import pprint
from hpOneView.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)

# Get network interfaces information from appliance
print("\nnetwork interfaces information from appliance:\n ")
network_interfaces = oneview_client.appliance_network_interfaces.get_all()
pprint(network_interfaces)
14 changes: 14 additions & 0 deletions hpOneView/oneview_client.py
Original file line number Diff line number Diff line change
@@ -107,6 +107,7 @@
from hpOneView.resources.security.roles import Roles
from hpOneView.resources.security.users import Users
from hpOneView.resources.settings.appliance_node_information import ApplianceNodeInformation
from hpOneView.resources.settings.appliance_network_interfaces import ApplianceNetworkInterfaces
from hpOneView.resources.settings.appliance_time_and_locale_configuration import ApplianceTimeAndLocaleConfiguration
from hpOneView.resources.settings.versions import Versions

@@ -192,6 +193,7 @@ def __init__(self, config):
self.__users = None
self.__appliance_time_and_locale_configuration = None
self.__appliance_node_information = None
self.__appliance_network_interfaces = None
self.__versions = None
self.__backups = None
self.__login_details = None
@@ -1129,6 +1131,18 @@ def appliance_node_information(self):
self.__appliance_node_information = ApplianceNodeInformation(self.__connection)
return self.__appliance_node_information

@property
def appliance_network_interfaces(self):
"""
Gets the ApplianceNetworkInterfaces API client.
Returns:
ApplianceNetworkInterfaces:
"""
if not self.__appliance_network_interfaces:
self.__appliance_network_interfaces = ApplianceNetworkInterfaces(self.__connection)
return self.__appliance_network_interfaces

@property
def appliance_time_and_locale_configuration(self):
"""
52 changes: 52 additions & 0 deletions hpOneView/resources/settings/appliance_network_interfaces.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# -*- coding: utf-8 -*-
###
# (C) Copyright (2012-2017) Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
###

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 hpOneView.resources.resource import ResourceClient


class ApplianceNetworkInterfaces(object):
"""
ApplianceNetworkInformation API client.
"""
URI = '/rest/appliance/network-interfaces'

def __init__(self, con):
self._client = ResourceClient(con, self.URI)

def get_all(self):
"""
Retrieves applicance network information
Returns:
dict: Appliance's network information
"""
uri = self.URI
return self._client.get(uri)
42 changes: 42 additions & 0 deletions tests/unit/resources/settings/test_appliance_network_interfaces.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
###
# (C) Copyright (2012-2017) Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
###

import unittest

import mock

from hpOneView.connection import connection
from hpOneView.resources.settings.appliance_network_interfaces import ApplianceNetworkInterfaces
from hpOneView.resources.resource import ResourceClient


class ApplianceNetworkInterfacesTest(unittest.TestCase):
def setUp(self):
self.host = '127.0.0.1'
self.connection = connection(self.host)
self._network_interfaces = ApplianceNetworkInterfaces(self.connection)

@mock.patch.object(ResourceClient, 'get')
def test_get_status_called_once(self, mock_get):
self._network_interfaces.get_all()
mock_get.assert_called_once_with('/rest/appliance/network-interfaces')
9 changes: 9 additions & 0 deletions tests/unit/test_oneview_client.py
Original file line number Diff line number Diff line change
@@ -77,6 +77,7 @@
from hpOneView.resources.security.roles import Roles
from hpOneView.resources.security.users import Users
from hpOneView.resources.settings.appliance_node_information import ApplianceNodeInformation
from hpOneView.resources.settings.appliance_network_interfaces import ApplianceNetworkInterfaces
from hpOneView.resources.settings.appliance_time_and_locale_configuration import ApplianceTimeAndLocaleConfiguration
from hpOneView.resources.settings.versions import Versions
from tests.test_utils import mock_builtin
@@ -890,6 +891,14 @@ def test_lazy_loading_appliance_node_information(self):
appliance_node_information = self._oneview.appliance_node_information
self.assertEqual(appliance_node_information, self._oneview.appliance_node_information)

def test_appliance_network_interfaces_has_right_type(self):
self.assertIsInstance(self._oneview.appliance_network_interfaces,
ApplianceNetworkInterfaces)

def test_lazy_loading_appliance_network_interfaces(self):
appliance_network_interfaces = self._oneview.appliance_network_interfaces
self.assertEqual(appliance_network_interfaces, self._oneview.appliance_network_interfaces)

def test_appliance_time_and_locale_configuration_has_right_type(self):
self.assertIsInstance(self._oneview.appliance_time_and_locale_configuration,
ApplianceTimeAndLocaleConfiguration)
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ envlist = docs, py34, py36, py27-coverage, py27-flake8
skip_missing_interpreters = true

[flake8]
ignore = E402
ignore = E402,W504,W605
max-line-length = 160
exclude = hpOneView/__init__.py
max-complexity = 14