コード例 #1
0
def handle(network):
	from core.models import ControllerSlice,ControllerNetwork, Network
	from collections import defaultdict

        # network = Network.get(network_id)
	# network controllers are not visible to users. We must ensure
	# networks are deployed at all deploymets available to their slices.
	slice_controllers = ControllerSlice.objects.all()
	slice_deploy_lookup = defaultdict(list)
	for slice_controller in slice_controllers:
		slice_deploy_lookup[slice_controller.slice].append(slice_controller.controller)

	network_controllers = ControllerNetwork.objects.all()
	network_deploy_lookup = defaultdict(list)
	for network_controller in network_controllers:
		network_deploy_lookup[network_controller.network].append(network_controller.controller)

	expected_controllers = slice_deploy_lookup[network.owner]
	for expected_controller in expected_controllers:
		if network not in network_deploy_lookup or \
		  expected_controller not in network_deploy_lookup[network]:
			nd = ControllerNetwork(network=network, controller=expected_controller, lazy_blocked=True)
                        if network.subnet:
                            # XXX: Possibly unpredictable behavior if there is
                            # more than one ControllerNetwork and the subnet
                            # is specified.
                            nd.subnet = network.subnet
			nd.save()
コード例 #2
0
def handle(network):
    from core.models import ControllerSlice, ControllerNetwork, Network
    from collections import defaultdict

    # network = Network.get(network_id)
    # network controllers are not visible to users. We must ensure
    # networks are deployed at all deploymets available to their slices.
    slice_controllers = ControllerSlice.objects.all()
    slice_deploy_lookup = defaultdict(list)
    for slice_controller in slice_controllers:
        slice_deploy_lookup[slice_controller.slice].append(
            slice_controller.controller)

    network_controllers = ControllerNetwork.objects.all()
    network_deploy_lookup = defaultdict(list)
    for network_controller in network_controllers:
        network_deploy_lookup[network_controller.network].append(
            network_controller.controller)

    expected_controllers = slice_deploy_lookup[network.owner]
    for expected_controller in expected_controllers:
        if network not in network_deploy_lookup or \
          expected_controller not in network_deploy_lookup[network]:
            nd = ControllerNetwork(network=network,
                                   controller=expected_controller,
                                   lazy_blocked=True)
            nd.save()
コード例 #3
0
def handle(controller):
    from core.models import Controller, Site, ControllerSite, Slice, ControllerSlice, User, ControllerUser, ControllerImages, ControllerNetwork, Image, Network
    from collections import defaultdict

    # relations for all sites
    ctrls_by_site = defaultdict(list)
    ctrl_sites = ControllerSite.objects.all()
    for ctrl_site in ctrl_sites:
        ctrls_by_site[ctrl_site.site].append(ctrl_site.controller)
    sites = Site.objects.all()
    for site in sites:
        if site not in ctrls_by_site or \
            controller not in ctrls_by_site[site]:
            controller_site = ControllerSite(controller=controller, site=site)
            controller_site.save()
    # relations for all slices
    ctrls_by_slice = defaultdict(list)
    ctrl_slices = ControllerSlice.objects.all()
    for ctrl_slice in ctrl_slices:
        ctrls_by_slice[ctrl_slice.slice].append(ctrl_slice.controller)
    slices = Slice.objects.all()
    for slice in slices:
        if slice not in ctrls_by_slice or \
            controller not in ctrls_by_slice:
            controller_slice = ControllerSlice(controller=controller, slice=slice)
            controller_slice.save()
    # relations for all users
    ctrls_by_user = defaultdict(list)
    ctrl_users = ControllerUser.objects.all()
    for ctrl_user in ctrl_users:
        ctrls_by_user[ctrl_user.user].append(ctrl_user.controller)
    users = User.objects.all()
    for user in users:
        if user not in ctrls_by_user or \
            controller not in ctrls_by_user[user]:
            controller_user = ControllerUser(controller=controller, user=user)
            controller_user.save()
    # relations for all networks
    ctrls_by_network = defaultdict(list)
    ctrl_networks = ControllerNetwork.objects.all()
    for ctrl_network in ctrl_networks:
        ctrls_by_network[ctrl_network.network].append(ctrl_network.controller)
    networks = Network.objects.all()
    for network in networks:
        if network not in ctrls_by_network or \
            controller not in ctrls_by_network[network]:
            controller_network = ControllerNetwork(controller=controller, network=network)
            controller_network.save()
    # relations for all images
    ctrls_by_image = defaultdict(list)
    ctrl_images = ControllerImages.objects.all()
    for ctrl_image in ctrl_images:
        ctrls_by_image[ctrl_image.image].append(ctrl_image.controller)
    images = Image.objects.all()
    for image in images:
        if image not in ctrls_by_image or \
            controller not in ctrls_by_image[image]:
            controller_image = ControllerImages(controller=controller, image=image)
            controller_image.save()
