summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-09-09 20:23:41 +0000
committerGerrit Code Review <review@openstack.org>2015-09-09 20:23:41 +0000
commitc42cd80d6e15339592a7eb3f3e8f9143a26a810d (patch)
tree8178270b23afd0904709ce0acd85aafa4c3ced65
parent46696f5ed55c9313754e7019e727ee88fa0847ce (diff)
parent48f7f0f1bcb0d43d18e89f8ff54971f450f2f58b (diff)
downloadpython-openstackclient-c42cd80d6e15339592a7eb3f3e8f9143a26a810d.tar.gz
Merge "Automate flavors, networks, and image get"
-rw-r--r--functional/tests/compute/v2/test_server.py38
1 files changed, 29 insertions, 9 deletions
diff --git a/functional/tests/compute/v2/test_server.py b/functional/tests/compute/v2/test_server.py
index aa1c1201..a6cc98e6 100644
--- a/functional/tests/compute/v2/test_server.py
+++ b/functional/tests/compute/v2/test_server.py
@@ -15,6 +15,7 @@ import uuid
import testtools
+from functional.common import exceptions
from functional.common import test
@@ -28,18 +29,37 @@ class ServerTests(test.TestCase):
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
def setUpClass(cls):
opts = cls.get_show_opts(cls.FIELDS)
- # TODO(thowe): pull these values from clouds.yaml
- flavor = '4'
- image = 'cirros-0.3.4-x86_64-uec'
- netid = ''
- if netid:
- nicargs = ' --nic net-id=' + netid
- else:
- nicargs = ''
+ flavor = cls.get_flavor()
+ image = cls.get_image()
+ network = cls.get_network()
raw_output = cls.openstack('server create --flavor ' + flavor +
- ' --image ' + image + nicargs + ' ' +
+ ' --image ' + image + network + ' ' +
cls.NAME + opts)
expected = cls.NAME + '\n'
cls.assertOutput(expected, raw_output)