コード例 #1
0
ファイル: router.py プロジェクト: maxdaq/vnfsetup
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
コード例 #2
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)
コード例 #3
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)
コード例 #4
0
ファイル: image.py プロジェクト: maxdaq/vnfsetup
def create(desc, output, args):

    vms = desc["VNF"]["vm"]
    prefix = desc["VNF"]["name"]

    for vm in vms:
        name = vm + "-" + prefix
        fmt = text.getItem(desc["vm " + vm]["image"], 0)
        image = text.getItem(desc["vm " + vm]["image"], 1)

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

        if not os.path.isfile(image):
            app.warn("Image " + image + " does not exist")
            continue

        params = ["--name", name, "--container-format", "bare", "--file", image]
        params = params + ["--disk-format", fmt]

        if proc.execProcess("glance", "image-create", params, output, args):
            app.failed("Creating image " + name)
        else:
            app.passed("Creating image " + name)
コード例 #5
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
コード例 #6
0
ファイル: subnet.py プロジェクト: maxdaq/vnfsetup
def delete (desc, output, args):

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

        for n in network:
                name = n + "-" + prefix

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

		if (proc.execProcess ("neutron", "subnet-delete", [name], output, args)):
                        app.failed ("Deleting subnet " + name)
                else:
                        app.passed ("Deleting subnet " + name)
コード例 #7
0
ファイル: image.py プロジェクト: maxdaq/vnfsetup
def delete(desc, output, args):

    vms = desc["VNF"]["vm"]
    prefix = desc["VNF"]["name"]

    for vm in vms:
        name = vm + "-" + prefix

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

        if proc.execProcess("glance", "image-delete", [name], output, args):
            app.failed("Deleting image " + name)
        else:
            app.passed("Deleting image " + name)
コード例 #8
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)
コード例 #9
0
ファイル: subnet.py プロジェクト: maxdaq/vnfsetup
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
コード例 #10
0
ファイル: image.py プロジェクト: maxdaq/vnfsetup
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
コード例 #11
0
ファイル: volume.py プロジェクト: maxdaq/vnfsetup
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
コード例 #12
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