Skip to content

Commit

Permalink
Release 0.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Murray-LIANG committed Dec 28, 2016
2 parents 93b0e11 + bfe0641 commit aac2e90
Show file tree
Hide file tree
Showing 15 changed files with 419 additions and 6 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -3,6 +3,7 @@ python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
install:
- pip install coveralls
- pip install -r requirements.txt
Expand Down
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.1
VERSION: 0.4.2

A minimalist Python library to manage VNX/Unity systems.
This document lies in the source code and go with the release.
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
@@ -1,4 +1,3 @@
enum34>=1.0.4
future>=0.15.1
paramiko>=1.13.0
python-dateutil>=2.4.2
Expand Down
12 changes: 11 additions & 1 deletion setup.py
Expand Up @@ -15,10 +15,13 @@
# under the License.

from __future__ import unicode_literals
from setuptools import setup, find_packages

import io
import os
import re
import sys

from setuptools import setup, find_packages

__author__ = 'Cedric Zhuang'

Expand Down Expand Up @@ -51,6 +54,12 @@ def read_requirements(filename):
return f.read().splitlines()


def install_requirements(filename):
packages = read_requirements(filename)
if sys.version_info < (3, 4):
packages.append("enum34>=1.0.4")


def get_description():
return "Python API for VNX and Unity."

Expand All @@ -77,6 +86,7 @@ def get_long_description():
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
"Natural Language :: English",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
Expand Down
15 changes: 15 additions & 0 deletions storops/unity/resource/host.py
Expand Up @@ -392,6 +392,21 @@ class UnityHostInitiatorPath(UnityResource):


class UnityHostInitiatorPathList(UnityResourceList):
def __init__(self, cli=None, is_logged_in=None, **filters):
super(UnityHostInitiatorPathList, self).__init__(cli, **filters)
self._is_logged_in = None
self._set_filter(is_logged_in)

def _set_filter(self, is_logged_in=None, **kwargs):
self._is_logged_in = is_logged_in

def _filter(self, initiator_path):
ret = True
if self._is_logged_in is not None:
ret &= (initiator_path.initiator.type == HostInitiatorTypeEnum.FC
and initiator_path.is_logged_in == self._is_logged_in)
return ret

@classmethod
def get_resource_class(cls):
return UnityHostInitiatorPath
Expand Down
42 changes: 42 additions & 0 deletions storops/unity/resource/port.py
Expand Up @@ -66,6 +66,20 @@ class UnityFcPort(UnityResource):


class UnityFcPortList(UnityResourceList):
def __init__(self, cli=None, port_ids=None, **filters):
super(UnityFcPortList, self).__init__(cli, **filters)
self._port_ids = None
self._set_filter(port_ids)

def _set_filter(self, port_ids=None, **kwargs):
self._port_ids = port_ids

def _filter(self, fc_port):
ret = True
if self._port_ids is not None:
ret &= fc_port.get_id() in self._port_ids
return ret

@classmethod
def get_resource_class(cls):
return UnityFcPort
Expand Down Expand Up @@ -144,6 +158,20 @@ def get_nested_properties(cls):


class UnityIscsiPortalList(UnityResourceList):
def __init__(self, cli=None, port_ids=None, **filters):
super(UnityIscsiPortalList, self).__init__(cli, **filters)
self._port_ids = None
self._set_filter(port_ids)

def _set_filter(self, port_ids=None, **kwargs):
self._port_ids = port_ids

def _filter(self, iscsi_portal):
ret = True
if self._port_ids is not None:
ret &= iscsi_portal.ethernet_port.get_id() in self._port_ids
return ret

@classmethod
def get_resource_class(cls):
return UnityIscsiPortal
Expand Down Expand Up @@ -190,6 +218,20 @@ def _get_peer_id(_id):


class UnityEthernetPortList(UnityResourceList):
def __init__(self, cli=None, port_ids=None, **filters):
super(UnityEthernetPortList, self).__init__(cli, **filters)
self._port_ids = None
self._set_filter(port_ids)

def _set_filter(self, port_ids=None, **kwargs):
self._port_ids = port_ids

def _filter(self, ethernet_port):
ret = True
if self._port_ids is not None:
ret &= ethernet_port.get_id() in self._port_ids
return ret

@classmethod
def get_resource_class(cls):
return UnityEthernetPort
Expand Down
16 changes: 16 additions & 0 deletions test/unity/resource/test_host.py
Expand Up @@ -503,3 +503,19 @@ def test_initiator_delete(self):
initiator = UnityHostInitiator(cli=t_rest(), _id='HostInitiator_2')
resp = initiator.delete()
assert_that(resp.is_ok(), equal_to(True))


class UnityHostInitiatorPathListTest(TestCase):
@patch_rest
def test_filter(self):
is_logged_in = True

