Correct all RSD 2.1 files format

Change-Id: I078c9422ec3782b771ac2bb14626a70ca15a3438
This commit is contained in:
Lin Yang 2019-05-30 11:15:08 -07:00
parent a5a4ef9c83
commit 0d79c5eaa1
9 changed files with 36 additions and 58 deletions

View File

@ -187,7 +187,6 @@ class EthernetSwitchPort(rsd_lib_base.ResourceBase):
class EthernetSwitchPortCollection(rsd_lib_base.ResourceCollectionBase): class EthernetSwitchPortCollection(rsd_lib_base.ResourceCollectionBase):
@property @property
def _resource_type(self): def _resource_type(self):
return EthernetSwitchPort return EthernetSwitchPort

View File

@ -55,9 +55,7 @@ class EthernetSwitchStaticMAC(rsd_lib_base.ResourceBase):
if vlan_id is not None: if vlan_id is not None:
if not isinstance(vlan_id, int): if not isinstance(vlan_id, int):
raise exceptions.InvalidParameterValueError( raise exceptions.InvalidParameterValueError(
parameter="vlan_id", parameter="vlan_id", value=vlan_id, valid_values="int"
value=vlan_id,
valid_values="int",
) )
data["VLANId"] = vlan_id data["VLANId"] = vlan_id
@ -69,7 +67,6 @@ class EthernetSwitchStaticMAC(rsd_lib_base.ResourceBase):
class EthernetSwitchStaticMACCollection(rsd_lib_base.ResourceCollectionBase): class EthernetSwitchStaticMACCollection(rsd_lib_base.ResourceCollectionBase):
@property @property
def _resource_type(self): def _resource_type(self):
return EthernetSwitchStaticMAC return EthernetSwitchStaticMAC

View File

