Esempio n. 1
0
def update_topo(topo, test_vn, new_policy):
    ''' Purpose of this def is to update & return topology object as needed.
    Example:  Need to modify VN's policy list..  This change requires update
    of every [affected] policy's VN list as well.
    Reference info of how data is maintained:
    vn_policy=  {'vnet0': ['policy0', 'policy1'], 'vnet1': ['policy2', 'policy3']}
    policy_vn= {'policy0': ['vnet0']}
    '''
    n_topo = copy.deepcopy(topo)
    # i] remove test_vn from currently associated policies
    topo_helper_obj = topology_helper(n_topo)
    n_topo.policy_vn = topo_helper_obj.get_policy_vn()
    for p in topo.vn_policy[test_vn]:
        n_topo.policy_vn[p].remove(test_vn)
    # ii] update vn_policy[test_vn] and policy_vn[new_policy] with new info
    n_topo.vn_policy[test_vn] = [new_policy]
    n_topo.policy_vn[new_policy].append(test_vn)
    return n_topo
def update_topo(topo, test_vn, new_policy):
    ''' Purpose of this def is to update & return topology object as needed.
    Example:  Need to modify VN's policy list..  This change requires update
    of every [affected] policy's VN list as well.
    Reference info of how data is maintained:
    vn_policy=  {'vnet0': ['policy0', 'policy1'], 'vnet1': ['policy2', 'policy3']}
    policy_vn= {'policy0': ['vnet0']}
    '''
    n_topo = copy.deepcopy(topo)
    # i] remove test_vn from currently associated policies
    topo_helper_obj = topology_helper(n_topo)
    n_topo.policy_vn = topo_helper_obj.get_policy_vn()
    for p in topo.vn_policy[test_vn]:
        n_topo.policy_vn[p].remove(test_vn)
    # ii] update vn_policy[test_vn] and policy_vn[new_policy] with new info
    n_topo.vn_policy[test_vn] = [new_policy]
    n_topo.policy_vn[new_policy].append(test_vn)
    return n_topo