コード例 #4
0
def handle(controller):
    from core.models import Controller, Site, ControllerSite, Slice, ControllerSlice, User, ControllerUser, ControllerImages, ControllerNetwork
    from collections import defaultdict

    # relations for all sites
    ctrls_by_site = defaultdict(list)
    ctrl_sites = ControllerSite.objects.all()
    for ctrl_site in ctrl_sites:
        ctrls_by_site[ctrl_site.site].append(ctrl_site.controller)
    sites = Site.objects.all()
    for site in sites:
        if site not in ctrls_by_site or \
            controller not in ctrls_by_site[site]:
            controller_site = ControllerSite(controller=controller, site=site)
            controller_site.save()
    # relations for all slices
    ctrls_by_slice = defaultdict(list)
    ctrl_slices = ControllerSlice.objects.all()
    for ctrl_slice in ctrl_slices:
        ctrls_by_slice[ctrl_slice.slice].append(ctrl_slice.controller)
    slices = Slice.objects.all()
    for slice in slices:
        if slice not in ctrls_by_slice or \
            controller not in ctrls_by_slice:
            controller_slice = ControllerSlice(controller=controller, slice=slice)
            controller_slice.save()
    # relations for all users
    ctrls_by_user = defaultdict(list)
    ctrl_users = ControllerUser.objects.all()
    for ctrl_user in ctrl_users:
        ctrls_by_user[ctrl_user.user].append(ctrl_user.controller)
    users = User.objects.all()
    for user in users:
        if user not in ctrls_by_user or \
            controller not in ctrls_by_user[user]:
            controller_user = ControllerUser(controller=controller, user=user)
            controller_user.save()
    # relations for all networks
    ctrls_by_network = defaultdict(list)
    ctrl_networks = ControllerNetwork.objects.all()
    for ctrl_network in ctrl_networks:
        ctrls_by_network[ctrl_network.network].append(ctrl_network.controller)
    networks = Network.objects.all()
    for network in networks:
        if network not in ctrls_by_network or \
            controller not in ctrls_by_network[network]:
            controller_network = ControllerNetwork(controller=controller, network=network)
            controller_network.save()
    # relations for all images
    ctrls_by_image = defaultdict(list)
    ctrl_images = ControllerImages.objects.all()
    for ctrl_image in ctrl_images:
        ctrls_by_image[ctrl_image.image].append(ctrl_image.controller)
    images = Image.objects.all()
    for image in images:
        if image not in ctrls_by_image or \
            controller not in ctrls_by_image[image]:
            controller_image = ControllerImages(controller=controller, image=image)
            controller_image.save()