@ -145,18 +145,9 @@ port_req_schema = {
"type": "object", "type": "object",
"properties": { "properties": {
"PortId": {"type": "number"}, "PortId": {"type": "number"},
"LinkType": { "LinkType": {"type": "string", "enum": ["Ethernet", "PCIe"]},
"type": "string", "OperationalState": {"type": "string", "enum": ["Up", "Down"]},
"enum": ["Ethernet", "PCIe"], "AdministrativeState": {"type": "string", "enum": ["Up", "Down"]},
},
"OperationalState": {
"type": "string",
"enum": ["Up", "Down"],
},
"AdministrativeState": {
"type": "string",
"enum": ["Up", "Down"],
},
"LinkSpeedMbps": {"type": ["number", "null"]}, "LinkSpeedMbps": {"type": ["number", "null"]},
"NeighborInfo": { "NeighborInfo": {
"type": "object", "type": "object",

View File

@ -189,9 +189,7 @@ class TestChassis(base.TestCase):
def test_power(self): def test_power(self):
# | GIVEN | # | GIVEN |
self.conn.get.return_value.json.reset_mock() self.conn.get.return_value.json.reset_mock()
with open( with open("rsd_lib/tests/unit/json_samples/v2_1/power.json", "r") as f:
"rsd_lib/tests/unit/json_samples/v2_1/power.json", "r"
) as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
# | WHEN | # | WHEN |
actual_power = self.chassis_inst.power actual_power = self.chassis_inst.power
@ -208,9 +206,7 @@ class TestChassis(base.TestCase):
def test_power_on_refresh(self): def test_power_on_refresh(self):
# | GIVEN | # | GIVEN |
with open( with open("rsd_lib/tests/unit/json_samples/v2_1/power.json", "r") as f:
"rsd_lib/tests/unit/json_samples/v2_1/power.json", "r"
) as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
# | WHEN & THEN | # | WHEN & THEN |
self.assertIsInstance(self.chassis_inst.power, power.Power) self.assertIsInstance(self.chassis_inst.power, power.Power)
@ -225,9 +221,7 @@ class TestChassis(base.TestCase):
self.chassis_inst.refresh(force=False) self.chassis_inst.refresh(force=False)
# | GIVEN | # | GIVEN |
with open( with open("rsd_lib/tests/unit/json_samples/v2_1/power.json", "r") as f:
"rsd_lib/tests/unit/json_samples/v2_1/power.json", "r"
) as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
# | WHEN & THEN | # | WHEN & THEN |
self.assertIsInstance(self.chassis_inst.power, power.Power) self.assertIsInstance(self.chassis_inst.power, power.Power)

View File

@ -87,7 +87,7 @@ class EthernetSwitchACLTestCase(testtools.TestCase):
data={ data={
"Port": { "Port": {
"@odata.id": "/redfish/v1/EthernetSwitches/Switch1/Ports/" "@odata.id": "/redfish/v1/EthernetSwitches/Switch1/Ports/"
"sw0p2" "sw0p2"
} }
}, },
) )
@ -127,7 +127,7 @@ class EthernetSwitchACLTestCase(testtools.TestCase):
data={ data={
"Port": { "Port": {
"@odata.id": "/redfish/v1/EthernetSwitches/Switch1/Ports/" "@odata.id": "/redfish/v1/EthernetSwitches/Switch1/Ports/"
"sw0p1" "sw0p1"
} }
}, },
) )
@ -220,7 +220,7 @@ class EthernetSwitchACLCollectionTestCase(testtools.TestCase):
None, None,
headers={ headers={
"Location": "https://localhost:8443/redfish/v1/" "Location": "https://localhost:8443/redfish/v1/"
"EthernetSwitches/Switch1/ACLs/ACL1" "EthernetSwitches/Switch1/ACLs/ACL1"
}, },
) )
self.acl_col = ethernet_switch_acl.EthernetSwitchACLCollection( self.acl_col = ethernet_switch_acl.EthernetSwitchACLCollection(
@ -265,9 +265,8 @@ class EthernetSwitchACLCollectionTestCase(testtools.TestCase):
def test_create_acl(self): def test_create_acl(self):
result = self.acl_col.create_acl() result = self.acl_col.create_acl()
self.acl_col._conn.post.assert_called_once_with( self.acl_col._conn.post.assert_called_once_with(
"/redfish/v1/EthernetSwitches/Switch1/ACLs", data={}, "/redfish/v1/EthernetSwitches/Switch1/ACLs", data={}
) )
self.assertEqual( self.assertEqual(
result, result, "/redfish/v1/EthernetSwitches/Switch1/ACLs/ACL1"
"/redfish/v1/EthernetSwitches/Switch1/ACLs/ACL1",
) )

View File

@ -151,9 +151,7 @@ class EthernetSwitchACLRuleTestCase(testtools.TestCase):
) as f: ) as f:
self.conn.get.return_value.json.return_value = json.loads(f.read()) self.conn.get.return_value.json.return_value = json.loads(f.read())
# | WHEN | # | WHEN |
actual_mirror_port_region = ( actual_mirror_port_region = self.acl_rule_inst.mirror_port_region
self.acl_rule_inst.mirror_port_region
)
# | THEN | # | THEN |
self.assertIsInstance(actual_mirror_port_region, list) self.assertIsInstance(actual_mirror_port_region, list)
self.conn.get.return_value.json.assert_called_with() self.conn.get.return_value.json.assert_called_with()
@ -163,8 +161,7 @@ class EthernetSwitchACLRuleTestCase(testtools.TestCase):
# | WHEN & THEN | # | WHEN & THEN |
# tests for same object on invoking subsequently # tests for same object on invoking subsequently
self.assertIs( self.assertIs(
actual_mirror_port_region, actual_mirror_port_region, self.acl_rule_inst.mirror_port_region
self.acl_rule_inst.mirror_port_region,
) )
self.conn.get.return_value.json.assert_not_called() self.conn.get.return_value.json.assert_not_called()
@ -202,10 +199,7 @@ class EthernetSwitchACLRuleTestCase(testtools.TestCase):
"RuleId": 1, "RuleId": 1,
"Action": "Permit", "Action": "Permit",
"Condition": { "Condition": {
"IPSource": { "IPSource": {"IPv4Address": "192.168.6.0", "Mask": "0.0.0.255"}
"IPv4Address": "192.168.6.0",
"Mask": "0.0.0.255",
},
}, },
} }
self.acl_rule_inst.update(data) self.acl_rule_inst.update(data)

