File tree Expand file tree Collapse file tree
functional/tests/compute/v2 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515
1616import testtools
1717
18+ from functional .common import exceptions
1819from functional .common import test
1920
2021
@@ -27,19 +28,38 @@ class ServerTests(test.TestCase):
2728 FIELDS = ['name' ]
2829 IP_POOL = 'public'
2930
31+ @classmethod
32+ def get_flavor (cls ):
33+ raw_output = cls .openstack ('flavor list -f value -c ID' )
34+ ray = raw_output .split ('\n ' )
35+ idx = len (ray )/ 2
36+ return ray [idx ]
37+
38+ @classmethod
39+ def get_image (cls ):
40+ raw_output = cls .openstack ('image list -f value -c ID' )
41+ ray = raw_output .split ('\n ' )
42+ idx = len (ray )/ 2
43+ return ray [idx ]
44+
45+ @classmethod
46+ def get_network (cls ):
47+ try :
48+ raw_output = cls .openstack ('network list -f value -c ID' )
49+ except exceptions .CommandFailed :
50+ return ''
51+ ray = raw_output .split ('\n ' )
52+ idx = len (ray )/ 2
53+ return ' --nic net-id=' + ray [idx ]
54+
3055 @classmethod
3156 def setUpClass (cls ):
3257 opts = cls .get_show_opts (cls .FIELDS )
33- # TODO(thowe): pull these values from clouds.yaml
34- flavor = '4'
35- image = 'cirros-0.3.4-x86_64-uec'
36- netid = ''
37- if netid :
38- nicargs = ' --nic net-id=' + netid
39- else :
40- nicargs = ''
58+ flavor = cls .get_flavor ()
59+ image = cls .get_image ()
60+ network = cls .get_network ()
4161 raw_output = cls .openstack ('server create --flavor ' + flavor +
42- ' --image ' + image + nicargs + ' ' +
62+ ' --image ' + image + network + ' ' +
4363 cls .NAME + opts )
4464 expected = cls .NAME + '\n '
4565 cls .assertOutput (expected , raw_output )
You can’t perform that action at this time.
0 commit comments