@@ -67,13 +67,13 @@ def _create_dummy_project(self, add_clean_up=True):
6767 '--description %(description)s '
6868 '--enable %(name)s' % {'description' : project_description ,
6969 'name' : project_name })
70- items = self .parse_show (raw_output )
71- self .assert_show_fields (items , self .PROJECT_FIELDS )
7270 project = self .parse_show_as_object (raw_output )
7371 if add_clean_up :
7472 self .addCleanup (
7573 self .openstack ,
7674 'project delete %s' % project ['id' ])
75+ items = self .parse_show (raw_output )
76+ self .assert_show_fields (items , self .PROJECT_FIELDS )
7777 return project_name
7878
7979 def _create_dummy_user (self , add_clean_up = True ):
@@ -90,47 +90,47 @@ def _create_dummy_user(self, add_clean_up=True):
9090 'email' : email ,
9191 'password' : password ,
9292 'name' : username })
93- items = self .parse_show (raw_output )
94- self .assert_show_fields (items , self .USER_FIELDS )
9593 if add_clean_up :
9694 self .addCleanup (
9795 self .openstack ,
9896 'user delete %s' % self .parse_show_as_object (raw_output )['id' ])
97+ items = self .parse_show (raw_output )
98+ self .assert_show_fields (items , self .USER_FIELDS )
9999 return username
100100
101101 def _create_dummy_role (self , add_clean_up = True ):
102102 role_name = data_utils .rand_name ('TestRole' )
103103 raw_output = self .openstack ('role create %s' % role_name )
104- items = self .parse_show (raw_output )
105- self .assert_show_fields (items , self .ROLE_FIELDS )
106104 role = self .parse_show_as_object (raw_output )
107- self .assertEqual (role_name , role ['name' ])
108105 if add_clean_up :
109106 self .addCleanup (
110107 self .openstack ,
111108 'role delete %s' % role ['id' ])
109+ items = self .parse_show (raw_output )
110+ self .assert_show_fields (items , self .ROLE_FIELDS )
111+ self .assertEqual (role_name , role ['name' ])
112112 return role_name
113113
114114 def _create_dummy_ec2_credentials (self , add_clean_up = True ):
115115 raw_output = self .openstack ('ec2 credentials create' )
116- items = self .parse_show (raw_output )
117- self .assert_show_fields (items , self .EC2_CREDENTIALS_FIELDS )
118116 ec2_credentials = self .parse_show_as_object (raw_output )
119117 access_key = ec2_credentials ['access' ]
120118 if add_clean_up :
121119 self .addCleanup (
122120 self .openstack ,
123121 'ec2 credentials delete %s' % access_key )
122+ items = self .parse_show (raw_output )
123+ self .assert_show_fields (items , self .EC2_CREDENTIALS_FIELDS )
124124 return access_key
125125
126126 def _create_dummy_token (self , add_clean_up = True ):
127127 raw_output = self .openstack ('token issue' )
128- items = self .parse_show (raw_output )
129- self .assert_show_fields (items , self .TOKEN_FIELDS )
130128 token = self .parse_show_as_object (raw_output )
131129 if add_clean_up :
132130 self .addCleanup (self .openstack ,
133131 'token revoke %s' % token ['id' ])
132+ items = self .parse_show (raw_output )
133+ self .assert_show_fields (items , self .TOKEN_FIELDS )
134134 return token ['id' ]
135135
136136 def _create_dummy_service (self , add_clean_up = True ):
@@ -144,12 +144,12 @@ def _create_dummy_service(self, add_clean_up=True):
144144 '%(type)s' % {'name' : service_name ,
145145 'description' : description ,
146146 'type' : type_name })
147- items = self .parse_show (raw_output )
148- self .assert_show_fields (items , self .SERVICE_FIELDS )
149147 if add_clean_up :
150148 service = self .parse_show_as_object (raw_output )
151149 self .addCleanup (self .openstack ,
152150 'service delete %s' % service ['id' ])
151+ items = self .parse_show (raw_output )
152+ self .assert_show_fields (items , self .SERVICE_FIELDS )
153153 return service_name
154154
155155 def _create_dummy_endpoint (self , add_clean_up = True ):
@@ -169,11 +169,11 @@ def _create_dummy_endpoint(self, add_clean_up=True):
169169 'internalurl' : internal_url ,
170170 'region' : region_id ,
171171 'service' : service_name })
172- items = self .parse_show (raw_output )
173- self .assert_show_fields (items , self .ENDPOINT_FIELDS )
174172 endpoint = self .parse_show_as_object (raw_output )
175173 if add_clean_up :
176174 self .addCleanup (
177175 self .openstack ,
178176 'endpoint delete %s' % endpoint ['id' ])
177+ items = self .parse_show (raw_output )
178+ self .assert_show_fields (items , self .ENDPOINT_FIELDS )
179179 return endpoint ['id' ]
0 commit comments