View File

@ -252,17 +252,20 @@ class EthernetSwitchPortTestCase(testtools.TestCase):
"Switch1/Ports/Port11/VLans/VLan1" "Switch1/Ports/Port11/VLans/VLan1"
}, },
"PortMembers": [ "PortMembers": [
{"@odata.id": "/redfish/v1/EthernetSwitches/" {
"Switch1/Ports/Port10"}, "@odata.id": "/redfish/v1/EthernetSwitches/"
{"@odata.id": "/redfish/v1/EthernetSwitches/" "Switch1/Ports/Port10"
"Switch1/Ports/Port12"}, },
{
"@odata.id": "/redfish/v1/EthernetSwitches/"
"Switch1/Ports/Port12"
},
], ],
}, },
} }
self.port_inst.update(data) self.port_inst.update(data)
self.port_inst._conn.patch.assert_called_once_with( self.port_inst._conn.patch.assert_called_once_with(
"/redfish/v1/EthernetSwitches/Switch1/Ports/Port1", "/redfish/v1/EthernetSwitches/Switch1/Ports/Port1", data=data
data=data,
) )
@ -330,11 +333,15 @@ class EthernetSwitchPortCollectionTestCase(testtools.TestCase):
"PortMode": "LinkAggregationStatic", "PortMode": "LinkAggregationStatic",
"Links": { "Links": {
"PortMembers": [ "PortMembers": [
{"@odata.id": "/redfish/v1/EthernetSwitches/" {
"Switch1/Ports/Port10"}, "@odata.id": "/redfish/v1/EthernetSwitches/"
{"@odata.id": "/redfish/v1/EthernetSwitches/" "Switch1/Ports/Port10"
"Switch1/Ports/Port11"}, },
], {
"@odata.id": "/redfish/v1/EthernetSwitches/"
"Switch1/Ports/Port11"
},
]
}, },
} }
result = self.port_col.create_port(reqs) result = self.port_col.create_port(reqs)
@ -342,6 +349,5 @@ class EthernetSwitchPortCollectionTestCase(testtools.TestCase):
"/redfish/v1/EthernetSwitches/Switch1/Ports", data=reqs "/redfish/v1/EthernetSwitches/Switch1/Ports", data=reqs
) )
self.assertEqual( self.assertEqual(
result, result, "/redfish/v1/EthernetSwitches/Switch1/Ports/Port1"
"/redfish/v1/EthernetSwitches/Switch1/Ports/Port1",
) )

View File

@ -63,9 +63,7 @@ class EthernetSwitchStaticMACTestCase(testtools.TestCase):
self.static_mac_inst._conn.patch.reset_mock() self.static_mac_inst._conn.patch.reset_mock()
reqs = {"MACAddress": "00:11:22:33:44:55", "VLANId": 69} reqs = {"MACAddress": "00:11:22:33:44:55", "VLANId": 69}
self.static_mac_inst.update( self.static_mac_inst.update("00:11:22:33:44:55", vlan_id=69)
"00:11:22:33:44:55", vlan_id=69
)
self.static_mac_inst._conn.patch.assert_called_once_with( self.static_mac_inst._conn.patch.assert_called_once_with(
"/redfish/v1/EthernetSwitches/Switch1/Ports/StaticMACs/1", "/redfish/v1/EthernetSwitches/Switch1/Ports/StaticMACs/1",
data=reqs, data=reqs,

View File

@ -159,7 +159,7 @@ class DriveTestCase(testtools.TestCase):
with self.assertRaisesRegex( with self.assertRaisesRegex(
exceptions.InvalidParameterValueError, exceptions.InvalidParameterValueError,
'The parameter "erase_on_detach" value "invalid string" is ' 'The parameter "erase_on_detach" value "invalid string" is '
'invalid', "invalid",
): ):
self.drive_inst.update(erase_on_detach="invalid string") self.drive_inst.update(erase_on_detach="invalid string")