Merge "Automate flavors, networks, and image get"
This commit is contained in:
commit
c42cd80d6e
@ -15,6 +15,7 @@ import uuid
|
|||||||
|
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
|
from functional.common import exceptions
|
||||||
from functional.common import test
|
from functional.common import test
|
||||||
|
|
||||||
|
|
||||||
@ -27,19 +28,38 @@ class ServerTests(test.TestCase):
|
|||||||
FIELDS = ['name']
|
FIELDS = ['name']
|
||||||
IP_POOL = 'public'
|
IP_POOL = 'public'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_flavor(cls):
|
||||||
|
raw_output = cls.openstack('flavor list -f value -c ID')
|
||||||
|
ray = raw_output.split('\n')
|
||||||
|
idx = len(ray)/2
|
||||||
|
return ray[idx]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_image(cls):
|
||||||
|
raw_output = cls.openstack('image list -f value -c ID')
|
||||||
|
ray = raw_output.split('\n')
|
||||||
|
idx = len(ray)/2
|
||||||
|
return ray[idx]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_network(cls):
|
||||||
|
try:
|
||||||
|
raw_output = cls.openstack('network list -f value -c ID')
|
||||||
|
except exceptions.CommandFailed:
|
||||||
|
return ''
|
||||||
|
ray = raw_output.split('\n')
|
||||||
|
idx = len(ray)/2
|
||||||
|
return ' --nic net-id=' + ray[idx]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
opts = cls.get_show_opts(cls.FIELDS)
|
opts = cls.get_show_opts(cls.FIELDS)
|
||||||
# TODO(thowe): pull these values from clouds.yaml
|
flavor = cls.get_flavor()
|
||||||
flavor = '4'
|
image = cls.get_image()
|
||||||
image = 'cirros-0.3.4-x86_64-uec'
|
network = cls.get_network()
|
||||||
netid = ''
|
|
||||||
if netid:
|
|
||||||
nicargs = ' --nic net-id=' + netid
|
|
||||||
else:
|
|
||||||
nicargs = ''
|
|
||||||
raw_output = cls.openstack('server create --flavor ' + flavor +
|
raw_output = cls.openstack('server create --flavor ' + flavor +
|
||||||
' --image ' + image + nicargs + ' ' +
|
' --image ' + image + network + ' ' +
|
||||||
cls.NAME + opts)
|
cls.NAME + opts)
|
||||||
expected = cls.NAME + '\n'
|
expected = cls.NAME + '\n'
|
||||||
cls.assertOutput(expected, raw_output)
|
cls.assertOutput(expected, raw_output)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user