1010# License for the specific language governing permissions and limitations
1111# under the License.
1212
13- import json
1413import uuid
1514
1615from openstackclient .tests .functional import base
@@ -27,12 +26,13 @@ def test_aggregate_crud(self):
2726 'aggregate delete ' + name1 ,
2827 fail_ok = True ,
2928 )
30- cmd_output = json . loads ( self .openstack (
31- 'aggregate create -f json ' +
29+ cmd_output = self .openstack (
30+ 'aggregate create ' +
3231 '--zone nova ' +
3332 '--property a=b ' +
34- name1
35- ))
33+ name1 ,
34+ parse_output = True ,
35+ )
3636 self .assertEqual (
3737 name1 ,
3838 cmd_output ['name' ]
@@ -45,8 +45,10 @@ def test_aggregate_crud(self):
4545 'a' ,
4646 cmd_output ['properties' ]
4747 )
48- cmd_output = json .loads (self .openstack (
49- 'aggregate show -f json ' + name1 ))
48+ cmd_output = self .openstack (
49+ 'aggregate show ' + name1 ,
50+ parse_output = True ,
51+ )
5052 self .assertEqual (name1 , cmd_output ['name' ])
5153
5254 name2 = uuid .uuid4 ().hex
@@ -55,11 +57,12 @@ def test_aggregate_crud(self):
5557 'aggregate delete ' + name2 ,
5658 fail_ok = True ,
5759 )
58- cmd_output = json . loads ( self .openstack (
59- 'aggregate create -f json ' +
60+ cmd_output = self .openstack (
61+ 'aggregate create ' +
6062 '--zone external ' +
61- name2
62- ))
63+ name2 ,
64+ parse_output = True ,
65+ )
6366 self .assertEqual (
6467 name2 ,
6568 cmd_output ['name' ]
@@ -68,8 +71,10 @@ def test_aggregate_crud(self):
6871 'external' ,
6972 cmd_output ['availability_zone' ]
7073 )
71- cmd_output = json .loads (self .openstack (
72- 'aggregate show -f json ' + name2 ))
74+ cmd_output = self .openstack (
75+ 'aggregate show ' + name2 ,
76+ parse_output = True ,
77+ )
7378 self .assertEqual (name2 , cmd_output ['name' ])
7479
7580 # Test aggregate set
@@ -89,10 +94,11 @@ def test_aggregate_crud(self):
8994 )
9095 self .assertOutput ('' , raw_output )
9196
92- cmd_output = json .loads (self .openstack (
93- 'aggregate show -f json ' +
94- name3
95- ))
97+ cmd_output = self .openstack (
98+ 'aggregate show ' +
99+ name3 ,
100+ parse_output = True ,
101+ )
96102 self .assertEqual (
97103 name3 ,
98104 cmd_output ['name' ]
@@ -111,9 +117,10 @@ def test_aggregate_crud(self):
111117 )
112118
113119 # Test aggregate list
114- cmd_output = json .loads (self .openstack (
115- 'aggregate list -f json'
116- ))
120+ cmd_output = self .openstack (
121+ 'aggregate list' ,
122+ parse_output = True ,
123+ )
117124 names = [x ['Name' ] for x in cmd_output ]
118125 self .assertIn (name3 , names )
119126 self .assertIn (name2 , names )
@@ -122,9 +129,10 @@ def test_aggregate_crud(self):
122129 self .assertIn ('internal' , zones )
123130
124131 # Test aggregate list --long
125- cmd_output = json .loads (self .openstack (
126- 'aggregate list --long -f json'
127- ))
132+ cmd_output = self .openstack (
133+ 'aggregate list --long' ,
134+ parse_output = True ,
135+ )
128136 names = [x ['Name' ] for x in cmd_output ]
129137 self .assertIn (name3 , names )
130138 self .assertIn (name2 , names )
@@ -143,10 +151,11 @@ def test_aggregate_crud(self):
143151 )
144152 self .assertOutput ('' , raw_output )
145153
146- cmd_output = json .loads (self .openstack (
147- 'aggregate show -f json ' +
148- name3
149- ))
154+ cmd_output = self .openstack (
155+ 'aggregate show ' +
156+ name3 ,
157+ parse_output = True ,
158+ )
150159 self .assertNotIn (
151160 "c='d'" ,
152161 cmd_output ['properties' ]
@@ -163,9 +172,10 @@ def test_aggregate_crud(self):
163172 def test_aggregate_add_and_remove_host (self ):
164173 """Test aggregate add and remove host"""
165174 # Get a host
166- cmd_output = json .loads (self .openstack (
167- 'host list -f json'
168- ))
175+ cmd_output = self .openstack (
176+ 'host list' ,
177+ parse_output = True ,
178+ )
169179 host_name = cmd_output [0 ]['Host Name' ]
170180
171181 # NOTE(dtroyer): Cells v1 is not operable with aggregates. Hostnames
@@ -181,22 +191,24 @@ def test_aggregate_add_and_remove_host(self):
181191 )
182192
183193 # Test add host
184- cmd_output = json . loads ( self .openstack (
185- 'aggregate add host -f json ' +
194+ cmd_output = self .openstack (
195+ 'aggregate add host ' +
186196 name + ' ' +
187- host_name
188- ))
197+ host_name ,
198+ parse_output = True ,
199+ )
189200 self .assertIn (
190201 host_name ,
191202 cmd_output ['hosts' ]
192203 )
193204
194205 # Test remove host
195- cmd_output = json . loads ( self .openstack (
196- 'aggregate remove host -f json ' +
206+ cmd_output = self .openstack (
207+ 'aggregate remove host ' +
197208 name + ' ' +
198- host_name
199- ))
209+ host_name ,
210+ parse_output = True ,
211+ )
200212 self .assertNotIn (
201213 host_name ,
202214 cmd_output ['hosts' ]
0 commit comments