@@ -230,7 +230,7 @@ def test_server_set(self):
230230 ))
231231 # Really, shouldn't this be a list?
232232 self .assertEqual (
233- "a=' b', c='d'" ,
233+ { 'a' : ' b' , 'c' : 'd' } ,
234234 cmd_output ['properties' ],
235235 )
236236
@@ -244,7 +244,7 @@ def test_server_set(self):
244244 name
245245 ))
246246 self .assertEqual (
247- "c='d'" ,
247+ { 'c' : 'd' } ,
248248 cmd_output ['properties' ],
249249 )
250250
@@ -619,8 +619,8 @@ def test_server_boot_with_bdm_snapshot(self):
619619 server_name
620620 ))
621621 volumes_attached = cmd_output ['volumes_attached' ]
622- self .assertTrue (volumes_attached . startswith ( 'id=' ) )
623- attached_volume_id = volumes_attached . replace ( 'id=' , '' )
622+ self .assertIsNotNone (volumes_attached )
623+ attached_volume_id = volumes_attached [ 0 ][ "id" ]
624624
625625 # check the volume that attached on server
626626 cmd_output = json .loads (self .openstack (
@@ -699,8 +699,8 @@ def test_server_boot_with_bdm_image(self):
699699 server_name
700700 ))
701701 volumes_attached = cmd_output ['volumes_attached' ]
702- self .assertTrue (volumes_attached . startswith ( 'id=' ) )
703- attached_volume_id = volumes_attached . replace ( 'id=' , '' )
702+ self .assertIsNotNone (volumes_attached )
703+ attached_volume_id = volumes_attached [ 0 ][ "id" ]
704704
705705 # check the volume that attached on server
706706 cmd_output = json .loads (self .openstack (
@@ -773,10 +773,12 @@ def test_boot_from_volume(self):
773773 server_name
774774 ))
775775 volumes_attached = cmd_output ['volumes_attached' ]
776- self .assertTrue (volumes_attached .startswith ('id=' ))
777- attached_volume_id = volumes_attached .replace ('id=' , '' )
778- # Don't leak the volume when the test exits.
779- self .addCleanup (self .openstack , 'volume delete ' + attached_volume_id )
776+ self .assertIsNotNone (volumes_attached )
777+ attached_volume_id = volumes_attached [0 ]["id" ]
778+ for vol in volumes_attached :
779+ self .assertIsNotNone (vol ['id' ])
780+ # Don't leak the volume when the test exits.
781+ self .addCleanup (self .openstack , 'volume delete ' + vol ['id' ])
780782
781783 # Since the server is volume-backed the GET /servers/{server_id}
782784 # response will have image=''.
@@ -785,7 +787,7 @@ def test_boot_from_volume(self):
785787 # check the volume that attached on server
786788 cmd_output = json .loads (self .openstack (
787789 'volume show -f json ' +
788- attached_volume_id
790+ volumes_attached [ 0 ][ "id" ]
789791 ))
790792 # The volume size should be what we specified on the command line.
791793 self .assertEqual (1 , int (cmd_output ['size' ]))
@@ -879,14 +881,21 @@ def test_server_create_with_security_group(self):
879881
880882 self .assertIsNotNone (server ['id' ])
881883 self .assertEqual (server_name , server ['name' ])
882- self .assertIn (str (security_group1 ['id' ]), server ['security_groups' ])
883- self .assertIn (str (security_group2 ['id' ]), server ['security_groups' ])
884+ sec_grp = ""
885+ for sec in server ['security_groups' ]:
886+ sec_grp += sec ['name' ]
887+ self .assertIn (str (security_group1 ['id' ]), sec_grp )
888+ self .assertIn (str (security_group2 ['id' ]), sec_grp )
884889 self .wait_for_status (server_name , 'ACTIVE' )
885890 server = json .loads (self .openstack (
886891 'server show -f json ' + server_name
887892 ))
888- self .assertIn (sg_name1 , server ['security_groups' ])
889- self .assertIn (sg_name2 , server ['security_groups' ])
893+ # check if security group exists in list
894+ sec_grp = ""
895+ for sec in server ['security_groups' ]:
896+ sec_grp += sec ['name' ]
897+ self .assertIn (sg_name1 , sec_grp )
898+ self .assertIn (sg_name2 , sec_grp )
890899
891900 def test_server_create_with_empty_network_option_latest (self ):
892901 """Test server create with empty network option in nova 2.latest."""
0 commit comments