How to use the sol.opt.topology.provisioning.provisionLinks function in SoL

To help you get started, we’ve selected a few SoL examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github progwriter / SOL / old_examples / BasicLoadBalancer.py View on Github external
generators.forceSwitchLabels(topo)
    # For the sake of example, set middleboxes everywhere
    for node, data in topo.nodes():
        topo.setMbox(node)
        topo.setServiceTypes(node, ['dpi'])
    iePairs = provisioning.generateIEpairs(topo)
    trafficMatrix = provisioning.computeUniformTrafficMatrixPerIE(
        iePairs, 10 ** 6)
    trafficClasses = generateTrafficClasses(iePairs, trafficMatrix, {'allTraffic': 1},
                                            {'allTraffic': 100})
    for t in trafficClasses:
        t.cpuCost = 10
    maxCPUCap = provisioning.computeMaxIngressLoad(trafficClasses, {t: t.cpuCost for t in trafficClasses})
    nodeCaps = {node: maxCPUCap for node, data in topo.nodes()
                if 'dpi' in topo.getServiceTypes(node)}
    linkCaps = provisioning.provisionLinks(topo, trafficClasses, 2)

    # Setup the basic config
    config = {
        'name': 'BasicLoadBalancer',  # for clarity

        'topology': topo,

        'trafficClasses': trafficClasses,
        'predicate': nullPredicate,
        'selectStrategy': 'random',
        'selectNumber': 10,
        'nodeCaps': nodeCaps,
        'linkCaps': linkCaps,
        'nodeCapFunction': functools.partial(defaultNodeCapFunc, nodeCaps=nodeCaps),
        'linkCapFunction': functools.partial(defaultLinkFunc, linkCaps=linkCaps),
        'constraints': [('nodecap', 'cpu'), 'allocateflow', 'routeall', ('linkcap', 'bandwidth')],
github progwriter / SOL / old_examples / SIMPLE.py View on Github external
iePairs, 10 ** 6)
    # compute traffic classes, only one class
    trafficClasses = generateTrafficClasses(iePairs, trafficMatrix, {'allTraffic': 1},
                                            {'allTraffic': 2000})
    # assign flow processing cost for each traffic class
    for t in trafficClasses:
        t.cpuCost = 10
    # provision the node cpu capacities
    maxCPUCap = provisioning.computeMaxIngressLoad(trafficClasses, {t: t.cpuCost for t in trafficClasses})
    nodeCaps = dict()
    nodeCaps['cpu'] = {node: maxCPUCap * 2 for node, data in topo.nodes()
                       if 'fw' or 'ids' in topo.getServiceTypes(node)}
    # and the tcam capacities
    nodeCaps['tcam'] = {node: 1000 for node, data in topo.nodes()}
    # similartly with link capacities
    linkCaps = provisioning.provisionLinks(topo, trafficClasses, 3)

    # =====================================
    # Write our user defined functions now:
    # =====================================

    def SIMPLE_predicate(path, topology):
        # Firewall followed by IDS is the requirement for the path
        return any([s == ('fw', 'ids') for s in itertools.product(*[topology.getServiceTypes(node)
                                                                    for node in path.useMBoxes])])

    def SIMPLE_NodeCapFunc(node, tc, path, resource, nodeCaps):
        # this computes the cost of processing the traffic class at
        if resource == 'cpu' and node in nodeCaps['cpu']:
            return tc.volFlows * tc.cpuCost / nodeCaps[resource][node]
        else:
            raise ValueError("wrong resource")  # just in case