1717
1818
1919class AggregateTests (base .TestCase ):
20- """Functional tests for aggregate. """
20+ """Functional tests for aggregate"""
2121
2222 def test_aggregate_create_and_delete (self ):
2323 """Test create, delete multiple"""
2424 name1 = uuid .uuid4 ().hex
2525 cmd_output = json .loads (self .openstack (
2626 'aggregate create -f json ' +
2727 '--zone nova ' +
28- name1 ))
28+ name1
29+ ))
2930 self .assertEqual (
3031 name1 ,
3132 cmd_output ['name' ]
@@ -39,7 +40,8 @@ def test_aggregate_create_and_delete(self):
3940 cmd_output = json .loads (self .openstack (
4041 'aggregate create -f json ' +
4142 '--zone nova ' +
42- name2 ))
43+ name2
44+ ))
4345 self .assertEqual (
4446 name2 ,
4547 cmd_output ['name' ]
@@ -50,7 +52,10 @@ def test_aggregate_create_and_delete(self):
5052 )
5153
5254 del_output = self .openstack (
53- 'aggregate delete ' + name1 + ' ' + name2 )
55+ 'aggregate delete ' +
56+ name1 + ' ' +
57+ name2
58+ )
5459 self .assertOutput ('' , del_output )
5560
5661 def test_aggregate_list (self ):
@@ -60,19 +65,22 @@ def test_aggregate_list(self):
6065 'aggregate create ' +
6166 '--zone nova ' +
6267 '--property a=b ' +
63- name1 )
68+ name1
69+ )
6470 self .addCleanup (self .openstack , 'aggregate delete ' + name1 )
6571
6672 name2 = uuid .uuid4 ().hex
6773 self .openstack (
6874 'aggregate create ' +
6975 '--zone internal ' +
7076 '--property c=d ' +
71- name2 )
77+ name2
78+ )
7279 self .addCleanup (self .openstack , 'aggregate delete ' + name2 )
7380
7481 cmd_output = json .loads (self .openstack (
75- 'aggregate list -f json' ))
82+ 'aggregate list -f json'
83+ ))
7684 names = [x ['Name' ] for x in cmd_output ]
7785 self .assertIn (name1 , names )
7886 self .assertIn (name2 , names )
@@ -82,7 +90,8 @@ def test_aggregate_list(self):
8290
8391 # Test aggregate list --long
8492 cmd_output = json .loads (self .openstack (
85- 'aggregate list --long -f json' ))
93+ 'aggregate list --long -f json'
94+ ))
8695 names = [x ['Name' ] for x in cmd_output ]
8796 self .assertIn (name1 , names )
8897 self .assertIn (name2 , names )
@@ -101,21 +110,24 @@ def test_aggregate_set_and_unset(self):
101110 'aggregate create ' +
102111 '--zone nova ' +
103112 '--property a=b ' +
104- name1 )
113+ name1
114+ )
105115 self .addCleanup (self .openstack , 'aggregate delete ' + name2 )
106116
107117 raw_output = self .openstack (
108- 'aggregate set --name ' +
109- name2 +
110- ' --zone internal ' +
118+ 'aggregate set ' +
119+ '--name ' + name2 + ' ' +
120+ '--zone internal ' +
111121 '--no-property ' +
112122 '--property c=d ' +
113123 name1
114124 )
115125 self .assertOutput ('' , raw_output )
116126
117127 cmd_output = json .loads (self .openstack (
118- 'aggregate show -f json ' + name2 ))
128+ 'aggregate show -f json ' +
129+ name2
130+ ))
119131 self .assertEqual (
120132 name2 ,
121133 cmd_output ['name' ]
@@ -135,30 +147,41 @@ def test_aggregate_set_and_unset(self):
135147
136148 # Test unset
137149 raw_output = self .openstack (
138- 'aggregate unset --property c ' +
150+ 'aggregate unset ' +
151+ '--property c ' +
139152 name2
140153 )
141154 self .assertOutput ('' , raw_output )
142155
143156 cmd_output = json .loads (self .openstack (
144- 'aggregate show -f json ' + name2 ))
157+ 'aggregate show -f json ' +
158+ name2
159+ ))
145160 self .assertNotIn (
146161 "c='d'" ,
147162 cmd_output ['properties' ]
148163 )
149164
150165 def test_aggregate_add_and_remove_host (self ):
151166 """Test aggregate add and remove host"""
152- name = uuid .uuid4 ().hex
153- self .openstack (
154- 'aggregate create ' + name )
155- self .addCleanup (self .openstack , 'aggregate delete ' + name )
156-
157167 # Get a host
158168 cmd_output = json .loads (self .openstack (
159- 'host list -f json' ))
169+ 'host list -f json'
170+ ))
160171 host_name = cmd_output [0 ]['Host Name' ]
161172
173+ # NOTE(dtroyer): Cells v1 is not operable with aggregates. Hostnames
174+ # are returned as rrr@host or ccc!rrr@host.
175+ if '@' in host_name :
176+ self .skipTest ("Skip aggregates in a Nova cells v1 configuration" )
177+
178+ name = uuid .uuid4 ().hex
179+ self .openstack (
180+ 'aggregate create ' +
181+ name
182+ )
183+ self .addCleanup (self .openstack , 'aggregate delete ' + name )
184+
162185 # Test add host
163186 cmd_output = json .loads (self .openstack (
164187 'aggregate add host -f json ' +
0 commit comments