Allow user to only specify capacity parameter

Previously, the endpoint parameter is required for attaching storage.
It returns InvalidParameterValueError exception when user only
specify capacity parameter. Fixed it by checking endpoint only when
it is not None.

Change-Id: Ie3da659f5c8e4fe35e19dc3ba60db7c83b6cfae7
This commit is contained in:
Lin Yang 2017-09-08 10:59:42 -07:00
parent 0203693ff7
commit b6360378d1
2 changed files with 7 additions and 1 deletions

View File

@ -306,7 +306,7 @@ class Node(base.ResourceBase):
valid_endpoints = attach_action.allowed_values
target_uri = attach_action.target_uri
if endpoint not in valid_endpoints:
if endpoint and endpoint not in valid_endpoints:
raise exceptions.InvalidParameterValueError(
parameter='endpoint', value=endpoint,
valid_values=valid_endpoints)

View File

@ -183,6 +183,12 @@ class NodeTestCase(testtools.TestCase):
self.node_inst.attach_endpoint,
endpoint='invalid')
def test_attach_endpoint_only_with_capacity_parameter(self):
self.node_inst.attach_endpoint(capacity=100)
self.node_inst._conn.post.assert_called_once_with(
'/redfish/v1/Nodes/Node1/Actions/ComposedNode.AttachEndpoint',
data={'CapacityGiB': 100})
def test_detach_endpoint(self):
self.node_inst.detach_endpoint(
endpoint='/redfish/v1/Chassis/PCIeSwitchChassis/Drives/Disk.Bay.3')