コード例 #5
0
def handle(network):
    from core.models import ControllerSlice, ControllerNetwork, Network
    from collections import defaultdict

    print "MODEL POLICY: network", network

    # network = Network.get(network_id)
    # network controllers are not visible to users. We must ensure
    # networks are deployed at all deploymets available to their slices.
    slice_controllers = ControllerSlice.objects.all()
    slice_deploy_lookup = defaultdict(list)
    for slice_controller in slice_controllers:
        slice_deploy_lookup[slice_controller.slice].append(
            slice_controller.controller)

    network_controllers = ControllerNetwork.objects.all()
    network_deploy_lookup = defaultdict(list)
    for network_controller in network_controllers:
        network_deploy_lookup[network_controller.network].append(
            network_controller.controller)

    expected_controllers = slice_deploy_lookup[network.owner]
    for expected_controller in expected_controllers:
        if network not in network_deploy_lookup or \
          expected_controller not in network_deploy_lookup[network]:
            lazy_blocked = True

            # check and see if some instance already exists
            for networkslice in network.networkslices.all():
                if networkslice.slice.instances.filter(
                        node__site_deployment__controller=expected_controller
                ).exists():
                    print "MODEL_POLICY: network, setting lazy_blocked to false because instance on controller already exists"
                    lazy_blocked = False

            nd = ControllerNetwork(network=network,
                                   controller=expected_controller,
                                   lazy_blocked=lazy_blocked)
            print "MODEL POLICY: network", network, "create ControllerNetwork", nd, "lazy_blocked", lazy_blocked
            if network.subnet:
                # XXX: Possibly unpredictable behavior if there is
                # more than one ControllerNetwork and the subnet
                # is specified.
                nd.subnet = network.subnet
            nd.save()
コード例 #6
0
ファイル: model_policy_Network.py プロジェクト: Chunhai/xos-1
def handle(network):
	from core.models import ControllerSlice,ControllerNetwork, Network
	from collections import defaultdict

        print "MODEL POLICY: network", network

        # network = Network.get(network_id)
	# network controllers are not visible to users. We must ensure
	# networks are deployed at all deploymets available to their slices.
	slice_controllers = ControllerSlice.objects.all()
	slice_deploy_lookup = defaultdict(list)
	for slice_controller in slice_controllers:
		slice_deploy_lookup[slice_controller.slice].append(slice_controller.controller)

	network_controllers = ControllerNetwork.objects.all()
	network_deploy_lookup = defaultdict(list)
	for network_controller in network_controllers:
		network_deploy_lookup[network_controller.network].append(network_controller.controller)

	expected_controllers = slice_deploy_lookup[network.owner]
	for expected_controller in expected_controllers:
		if network not in network_deploy_lookup or \
		  expected_controller not in network_deploy_lookup[network]:
                        lazy_blocked=True

                        # check and see if some instance already exists
                        for networkslice in network.networkslices.all():
                            if networkslice.slice.instances.filter(node__site_deployment__controller=expected_controller).exists():
                               print "MODEL_POLICY: network, setting lazy_blocked to false because instance on controller already exists"
                               lazy_blocked=False

			nd = ControllerNetwork(network=network, controller=expected_controller, lazy_blocked=lazy_blocked)
                        print "MODEL POLICY: network", network, "create ControllerNetwork", nd, "lazy_blocked", lazy_blocked
                        if network.subnet:
                            # XXX: Possibly unpredictable behavior if there is
                            # more than one ControllerNetwork and the subnet
                            # is specified.
                            nd.subnet = network.subnet
			nd.save()
コード例 #7
0
ファイル: model_policy_Network.py プロジェクト: TDJIOLee/xos
def handle(network):
	from core.models import ControllerSlice,ControllerNetwork, Network
	from collections import defaultdict

        # network = Network.get(network_id)
	# network controllers are not visible to users. We must ensure
	# networks are deployed at all deploymets available to their slices.
	slice_controllers = ControllerSlice.objects.all()
	slice_deploy_lookup = defaultdict(list)
	for slice_controller in slice_controllers:
		slice_deploy_lookup[slice_controller.slice].append(slice_controller.controller)

	network_controllers = ControllerNetwork.objects.all()
	network_deploy_lookup = defaultdict(list)
	for network_controller in network_controllers:
		network_deploy_lookup[network_controller.network].append(network_controller.controller)

	expected_controllers = slice_deploy_lookup[network.owner]
	for expected_controller in expected_controllers:
		if network not in network_deploy_lookup or \
		  expected_controller not in network_deploy_lookup[network]:
			nd = ControllerNetwork(network=network, controller=expected_controller)
			nd.save()