Add HPE extensions support to redfish connection lib
This commit adds support to have HPE root and system resource extensions to redfish connection library. Partial-Bug: #1691955 Change-Id: I65bf78d6471a5246465e0a6b226844748888ca73
This commit is contained in:
parent
100c058a09
commit
3ff2a0582f
|
@ -0,0 +1,35 @@
|
|||
# Copyright 2017 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.
|
||||
|
||||
__author__ = 'HPE'
|
||||
|
||||
from proliantutils.redfish.resources.system import system
|
||||
import sushy
|
||||
|
||||
|
||||
class HPESushy(sushy.Sushy):
|
||||
"""Class that extends base Sushy class
|
||||
|
||||
This class extends the Sushy class to override certain methods
|
||||
required to customize the functionality of different resources
|
||||
"""
|
||||
|
||||
def get_system(self, identity):
|
||||
"""Given the identity return a HPESystem object
|
||||
|
||||
:param identity: The identity of the System resource
|
||||
:returns: The System object
|
||||
"""
|
||||
return system.HPESystem(self._conn, identity,
|
||||
redfish_version=self.redfish_version)
|
|
@ -20,6 +20,7 @@ import sushy
|
|||
from proliantutils import exception
|
||||
from proliantutils.ilo import operations
|
||||
from proliantutils import log
|
||||
from proliantutils.redfish import main
|
||||
|
||||
|
||||
"""
|
||||
|
@ -81,7 +82,7 @@ class RedfishOperations(operations.IloOperations):
|
|||
self._root_prefix = root_prefix
|
||||
|
||||
try:
|
||||
self._sushy = sushy.Sushy(
|
||||
self._sushy = main.HPESushy(
|
||||
address, username=username, password=password,
|
||||
root_prefix=root_prefix, verify=verify)
|
||||
except sushy.exceptions.SushyError as e:
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
# Copyright 2017 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.
|
||||
|
||||
__author__ = 'HPE'
|
||||
|
||||
from sushy.resources.system import system
|
||||
|
||||
|
||||
class HPESystem(system.System):
|
||||
"""Class that extends the functionality of System resource class
|
||||
|
||||
This class extends the functionality of System resource class
|
||||
from sushy
|
||||
"""
|
|
@ -0,0 +1,40 @@
|
|||
# Copyright 2017 Hewlett Packard Enterprise Development LP
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import mock
|
||||
from sushy import connector
|
||||
import testtools
|
||||
|
||||
from proliantutils.redfish import main
|
||||
from proliantutils.redfish.resources.system import system
|
||||
|
||||
|
||||
class HPESushyTestCase(testtools.TestCase):
|
||||
|
||||
@mock.patch.object(connector, 'Connector', autospec=True)
|
||||
def setUp(self, connector_mock):
|
||||
super(HPESushyTestCase, self).setUp()
|
||||
self.hpe_sushy = main.HPESushy('https://1.2.3.4',
|
||||
username='foo',
|
||||
password='bar')
|
||||
|
||||
@mock.patch.object(system, 'HPESystem', autospec=True)
|
||||
def test_get_system(self, mock_system):
|
||||
sys_inst = self.hpe_sushy.get_system('1234')
|
||||
self.assertTrue(isinstance(sys_inst,
|
||||
system.HPESystem.__class__))
|
||||
mock_system.assert_called_once_with(self.hpe_sushy._conn,
|
||||
'1234',
|
||||
self.hpe_sushy.redfish_version)
|
|
@ -20,12 +20,13 @@ import sushy
|
|||
import testtools
|
||||
|
||||
from proliantutils import exception
|
||||
from proliantutils.redfish import main
|
||||
from proliantutils.redfish import redfish
|
||||
|
||||
|
||||
class RedfishOperationsTestCase(testtools.TestCase):
|
||||
|
||||
@mock.patch.object(sushy, 'Sushy', autospec=True)
|
||||
@mock.patch.object(main, 'HPESushy', autospec=True)
|
||||
def setUp(self, sushy_mock):
|
||||
super(RedfishOperationsTestCase, self).setUp()
|
||||
self.sushy = mock.MagicMock()
|
||||
|
@ -39,7 +40,7 @@ class RedfishOperationsTestCase(testtools.TestCase):
|
|||
sushy_mock.assert_called_once_with(
|
||||
'https://1.2.3.4', 'foo', 'bar', '/redfish/v1/', False)
|
||||
|
||||
@mock.patch.object(sushy, 'Sushy', autospec=True)
|
||||
@mock.patch.object(main, 'HPESushy', autospec=True)
|
||||
def test_sushy_init_fail(self, sushy_mock):
|
||||
sushy_mock.side_effect = sushy.exceptions.SushyError
|
||||
self.assertRaisesRegex(
|
||||
|
|
Loading…
Reference in New Issue