import os, paramiko, time import openstackutils cwlib = openstackutils.OpenStackUtils() test_resources = {} def setup(): global test_resources start_chrono = int(round(time.time() * 1000)) port= cwlib.create_port_with_sg() keypair, private_key = cwlib.create_keypair() floating_ip = cwlib.create_floating_ip() #cwlib.associate_floating_ip_to_port(floating_ip) userdata_path = os.path.dirname(os.path.realpath(__file__)) + '/userdata.yml' server = cwlib.boot_vm_with_userdata_and_port(userdata_path,keypair,port) cwlib.associate_floating_ip_to_server(floating_ip, server) time.sleep(80) test_resources['my_port']= port test_resources['my_keypair'] = keypair test_resources['my_floating'] = floating_ip test_resources['my_server'] = server test_resources['my_private_key'] = private_key test_resources['ssh_connection'] = cwlib.initiate_ssh(floating_ip,private_key) stop_chrono = int(round(time.time() * 1000))
#!/usr/bin/env python import time, paramiko,os,re,errno from socket import error as socket_error import openstackutils as c from os import environ as env cwlib =c.OpenStackUtils() if __name__ == '__main__': #port= cwlib.create_port_with_sg() 688099dc-1cff-4dde-bfd9-13de09e972bf #print port['port']['id'] #cwlib.delete_port(port) #84.39.51.34 serv=cwlib.get_server('688099dc-1cff-4dde-bfd9-13de09e972bf') serv.reboot(reboot_type='HARD') time.sleep(20) print serv.status serv.reboot(reboot_type='SOFT') time.sleep(20) print serv.status