all_paths = UnityHostInitiatorPathList(cli=t_rest())
paths = all_paths.shadow_copy(is_logged_in=is_logged_in)
assert_that(len(paths), equal_to(2))
assert_that(all(p.is_logged_in for p in paths), equal_to(True))

paths = UnityHostInitiatorPathList(cli=t_rest(),
is_logged_in=is_logged_in)
assert_that(len(paths), equal_to(2))
assert_that(all(p.is_logged_in for p in paths), equal_to(True))
2 changes: 2 additions & 0 deletions test/unity/resource/test_nas_server.py
Expand Up @@ -194,6 +194,8 @@ def f():

assert_that(f, raises(UnitySmbNameInUseError, 'name already exists'))


class UnityNasServerListTest(TestCase):
@patch_rest
def test_shadow_copy_home_sp(self):
nas_servers = UnityNasServerList(cli=t_rest(), home_sp='spa')
Expand Down
50 changes: 48 additions & 2 deletions test/unity/resource/test_port.py
Expand Up @@ -26,8 +26,9 @@
from storops.unity.enums import ConnectorTypeEnum, EPSpeedValuesEnum, \
FcSpeedEnum, IOLimitPolicyStateEnum
from storops.unity.resource.lun import UnityLun
from storops.unity.resource.port import UnityEthernetPort, UnityIpPort, \
UnityIpPortList, UnityIscsiPortal, UnityIscsiNode, UnityFcPort, \
from storops.unity.resource.port import UnityEthernetPort, \
UnityEthernetPortList, UnityIpPort, UnityIpPortList, UnityIscsiPortal, \
UnityIscsiPortalList, UnityIscsiNode, UnityFcPort, UnityFcPortList, \
UnityIoLimitRule, UnityIoLimitPolicy, UnityIoLimitPolicyList, \
UnityLinkAggregation
from storops.unity.resource.sp import UnityStorageProcessor
Expand Down Expand Up @@ -154,6 +155,21 @@ def test_get_peer(self, port_id, peer_id):
assert_that(peer.get_id(), equal_to(peer_id))


class UnityEthernetPortListTest(TestCase):
@patch_rest
def test_filter(self):
port_id = 'spa_eth2'

all_ports = UnityEthernetPortList(cli=t_rest())
ports = all_ports.shadow_copy(port_ids=[port_id])
assert_that(len(ports), equal_to(1))
assert_that(ports[0].get_id(), equal_to(port_id))

ports = UnityEthernetPortList(cli=t_rest(), port_ids=[port_id])
assert_that(len(ports), equal_to(1))
assert_that(ports[0].get_id(), equal_to(port_id))


class UnityIscsiPortalTest(TestCase):
@patch_rest
def test_get_properties(self):
Expand All @@ -166,6 +182,21 @@ def test_get_properties(self):
assert_that(portal.gateway, equal_to('10.244.213.1'))


class UnityIscsiPortalListTest(TestCase):
@patch_rest
def test_filter(self):
port_id = 'spa_eth2'

all_ports = UnityIscsiPortalList(cli=t_rest())
ports = all_ports.shadow_copy(port_ids=[port_id])
assert_that(len(ports), equal_to(2))
assert_that(set(ports.id), equal_to(set(['if_4', 'if_5'])))

ports = UnityIscsiPortalList(cli=t_rest(), port_ids=[port_id])
assert_that(len(ports), equal_to(2))
assert_that(set(ports.id), equal_to(set(['if_4', 'if_5'])))


class UnityFcPortTest(TestCase):
@patch_rest
def test_get_properties(self):
Expand All @@ -188,6 +219,21 @@ def test_get_properties(self):
equal_to(UnityStorageProcessor('spa', cli=t_rest())))


class UnityFcPortListTest(TestCase):
@patch_rest
def test_filter(self):
port_id = 'spa_iom_1_fc2'

all_ports = UnityFcPortList(cli=t_rest())
ports = all_ports.shadow_copy(port_ids=[port_id])
assert_that(len(ports), equal_to(1))
assert_that(ports[0].get_id(), equal_to(port_id))

ports = UnityFcPortList(cli=t_rest(), port_ids=[port_id])
assert_that(len(ports), equal_to(1))
assert_that(ports[0].get_id(), equal_to(port_id))


