Skip to content

Commit

Permalink
Release 0.4.3
Browse files Browse the repository at this point in the history
Bugfix:
* Get file port for unity.
  • Loading branch information
Cedric Zhuang committed Dec 29, 2016
2 parents aac2e90 + 6901fdf commit 2d8ee79
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -13,7 +13,7 @@ StorOps: The Python Library for VNX & Unity
.. image:: https://landscape.io/github/emc-openstack/storops/master/landscape.svg?style=flat
:target: https://landscape.io/github/emc-openstack/storops/

VERSION: 0.4.2
VERSION: 0.4.3

A minimalist Python library to manage VNX/Unity systems.
This document lies in the source code and go with the release.
Expand Down
2 changes: 1 addition & 1 deletion storops/lib/resource.py
Expand Up @@ -303,7 +303,7 @@ def _is_updated(self):

def __add__(self, other):
if not isinstance(other, ResourceList):
raise TypeError
raise TypeError('Unsupported type {}'.format(type(other)))
return self.list + other.list


Expand Down
11 changes: 10 additions & 1 deletion storops/unity/resource/port.py 100644 → 100755
Expand Up @@ -23,7 +23,7 @@
from storops.exception import UnityEthernetPortMtuSizeNotSupportError
from storops.exception import UnityEthernetPortSpeedNotSupportError
from storops.unity.enums import EPSpeedValuesEnum, IOLimitPolicyTypeEnum

from storops.lib.version import version

__author__ = 'Jay Xu'

Expand All @@ -36,10 +36,17 @@ def set_mtu(self, mtu):
port.modify(mtu=mtu)

@instance_cache
@version('>=4.1')
def is_link_aggregation(self):
port = UnityLinkAggregation.get(self._cli, self.get_id())
return port.existed

@instance_cache # noqa
@version('<4.1')
def is_link_aggregation(self):
# Link aggregation is not supported before Falcon 4.1
return False

def get_physical_port(self):
"""Returns the link aggregation object or the ethernet port object."""
obj = None
Expand Down Expand Up @@ -237,6 +244,7 @@ def get_resource_class(cls):
return UnityEthernetPort


@version(">=4.1")
class UnityLinkAggregation(UnityResource):
@classmethod
def create(cls, cli, ports, mtu=None):
Expand All @@ -260,6 +268,7 @@ def modify(self, mtu=None, add_ports=None, remove_ports=None):
resp.raise_if_err()


@version(">=4.1")
class UnityLinkAggregationList(UnityResourceList):
@classmethod
def get_resource_class(cls):
Expand Down
20 changes: 20 additions & 0 deletions storops/unity/resource/system.py 100644 → 100755
Expand Up @@ -148,6 +148,25 @@ def get_ip_port(self, _id=None, name=None, **filters):
return self._get_unity_rsc(UnityIpPortList, _id=_id, name=name,
**filters)

@version(">=4.1")
def get_file_port(self):
"""Returns ports list can be used by File
File ports includes ethernet ports and link aggregation ports.
"""
eths = self.get_ethernet_port()
las = self.get_link_aggregation()
return eths + las

@version("<4.1") # noqa
def get_file_port(self):
"""Returns ports list can be used by File
File ports includes ethernet ports and link aggregation ports.
"""
eths = self.get_ethernet_port()
return eths.list

def get_file_interface(self, _id=None, name=None, **filters):
return self._get_unity_rsc(UnityFileInterfaceList, _id=_id, name=name,
**filters)
Expand Down Expand Up @@ -281,6 +300,7 @@ def get_disk(self, _id=None, name=None, **filters):
def info(self):
return UnityBasicSystemInfo.get(cli=self._cli)

@version('>=4.1')
def get_link_aggregation(self, _id=None, name=None, **filters):
return self._get_unity_rsc(UnityLinkAggregationList, _id=_id,
name=name,
Expand Down
12 changes: 12 additions & 0 deletions test/unity/resource/test_port.py 100644 → 100755
Expand Up @@ -23,6 +23,7 @@
from storops.exception import UnityEthernetPortSpeedNotSupportError, \
UnityEthernetPortMtuSizeNotSupportError, UnityResourceNotFoundError, \
UnityPolicyNameInUseError, UnityEthernetPortAlreadyAggregatedError
from storops.exception import SystemAPINotSupported
from storops.unity.enums import ConnectorTypeEnum, EPSpeedValuesEnum, \
FcSpeedEnum, IOLimitPolicyStateEnum
from storops.unity.resource.lun import UnityLun
Expand Down Expand Up @@ -59,6 +60,11 @@ def test_is_link_aggregation(self):
port = UnityIpPort('spa_la_2', cli=t_rest())
assert_that(port.is_link_aggregation(), equal_to(True))

@patch_rest
def test_is_link_aggregation_not_supported(self):
port = UnityIpPort('spa_eth6', cli=t_rest("4.0"))
assert_that(port.is_link_aggregation(), equal_to(False))

@patch_rest
def test_set_mtu_on_eth_port(self):
port = UnityIpPort('spa_eth3', cli=t_rest())
Expand Down Expand Up @@ -359,3 +365,9 @@ def test_modify(self):
la.modify(mtu=1500,
remove_ports=[UnityEthernetPort.get(t_rest(), "spa_eth2")],
add_ports=[UnityEthernetPort.get(t_rest(), "spa_eth4")])

@patch_rest()
def test_list_la_unsupported(self):
def f():
UnityLinkAggregation.get(t_rest("4.0.0"))
assert_that(f, raises(SystemAPINotSupported))
12 changes: 12 additions & 0 deletions test/unity/resource/test_system.py
Expand Up @@ -547,6 +547,18 @@ def test_get_link_aggregation_by_id(self):
cg = t_unity().get_link_aggregation(_id='spa_la_2')
assert_that(cg.id, equal_to('spa_la_2'))

@patch_rest
def test_get_file_port(self):
unity = UnitySystem(cli=t_rest("4.1.0"))
ports = unity.get_file_port()
assert_that(len(ports), equal_to(10))

@patch_rest
def test_get_file_port_la_unsupported(self):
unity = UnitySystem(cli=t_rest("4.0.0"))
ports = unity.get_file_port()
assert_that(len(ports), equal_to(8))

@patch_rest
def test_enable_performance_statistics(self):
unity = UnitySystem('10.244.223.61')
Expand Down

0 comments on commit 2d8ee79

Please sign in to comment.