예제 #1
0
파일: volume.py 프로젝트: maxdaq/vnfsetup
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
예제 #2
0
파일: router.py 프로젝트: maxdaq/vnfsetup
def create (desc, output, args):

        router = desc["VNF"]["router"]
        prefix = desc["VNF"]["name"]

        for r in router:
                name = r + "-" + prefix

                if search (name) != -1:
                        app.exists ("Router " + name)
                        continue

		if (proc.execProcess ("neutron", "router-create", [name], output, args)):
                        app.failed ("Creating router " + name)
                else:
                        app.passed ("Creating router " + name)

                if desc["router "+r]["interface"] != "":
                        interface = text.getList(desc["router "+r]["interface"])
                        for i in interface:
                                params = [name, i + "-" + prefix]

				if (proc.execProcess ("neutron", "router-interface-add", params, output, args)):
                                        app.failed ("Adding interface " + i + "-" + prefix + " to router " + name)
                                else:
                                        app.passed ("Adding interface " + i + "-" + prefix + " to router " + name)

                id = search (name)
예제 #3
0
파일: router.py 프로젝트: maxdaq/vnfsetup
def delete (desc, output, args):

        router = desc["VNF"]["router"]
        prefix = desc["VNF"]["name"]

        for r in router:
                name = r + "-" + prefix
                interface = desc["router "+r]["interface"]

                router_id = search (name)
                if router_id == -1:
                        app.notfound ("Router " + name)
                        continue

                if (interface !=""):
                        for i in text.getList(interface):
                                params = [name, i + "-" + prefix]

				if (proc.execProcess ("neutron", "router-interface-delete", params, output, args)):
                                        app.failed ("Removing interface " + i + "-" + prefix + " from router " + name)
                                else:
                                        app.passed ("Removing interface " + i + "-" + prefix + " from router " + name)

		if (proc.execProcess ("neutron", "router-delete", [name], output, args)):
                        app.failed ("Deleting router " + name)
                else:
                        app.passed ("Deleting router " + name)
예제 #4
0
파일: subnet.py 프로젝트: maxdaq/vnfsetup
def create (desc, output, args):

        network = desc["VNF"]["network"]
        prefix = desc["VNF"]["name"]

        for n in network:
                name = n + "-" + prefix
                subnet = desc["network "+n]["subnet"]
                start = desc["network "+n]["start"]
                end = desc["network "+n]["end"]
                dhcp = desc["network "+n]["dhcp"]
                gateway = desc["network "+n]["gateway"]
                nameserver = desc["network "+n]["nameserver"]
                route = desc["network "+n]["route"]

                if search (name) != -1:
                        app.exists ("Subnet " + name)
                        continue

                params = [name, subnet,"--name",name]

                if start != "" and end != "":
                        params = params + ["--allocation-pool","start=" + start + ",end="+ end]

                if gateway != "":
                        params = params + ["--gateway="+gateway]

                if dhcp == "false":
                        params = params + ["--disable-dhcp"]

                if nameserver != "":
                        params = params + ["--dns_nameservers","list=true"]
                        for ns in text.getList(nameserver):
                                params = params + [ns]

                if route != "":
                        params = params + ["--host_routes","type=dict","list=true"]
                        for r in text.getList(route):
                                dest = getitem (r, 0)
                                next_hop = text.getItem (r, 1)
                                params = params + ["destination="+dest+",nexthop="+next_hop]

		if (proc.execProcess("neutron", "subnet-create", params, output, args)):
                        app.failed ("Creating subnet "+name)
                else:
                        app.passed ("Creating subnet " + name)
예제 #5
0
파일: volume.py 프로젝트: maxdaq/vnfsetup
def delete (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

                        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.notfound ("Volume "+dname)
                                        continue

				if (proc.execProcess ("cinder", "delete", [dname], output, args)):
                                        app.failed ("Deleting volume " + dname)
                                else:
                                        app.passed ("Deleting volume " + dname)

        return 1