class UnityIoLimitRuleTest(TestCase):
@patch_rest
def test_get_properties(self):
Expand Down
112 changes: 112 additions & 0 deletions test/unity/rest_data/hostInitiatorPath/all.json
@@ -0,0 +1,112 @@
{
"@base": "https://10.244.223.61/api/types/hostInitiatorPath/instances?fields=health,hostPushName,hostUUID,id,instanceId,isLoggedIn,operationalStatus,registrationType,sessionIds,initiator.id,iscsiPortal.id,fcPort.id,iscsiTarget.id&per_page=2000&compact=true",
"updated": "2016-12-27T06:43:30.785Z",
"links": [
{
"href": "&page=1",
"rel": "self"
}
],
"entries": [
{
"content": {
"initiator": {
"id": "HostInitiator_1"
},
"registrationType": 2,
"operationalStatus": [],
"id": "HostInitiator_1_02:00:00:04",
"fcPort": {
"id": "spa_iom_1_fc0"
},
"hostUUID": "ef78e03c-b57b-4c82-96b0-da9a991fe6d9",
"instanceId": "root/emc:EMC_UEM_InitiatorPathLeaf%InstanceID=02:00:00:00:00:00:00:00:00:04:00:00:00:00:00:00:20:00:00:00:C9:F3:AB:0C:10:00:00:00:C9:F3:AB:0C:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00",
"isLoggedIn": true,
"hostPushName": "ESD-HOST193221.meng.lab.emc.com",
"sessionIds": [
"13512448"
]
}
},
{
"content": {
"initiator": {
"id": "HostInitiator_1"
},
"registrationType": 2,
"operationalStatus": [],
"id": "HostInitiator_1_02:00:00:05",
"fcPort": {
"id": "spa_iom_1_fc1"
},
"hostUUID": "ef78e03c-b57b-4c82-96b0-da9a991fe6d9",
"instanceId": "root/emc:EMC_UEM_InitiatorPathLeaf%InstanceID=02:00:00:00:00:00:00:00:00:05:00:00:00:00:00:00:20:00:00:00:C9:F3:AB:0C:10:00:00:00:C9:F3:AB:0C:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00",
"isLoggedIn": false,
"hostPushName": "ESD-HOST193221.meng.lab.emc.com",
"sessionIds": [
"13512448"
]
}
},
{
"content": {
"initiator": {
"id": "HostInitiator_2"
},
"registrationType": 2,
"operationalStatus": [],
"id": "HostInitiator_2_02:00:01:04",
"fcPort": {
"id": "spb_iom_1_fc0"
},
"hostUUID": "ef78e03c-b57b-4c82-96b0-da9a991fe6d9",
"instanceId": "root/emc:EMC_UEM_InitiatorPathLeaf%InstanceID=02:00:00:00:00:00:00:00:01:04:00:00:00:00:00:00:20:00:00:00:C9:F3:AB:0D:10:00:00:00:C9:F3:AB:0D:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00",
"isLoggedIn": true,
"hostPushName": "ESD-HOST193221.meng.lab.emc.com",
"sessionIds": [
"13511424"
]
}
},
{
"content": {
"initiator": {
"id": "HostInitiator_2"
},
"registrationType": 2,
"operationalStatus": [],
"id": "HostInitiator_2_02:00:01:05",
"fcPort": {
"id": "spb_iom_1_fc1"
},
"hostUUID": "ef78e03c-b57b-4c82-96b0-da9a991fe6d9",
"instanceId": "root/emc:EMC_UEM_InitiatorPathLeaf%InstanceID=02:00:00:00:00:00:00:00:01:05:00:00:00:00:00:00:20:00:00:00:C9:F3:AB:0D:10:00:00:00:C9:F3:AB:0D:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00",
"isLoggedIn": false,
"hostPushName": "ESD-HOST193221.meng.lab.emc.com",
"sessionIds": [
"13511424"
]
}
},
{
"content": {
"initiator": {
"id": "HostInitiator_3"
},
"registrationType": 2,
"operationalStatus": [],
"id": "HostInitiator_3_02:00:01:04",
"fcPort": {
"id": "spb_iom_1_fc0"
},
"hostUUID": "345119f3-d49a-456a-948b-829e81dfdd9e",
"instanceId": "root/emc:EMC_UEM_InitiatorPathLeaf%InstanceID=02:00:00:00:00:00:00:00:01:04:00:00:00:00:00:00:20:00:00:90:FA:53:41:41:10:00:00:90:FA:53:41:41:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00",
"isLoggedIn": true,
"hostPushName": "ESD-HOST198232.meng.lab.emc.com",
"sessionIds": [
"13124352"
]
}
}
]
}
12 changes: 12 additions & 0 deletions test/unity/rest_data/hostInitiatorPath/index.json
@@ -0,0 +1,12 @@
{
"indices": [
{
"url": "/api/types/hostInitiatorPath?compact=True&fields=attributes.description,attributes.displayValue,attributes.initialValue,attributes.name,attributes.type,description,documentation,name,type",
"response": "type.json"
},
{
"url": "/api/types/hostInitiatorPath/instances?compact=True&fields=fcPort,health,hostPushName,hostUUID,id,initiator,instanceId,isLoggedIn,iscsiPortal,iscsiTarget,operationalStatus,registrationType,sessionIds",
"response": "all.json"
}
]
}

0 comments on commit aac2e90

Please sign in to comment.