r4220 update: 802.1q: fixed pruning of mgmt vlan.
authorAlexey Andriyanov <alan@al-an.info>
Sun, 13 Feb 2011 14:49:38 +0000 (14:49 +0000)
committerAlexey Andriyanov <alan@al-an.info>
Sun, 13 Feb 2011 14:49:38 +0000 (14:49 +0000)
produceUplinkPorts: added extra parameter '$object_id', added searchig for mgmt vlans
save8021QPorts: added extra parameter to produceUplinkPorts call
renderObject8021QPorts: idem
exec8021QDeploy: idem
recalc8021QPorts: idem, twice

ChangeLog
wwwroot/inc/functions.php
wwwroot/inc/interface.php
wwwroot/inc/ophandlers.php

index f9974e4..97ab6d6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 0.19.1
        update: UI: rack lists are now reduced by common tags with object on Rackspace tab (FILTER_RACKLIST_BY_TAGS config var)
+       update: 802.1q: If switch has IP interface in some VLAN linked to IP subnet, this VLAN is not pruned from switch's uplink
 0.19.0 2011-02-12
        new feature: IPv6 support, except of LivePTR, NAT and SLB functionality (by Alexey Andriyanov)
        new feature: cable ID column for links (#328, by Giovani Zamboni and Jens Weibler)
index 8d8f31e..af266c9 100644 (file)
@@ -3317,10 +3317,37 @@ function filter8021QChangeRequests
 }
 
 // take port list with order applied and return uplink ports in the same format
-function produceUplinkPorts ($domain_vlanlist, $portlist)
+function produceUplinkPorts ($domain_vlanlist, $portlist, $object_id)
 {
        $ret = array();
        $employed = array();
+
+       // find VLANs for object's L3 allocations
+       $cell = spotEntity ('object', $object_id);
+       amplifyCell ($cell);
+       foreach (array ('ipv4', 'ipv6') as $family)
+       {
+               $seen_nets = array();
+               foreach ($cell[$family] as $ip => $allocation)
+               {
+                       if ($family == 'ipv6')
+                               $ip = new IPv6Address ($ip);
+                       if ($net_id = ($family == 'ipv6' ? getIPv6AddressNetworkId ($ip) : getIPv4AddressNetworkId ($ip)))
+                       {
+                               if (! isset($seen_nets[$net_id]))
+                                       $seen_nets[$net_id]     = 1;
+                               else
+                                       continue;
+                               $net = spotEntity ("${family}net", $net_id);
+                               amplifyCell ($net);
+                               foreach ($net['8021q'] as $vlan)
+                                       if (! in_array ($vlan['vlan_id'], $employed))
+                                               $employed[] = $vlan['vlan_id'];
+
+                       }
+               }
+       }
+
        foreach ($domain_vlanlist as $vlan_id => $vlan)
                if ($vlan['vlan_type'] == 'compulsory')
                        $employed[] = $vlan_id;
@@ -3607,7 +3634,7 @@ function exec8021QDeploy ($object_id, $do_push)
        // Take new "desired" configuration and derive uplink port configuration
        // from it. Then cancel changes to immune VLANs and save resulting
        // changes (if any left).
-       $new_uplinks = filter8021QChangeRequests ($domain_vlanlist, $Dnew, produceUplinkPorts ($domain_vlanlist, $Dnew));
+       $new_uplinks = filter8021QChangeRequests ($domain_vlanlist, $Dnew, produceUplinkPorts ($domain_vlanlist, $Dnew, $vswitch['object_id']));
        $nsaved_uplinks += replace8021QPorts ('desired', $vswitch['object_id'], $Dnew, $new_uplinks);
        if ($nsaved + $nsaved_uplinks)
        {
@@ -3844,7 +3871,7 @@ function recalc8021QPorts ($switch_id, $check_only = FALSE)
                        $remote_before = $remote_order;
                        if ($remote_order[$remote_pn]['vst_role'] == 'uplink')
                        {
-                               $remote_uplinks = filter8021QChangeRequests ($remote_domain_vlanlist, $remote_before, produceUplinkPorts ($remote_domain_vlanlist, $remote_order));
+                               $remote_uplinks = filter8021QChangeRequests ($remote_domain_vlanlist, $remote_before, produceUplinkPorts ($remote_domain_vlanlist, $remote_order, $remote_vswitch['object_id']));
                                $remote_port_order = $remote_uplinks[$remote_pn];
                                $new_order = produceDownlinkPort ($domain_vlanlist, $pn, array ($pn => $local_port_order), $remote_port_order);
                                $local_port_order = $new_order[$pn]; // this updates $order
@@ -3860,7 +3887,7 @@ function recalc8021QPorts ($switch_id, $check_only = FALSE)
        }
 
        // calculate local uplinks, store changes in $order
-       foreach (filter8021QChangeRequests ($domain_vlanlist, $before, produceUplinkPorts ($domain_vlanlist, $order)) as $pn => $portorder)
+       foreach (filter8021QChangeRequests ($domain_vlanlist, $before, produceUplinkPorts ($domain_vlanlist, $order, $vswitch['object_id'])) as $pn => $portorder)
                $order[$pn] = $portorder;
        // queue changes in D-config of local switch
        if ($changed = queueChangesToSwitch ($switch_id, $order, $before, $check_only))
index 39bb7e7..43275df 100644 (file)
@@ -8034,7 +8034,7 @@ function renderObject8021QPorts ($object_id)
        $desired_config = apply8021QOrder ($vswitch['template_id'], getStored8021QConfig ($object_id, 'desired'));
        $cached_config = getStored8021QConfig ($object_id, 'cached');
        $desired_config = sortPortList  ($desired_config);
-       $uplinks = filter8021QChangeRequests ($vdom['vlanlist'], $desired_config, produceUplinkPorts ($vdom['vlanlist'], $desired_config));
+       $uplinks = filter8021QChangeRequests ($vdom['vlanlist'], $desired_config, produceUplinkPorts ($vdom['vlanlist'], $desired_config, $vswitch['object_id']));
        echo '<table border=0 width="100%"><tr valign=top><td class=tdleft width="50%">';
        // port list
        echo '<table cellspacing=0 cellpadding=5 align=center class=widetable>';
index f51b4a2..450e217 100644 (file)
@@ -2452,7 +2452,7 @@ function save8021QPorts ()
                $changes = authorize8021QChangeRequests ($before, $changes);
                foreach ($changes as $port_name => $port)
                        $after[$port_name] = $port;
-               $new_uplinks = filter8021QChangeRequests ($domain_vlanlist, $after, produceUplinkPorts ($domain_vlanlist, $after));
+               $new_uplinks = filter8021QChangeRequests ($domain_vlanlist, $after, produceUplinkPorts ($domain_vlanlist, $after, $vswitch['object_id']));
                $npulled = replace8021QPorts ('desired', $vswitch['object_id'], $before, $changes);
                $nsaved_uplinks = replace8021QPorts ('desired', $vswitch['object_id'], $before, $new_uplinks);
        }