Skip to content

Commit

Permalink
[Unity]Add missing params for io limit policy (#215)
Browse files Browse the repository at this point in the history
added burst_rate,burst_time,burst_frequency parameters for
create_io_limit_policy
  • Loading branch information
peter-wangxu committed May 11, 2018
1 parent 7767775 commit d3e99bf
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 4 deletions.
2 changes: 2 additions & 0 deletions storops/unity/parser_configs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,9 @@ UnityIoLimitRuleSetting:
- label: maxKBPSDensity
- label: burstRate
- label: burstTime
converter: to_minute
- label: burstFrequency
converter: to_hour


UnityFileDnsServer:
Expand Down
8 changes: 6 additions & 2 deletions storops/unity/resource/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,17 @@ def get_io_limit_policy(self, _id=None, name=None, **filters):
def create_io_limit_policy(self, name, max_iops=None, max_kbps=None,
policy_type=None, is_shared=None,
description=None, max_iops_density=None,
max_kbps_density=None):
max_kbps_density=None, burst_rate=None,
burst_time=None, burst_frequency=None):
return UnityIoLimitPolicy.create(
self._cli, name, max_iops=max_iops, max_kbps=max_kbps,
policy_type=policy_type, is_shared=is_shared,
description=description,
max_iops_density=max_iops_density,
max_kbps_density=max_kbps_density)
max_kbps_density=max_kbps_density,
burst_rate=burst_rate,
burst_time=burst_time,
burst_frequency=burst_frequency)

def get_cg(self, _id=None, name=None, **filters):
return self._get_unity_rsc(UnityConsistencyGroupList, _id=_id,
Expand Down
4 changes: 2 additions & 2 deletions storops_test/unity/resource/test_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ def test_get_properties(self):
assert_that(len(settings), equal_to(1))

setting = settings[0]
assert_that(setting.burst_frequency, equal_to('01:00:00.000'))
assert_that(setting.burst_time, equal_to('00:05:00.000'))
assert_that(setting.burst_frequency, equal_to(1))
assert_that(setting.burst_time, equal_to(5))
assert_that(setting.get_id(), equal_to('qr_2'))
assert_that(setting.max_kbps, equal_to(2048))
assert_that(setting.name, equal_to('Limit_2_MBPS_rule'))
Expand Down
12 changes: 12 additions & 0 deletions storops_test/unity/resource/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,18 @@ def test_create_kbps_policy(self):
setting = policy.io_limit_rule_settings[0]
assert_that(setting.max_kbps, equal_to(1234))

@patch_rest
def test_create_burst_policy(self):
unity = t_unity()
policy = unity.create_io_limit_policy(
'burst_policy', description='storops', max_iops=1000,
max_kbps=20480, burst_rate=50, burst_time=10, burst_frequency=2)
assert_that(policy.name, equal_to('burst_policy'))
setting = policy.io_limit_rule_settings[0]
assert_that(setting.burst_rate, equal_to(50))
assert_that(setting.burst_time, equal_to(10))
assert_that(setting.burst_frequency, equal_to(2))

@patch_rest
def test_create_cg(self):
lun1 = UnityLun(cli=t_rest(), _id='sv_3339')
Expand Down
41 changes: 41 additions & 0 deletions storops_test/unity/rest_data/ioLimitPolicy/burst_policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"@base": "https://10.245.101.39/api/types/ioLimitPolicy/instances?filter=name eq \"puppet_policy\"&fields=description,effectiveIoLimitMaxIOPS,effectiveIoLimitMaxKBPS,id,instanceId,ioLimitRuleSettings,ioLimitRules,isPaused,isShared,luns,name,snaps,state,type&per_page=2000&compact=true",
"updated": "2018-05-10T02:50:37.250Z",
"links": [
{
"href": "&page=1",
"rel": "self"
}
],
"entries": [
{
"content": {
"description": "Created by puppet 12",
"ioLimitRuleSettings": [
{
"maxKBPS": 20480,
"burstRate": 50,
"burstFrequency": "02:00:00.000",
"instanceId": "qr_1",
"burstTime": "00:10:00.000",
"id": "qr_1",
"maxIOPS": 1000,
"name": "puppet_policy_rule"
}
],
"instanceId": "qp_1",
"ioLimitRules": [
{
"id": "qr_1"
}
],
"state": 3,
"isPaused": false,
"isShared": false,
"type": 1,
"id": "qp_1",
"name": "burst_policy"
}
}
]
}
25 changes: 25 additions & 0 deletions storops_test/unity/rest_data/ioLimitPolicy/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"url": "/api/types/ioLimitPolicy?compact=True&fields=attributes.description,attributes.displayValue,attributes.initialValue,attributes.name,attributes.type,description,documentation,name,type",
"response": "type.json"
},
{
"url": "/api/instances/ioLimitPolicy/qp_1?compact=True&fields=description,effectiveIoLimitMaxIOPS,effectiveIoLimitMaxKBPS,id,instanceId,ioLimitRuleSettings,ioLimitRules,isPaused,isShared,luns,name,snaps,state,type",
"response": "burst_policy.json"
},
{
"url": "/api/instances/ioLimitPolicy/qp_2?compact=True&fields=description,effectiveIoLimitMaxIOPS,effectiveIoLimitMaxKBPS,id,instanceId,ioLimitRuleSettings,ioLimitRules,isPaused,isShared,luns,name,snaps,state,type",
"response": "qp_2.json"
Expand Down Expand Up @@ -75,6 +79,27 @@
},
"response": "policy_name_used.json"
},
{
"url": "/api/types/ioLimitPolicy/instances?compact=True",
"body": {
"isShared": false,
"type": 1,
"description": "storops",
"ioLimitRules": [
{
"maxKBPS": 20480,
"burstRate": 50,
"burstFrequency": "02:00:00.000",
"burstTime": "00:10:00.000",
"maxIOPS": 1000,
"name": "burst_policy_rule"
}
],
"name": "burst_policy"
},
"response": "burst_policy.json"

},
{
"url": "/api/instances/ioLimitPolicy/qp_8?compact=True",
"response": "not_exist.json"
Expand Down

0 comments on commit d3e99bf

Please sign in to comment.