Skip to content

Commit

Permalink
Expose get_fc_port api in UnitySystem
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianqi-Tang committed Oct 18, 2016
1 parent d191683 commit f123104
Show file tree
Hide file tree
Showing 8 changed files with 1,616 additions and 675 deletions.
1,348 changes: 676 additions & 672 deletions storops/unity/enums.py

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion storops/unity/resource/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from storops.unity.resource.snap import UnitySnapList
from storops.unity.resource.sp import UnityStorageProcessorList
from storops.unity.resource.port import UnityEthernetPortList, \
UnityIscsiPortalList
UnityIscsiPortalList, UnityFcPortList
from storops.unity.resource.vmware import UnityCapabilityProfileList

__author__ = 'Jay Xu'
Expand Down Expand Up @@ -67,6 +67,9 @@ def get_sp(self, _id=None, name=None, **filters):
def get_iscsi_portal(self, _id=None, **filters):
return self._get_unity_rsc(UnityIscsiPortalList, _id=_id, **filters)

def get_fc_port(self, _id=None, **filters):
return self._get_unity_rsc(UnityFcPortList, _id=_id, **filters)

def get_ethernet_port(self, _id=None, name=None, **filters):
return self._get_unity_rsc(UnityEthernetPortList, _id=_id,
name=name, **filters)
Expand Down
27 changes: 25 additions & 2 deletions test/unity/resource/test_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
from hamcrest import assert_that, equal_to, instance_of, only_contains, raises
from storops.exception import UnityEthernetPortSpeedNotSupportError, \
UnityEthernetPortMtuSizeNotSupportError
from storops.unity.enums import ConnectorTypeEnum, EPSpeedValuesEnum
from storops.unity.enums import ConnectorTypeEnum, EPSpeedValuesEnum, \
FcSpeedEnum
from storops.unity.resource.port import UnityEthernetPort, UnityIpPort, \
UnityIpPortList
UnityIpPortList, UnityFcPort
from storops.unity.resource.sp import UnityStorageProcessor
from test.unity.rest_mock import t_rest, patch_rest

Expand Down Expand Up @@ -113,3 +114,25 @@ def test_get_peer(self, port_id, peer_id):
port = UnityEthernetPort(cli=t_rest(), _id=port_id)
peer = port.get_peer()
assert_that(peer.get_id(), equal_to(peer_id))


class UnityFcPortTest(TestCase):
@patch_rest
def test_get_properties(self):
port = UnityFcPort('spa_fc4', cli=t_rest())
assert_that(port.existed, True)
assert_that(port.slot_number, 4)
assert_that(
port.wwn,
equal_to("50:06:01:60:C7:E0:01:DA:50:06:01:62:47:E0:01:DA"))
assert_that(port.available_speeds,
only_contains(FcSpeedEnum._4GbPS,
FcSpeedEnum._8GbPS,
FcSpeedEnum._16GbPS,
FcSpeedEnum.AUTO))
assert_that(port.connector_type,
equal_to(ConnectorTypeEnum.LC))
assert_that(port.name,
equal_to("SP A FC Port 4"))
assert_that(port.storage_processor,
UnityStorageProcessor('spa', cli=t_rest()))
8 changes: 8 additions & 0 deletions test/unity/resource/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from storops.unity.resource.nfs_server import UnityNfsServerList
from storops.unity.resource.nfs_share import UnityNfsShareList
from storops.unity.resource.pool import UnityPoolList
from storops.unity.resource.port import UnityFcPortList
from storops.unity.resource.lun import UnityLunList
from storops.unity.resource.port import UnityIpPortList
from storops.unity.resource.snap import UnitySnapList
Expand Down Expand Up @@ -367,6 +368,13 @@ def test_get_doc_resource(self):
assert_that(doc, contains_string(
'For a file system or VMware NFS datastore'))

@patch_rest
def test_get_fc_port(self):
unity = t_unity()
fi_list = unity.get_fc_port()
assert_that(fi_list, instance_of(UnityFcPortList))
assert_that(len(fi_list), equal_to(12))


class UnityDpeTest(TestCase):
@patch_rest
Expand Down
Loading

0 comments on commit f123104

Please sign in to comment.