summaryrefslogtreecommitdiffstats
path: root/testing/robot/lib
diff options
context:
space:
mode:
authorJuraj Linkes <jlinkes@cisco.com>2016-08-12 12:51:06 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-08-12 12:51:06 +0000
commit7ac44c4a1406bf060911c645f23eef18a13dc0af (patch)
treeb5826a52a6e0cf62e2dd0b3745a855e33fecde94 /testing/robot/lib
parent389c6a826c951b13598fdb1462a29ce41e8a22ac (diff)
parent6318a416890600c739208c228c2be8527aac61af (diff)
Merge "added headers and added a non-working first draft of nodhcp ping test"
Diffstat (limited to 'testing/robot/lib')
-rw-r--r--testing/robot/lib/FDSLibrary.py49
1 files changed, 47 insertions, 2 deletions
diff --git a/testing/robot/lib/FDSLibrary.py b/testing/robot/lib/FDSLibrary.py
index 2e29d6c..0cb43ee 100644
--- a/testing/robot/lib/FDSLibrary.py
+++ b/testing/robot/lib/FDSLibrary.py
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2016 Juraj Linkes (Cisco) and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
from neutronclient.v2_0 import client as neutron
from novaclient import client as nova
from novaclient.exceptions import NotFound
@@ -19,6 +28,14 @@ class FDSLibrary():
os.getenv('OS_TENANT_NAME'),
os.getenv('OS_AUTH_URL'))
+ def check_flavor_exists(self, flavor):
+ flavor_list_names = [x.name for x in self.nova_client.flavors.list()]
+ return flavor in flavor_list_names
+
+ def check_image_exists(self, image):
+ image_list_names = [x.name for x in self.nova_client.images.list()]
+ return image in image_list_names
+
def create_network(self, name):
body = {'network': {'name': name}}
response = self.neutron_client.create_network(body=body)
@@ -52,16 +69,44 @@ class FDSLibrary():
response = self.neutron_client.create_port(body=body)
return response
- def create_server(self, name, image, flavor, port_ids, security_groups=None):
+ def create_server(self, name, image, flavor, port_ids, security_groups=None, userdata=None):
image = self.nova_client.images.find(name=image)
flavor = self.nova_client.flavors.find(name=flavor)
nics = [{'port-id': port_id} for port_id in port_ids]
response = self.nova_client.servers.create(name=name, image=image.id, flavor=flavor.id,
- security_groups=security_groups, nics=nics)
+ security_groups=security_groups, nics=nics,
+ userdata=userdata)
for key in dir(response):
print key, getattr(response, key)
return response
+ def format_string(self, string, substitute):
+ return string.format(substitute)
+
+ def check_server_console(self, vm_id, string):
+ vm_obj = self.nova_client.servers.get(vm_id)
+ timeout = 0
+ while timeout < 100:
+ console_out = vm_obj.get_console_output()
+ print "console output is: '{}'".format(console_out[-200:])
+ failed_to_read_metadata = 'failed to read iid from metadata'
+ if string in console_out:
+ return True
+ elif 'request failed' in console_out:
+ print 'retrying'
+ elif failed_to_read_metadata in console_out:
+ print failed_to_read_metadata
+ return False
+ timeout += 1
+ time.sleep(5)
+ return False
+
+ def create_security_group(self):
+ pass
+
+ def create_security_rule(self):
+ pass
+
def poll_server(self, vm_id, status, timeout=300):
try:
start = datetime.datetime.now()