Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit 2daa16a

Browse files
authored
Merge pull request #379 from HewlettPackard/api500/600/planscripts
Api500/600/planscripts
2 parents fab0e98 + aae17a9 commit 2daa16a

File tree

5 files changed

+38
-7
lines changed

5 files changed

+38
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Extends support of the SDK to OneView Rest API version 600 (OneView v4.0).
88
- Interconnect
99
- Network set
1010
- OS deployment plan
11+
- Plan script
1112
- Storage pool
1213
- Storage volume
1314

endpoints-support.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -615,10 +615,10 @@
615615
|<sub> /rest/os-volumes/{id}</sub> | GET | :white_check_mark: |
616616
|<sub> /rest/os-volumes/archive/{id}</sub> | GET | :white_check_mark: |
617617
| **Plan Scripts** |
618-
|<sub> /rest/plan-scripts</sub> | POST | :white_check_mark: |
619-
|<sub> /rest/plan-scripts/differences/{id}</sub> | POST | :white_check_mark: |
620-
|<sub> /rest/plan-scripts</sub> | GET | :white_check_mark: |
621-
|<sub> /rest/plan-scripts/{id}</sub> | GET | :white_check_mark: |
622-
|<sub> /rest/plan-scripts/{id}</sub> | PUT | :white_check_mark: |
623-
|<sub> /rest/plan-scripts/{id}</sub> | DELETE | :white_check_mark: |
624-
618+
|<sub> /rest/plan-scripts</sub> | POST | :white_check_mark: | :white_check_mark: | :white_check_mark: |
619+
|<sub> /rest/plan-scripts/differences/{id}</sub> | POST | :white_check_mark: | :white_check_mark: | :white_check_mark: |
620+
|<sub> /rest/plan-scripts</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
621+
|<sub> /rest/plan-scripts/{id}</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
622+
|<sub> /rest/plan-scripts/{id}</sub> | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: |
623+
|<sub> /rest/plan-scripts/{id}</sub> | DELETE | :white_check_mark: | :white_check_mark: | :white_check_mark: |
624+
|<sub> /rest/plan-scripts/{id}/usedby/readonly</sub> | GET | :heavy_minus_sign: | :heavy_minus_sign: | :white_check_mark: |

examples/image_streamer/plan_scripts.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
"content": 'echo "test script"'
4040
}
4141

42+
# plan script which is used by buils plans and is readonly
43+
plan_script_id_readyonly = "590746df-7354-42aa-8887-e1ea122f7ed6"
44+
4245
# Create a Plan Script
4346
print("Create a Plan Script")
4447
plan_script = image_streamer_client.plan_scripts.create(plan_script_information)
@@ -72,6 +75,13 @@
7275
print(plan_script_item['name'])
7376
print("***** done *****\n")
7477

78+
# Get used by and read only
79+
print("Gets builds plans which uses a particular read only plan script")
80+
build_plans = image_streamer_client.plan_scripts.get_usedby_and_readonly(plan_script_id_readyonly)
81+
for build_plan_item in build_plans:
82+
print(build_plan_item["name"])
83+
print("**********done***********\n")
84+
7585
# Delete the Plan Script
7686
print("Delete the Plan Script")
7787
image_streamer_client.plan_scripts.delete(plan_script)

hpOneView/image_streamer/resources/plan_scripts.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,16 @@ def retrieve_differences(self, id_or_uri, content, timeout=-1):
168168
"""
169169
uri = self.URI + "/differences/" + extract_id_from_uri(id_or_uri)
170170
return self._client.create(content, uri=uri, timeout=timeout)
171+
172+
def get_usedby_and_readonly(self, id):
173+
"""
174+
Gets the build plans details os teh selected plan script as per the selected attributes.
175+
176+
Args:
177+
id: ID of the Plan Script.
178+
179+
Returns:
180+
array of build plans
181+
"""
182+
uri = self.URI + "/" + id + "/usedby/readonly"
183+
return self._client.get(uri)

tests/unit/image_streamer/resources/test_plan_scripts.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,10 @@ def test_retrieve_differences_with_id(self, mock_create):
125125
mock_create.assert_called_once_with("content",
126126
timeout=-1,
127127
uri='/rest/plan-scripts/differences/3518be0e-17c1-4189-8f81-83f3724f6155')
128+
129+
@mock.patch.object(ResourceClient, 'get')
130+
def test_get_usedby_and_readonly(self, mock_get):
131+
self._client.get_usedby_and_readonly('cbfd487e-3d92-4eb4-b877-f9ea7c16a271')
132+
133+
mock_get.assert_called_once_with(
134+
'/rest/plan-scripts/cbfd487e-3d92-4eb4-b877-f9ea7c16a271/usedby/readonly')

0 commit comments

Comments
 (0)