def create_network(neutron_client, net, subnet1, cidr1,
router, subnet2=None, cidr2=None):
- """Network assoc will not work for networks/subnets created by this function.
+ """Network assoc won't work for networks/subnets created by this function.
It is an ODL limitation due to it handling routers as vpns.
See https://bugs.opendaylight.org/show_bug.cgi?id=6962"""
return str(os.environ['INSTALLER_IP'])
+def get_instance_ip(instance):
+ instance_ip = instance.networks.itervalues().next()[0]
+ return instance_ip
+
+
def wait_for_instance(instance):
logger.info("Waiting for instance %s to get a DHCP lease..." % instance.id)
# The sleep this function replaced waited for 80s
def run_odl_cmd(odl_node, cmd):
- '''
- Run a command in the OpenDaylight Karaf shell
+ '''Run a command in the OpenDaylight Karaf shell
This is a bit flimsy because of shell quote escaping, make sure that
the cmd passed does not have any top level double quotes or this
function will break.
+
+ The /dev/null is used because client works, but outputs something
+ that contains "ERROR" and run_cmd doesn't like that.
+
'''
- karaf_cmd = '/opt/opendaylight/bin/client "%s" ' % cmd
+ karaf_cmd = '/opt/opendaylight/bin/client "%s" 2>/dev/null' % cmd
return odl_node.run_cmd(karaf_cmd)
+
+
+def wait_for_cloud_init(instance):
+ success = True
+ # ubuntu images take a long time to start
+ tries = 20
+ sleep_time = 30
+ while tries > 0:
+ instance_log = instance.get_console_output()
+ if "Failed to run module" in instance_log:
+ success = False
+ logger.error("Cloud init failed to run. Reason: %s",
+ instance_log)
+ break
+ if re.search(r"Cloud-init v. .+ finished at", instance_log):
+ success = True
+ break
+ time.sleep(sleep_time)
+ tries = tries - 1
+
+ if tries == 0:
+ logger.error("Cloud init timed out"
+ ". Reason: %s",
+ instance_log)
+ success = False
+
+ return success