def deleteAll (desc, output, args): buf = proc.readProcess ("neutron", "router-list") try: for line in buf.readlines(): id = text.getField(line, 1) name = text.getField(line, 2) if name in search (name) == -1: continue netbuf = proc.readProcess ("neutron", "subnet-list") try: for net in netbuf.readlines(): net_id = text.getField (net, 1) net_name = text.getField (net, 2) params = [id, net_name] if (proc.execProcess ("neutron", "router-interface-delete", params, output, args)): app.failed ("Remove interface " + net_name + " from router " + name) else: app.passed ("Removed interface " + net_name + " from router " + name) except: pass if (proc.execProcess ("neutron", "router-delete", [id], output, args)): app.failed ("Deleting router " + name) else: app.passed ("Deleting router " + name) except: pass
def create (desc, output, args): vms = desc["VNF"]["vm"] prefix = desc["VNF"]["name"] for vm in vms: name = vm + "-" + prefix hosts = [] if desc["vm "+vm]["host"]!="": hosts = text.getList(desc["vm "+vm]["host"]) disk = [] if desc["vm "+vm]["disk"] != "": disk = text.getList(desc["vm "+vm]["disk"]) j = 0 for h in hosts: j = j + 1 i = 0 params = [] for d in disk: size = text.getItem(d, 0) disk_name = text.getItem(d, 1) i = i + 1 vname = name +"-no"+str(j)+"-node"+h dname = vname+"-disk"+str(i)+"-"+size+"GB-"+disk_name if search (dname) != -1: app.exists ("Volume "+dname) continue params = [str(size), "--display-name="+ dname] if (proc.execProcess ("cinder", "create", params, output, args)): app.failed ("Creating volume " + dname) else: app.passed ("Creating volume " + dname) status = "creating" while status!="available": time.sleep(1) buf = proc.readProcess ("cinder", "show", dname) for line in buf.readlines(): if line.find("status")!=-1: if text.getField(line, 1) == "status": status = text.getField(line,2 ) break if status == "error": return -1 return 1
def deleteAll (desc, output, args): buf = proc.readProcess ("neutron", "subnet-list") try: for line in buf.readlines(): id = text.getField(line, 1) name = text.getField (line, 2) if search (name) == -1: continue if (proc.execProcess ("neutron", "subnet-delete", [id], output, args)): app.failed ("Deleting subnet " + name) else: app.passed ("Deleting subnetwork " + name) except: pass
def deleteAll(desc, output, args): buf = proc.readProcess("glance", "image-list") try: for line in buf.readlines(): id = text.getField(line, 1) name = text.getField(line, 2) if search(name) == -1: continue if proc.execProcess("glance", "image-delete", [id], output, args): app.failed("Deleting image " + name) else: app.passed("Deleting image " + name) except: pass
def deleteAll (desc, output, args): buf = proc.readProcess ("cinder", "list") try: for line in buf.readlines(): id = text.getField(line, 1) name = text.getField(line, 3) if search (name) == -1: continue if (proc.execProcess ("cinder", "delete", [id], output, args)): app.failed ("Deleting volume "+name) else: app.passed ("Deleting volume " + name) except: pass