Skip to content

Commit

Permalink
[GH-30] Add fc port list support
Browse files Browse the repository at this point in the history
Adds a new API get_fc_port in class UnitySystem to get all the fc
ports of the system.
  • Loading branch information
Tianqi-Tang committed Oct 21, 2016
1 parent 10a66eb commit 12502f7
Show file tree
Hide file tree
Showing 8 changed files with 944 additions and 3 deletions.
4 changes: 4 additions & 0 deletions storops/unity/enums.py
Expand Up @@ -544,6 +544,10 @@ class ConnectorTypeEnum(UnityEnum):
RJ45 = (1, 'RJ45')
LC = (2, 'LC')
MINI_SAS_HD = (3, 'MiniSAS HD')
COPPER_PIGTAIL = (4, "Copper pigtail")
NO_SEPARABLE_CONNECTOR = (5, "No separable connector")
NAS_COPPER = (6, "NAS copper")
NOT_PRESENT = (7, "Not present")


class EPSpeedValuesEnum(UnityEnum):
Expand Down
5 changes: 4 additions & 1 deletion storops/unity/resource/system.py
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
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, UnityIscsiPortal, UnityIscsiNode
UnityIpPortList, UnityIscsiPortal, UnityIscsiNode, UnityFcPort
from storops.unity.resource.sp import UnityStorageProcessor
from test.unity.rest_mock import t_rest, patch_rest

Expand Down Expand Up @@ -125,3 +126,25 @@ def test_get_properties(self):
equal_to('iqn.1992-04.com.emc:cx.fnm00150600267.a0'))
assert_that(portal.netmask, equal_to('255.255.255.0'))
assert_that(portal.gateway, equal_to('10.244.213.1'))


class UnityFcPortTest(TestCase):
@patch_rest
def test_get_properties(self):
port = UnityFcPort('spa_fc4', cli=t_rest())
assert_that(port.existed, equal_to(True))
assert_that(port.slot_number, equal_to(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,
equal_to(UnityStorageProcessor('spa', cli=t_rest())))
8 changes: 8 additions & 0 deletions test/unity/resource/test_system.py
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

0 comments on commit 12502f7

Please sign in to comment.