コード例 #1
0
ファイル: syncdomain.php プロジェクト: ivladdalvi/racktables
        if ($current_time < $pidfile_mtime + 15 * 60) {
            exit(0);
        }
        print_message_line("Failed to lock {$filename}, already locked by PID " . trim(fgets($fp, 10)));
        exit(1);
    }
    ftruncate($fp, 0);
    fwrite($fp, getmypid() . "\n");
    // don't close $fp yet: we need to keep an flock
}
// fetch all the needed data from DB (preparing for DB connection loss)
$switch_queue = array();
foreach ($switch_list as $object_id) {
    $cell = spotEntity('object', $object_id);
    $new_disabled = !considerConfiguredConstraint($cell, 'SYNC_802Q_LISTSRC');
    $queue = detectVLANSwitchQueue(getVLANSwitchInfo($object_id));
    if ($queue == 'disabled' xor $new_disabled) {
        usePreparedExecuteBlade('UPDATE VLANSwitch SET out_of_sync="yes", last_error_ts=NOW(), last_errno=? WHERE object_id=?', array($new_disabled ? E_8021Q_SYNC_DISABLED : E_8021Q_NOERROR, $object_id));
    } elseif (in_array($queue, $todo[$options['mode']])) {
        $switch_queue[] = $cell;
    }
}
// YOU SHOULD NOT USE DB FUNCTIONS BELOW IN THE PARENT PROCESS
// THE PARENT'S DB CONNECTION IS LOST DUE TO RECONNECTING IN THE CHILD
$fork_slots = getConfigVar('SYNCDOMAIN_MAX_PROCESSES');
$do_fork = $fork_slots > 1 and extension_loaded('pcntl');
if ($fork_slots > 1 and !$do_fork) {
    throw new RackTablesError('PHP extension \'pcntl\' not found, can not use childs', RackTablesError::MISCONFIGURED);
}
$switches_working = 0;
$switchesdone = 0;
コード例 #2
0
ファイル: interface.php プロジェクト: xtha/salt
function renderVLANDomain($vdom_id)
{
    global $nextorder;
    $mydomain = getVLANDomain($vdom_id);
    echo '<table border=0 class=objectview cellspacing=0 cellpadding=0>';
    echo '<tr><td colspan=2 align=center><h1>' . niftyString($mydomain['description']);
    echo '</h1></td></tr>';
    echo "<tr><td class=pcleft width='50%'>";
    if (!count($mydomain['switchlist'])) {
        startPortlet('no orders');
    } else {
        startPortlet('orders (' . count($mydomain['switchlist']) . ')');
        echo '<table cellspacing=0 cellpadding=5 align=center class=widetable>';
        echo '<tr><th>switch</th><th>template</th><th>status</th></tr>';
        $order = 'odd';
        $vstlist = getVSTOptions();
        global $dqtitle;
        foreach ($mydomain['switchlist'] as $switchinfo) {
            echo "<tr class=row_{$order}><td>";
            renderCell(spotEntity('object', $switchinfo['object_id']));
            echo '</td><td class=tdleft>';
            echo $vstlist[$switchinfo['template_id']];
            echo '</td><td>';
            $qcode = detectVLANSwitchQueue(getVLANSwitchInfo($switchinfo['object_id']));
            printImageHREF("DQUEUE {$qcode}", $dqtitle[$qcode]);
            echo '</td></tr>';
            $order = $nextorder[$order];
        }
        echo '</table>';
    }
    finishPortlet();
    echo '</td><td class=pcright>';
    if (!count($myvlans = getDomainVLANs($vdom_id))) {
        startPortlet('no VLANs');
    } else {
        startPortlet('VLANs (' . count($myvlans) . ')');
        $order = 'odd';
        global $vtdecoder;
        echo '<table class=cooltable align=center border=0 cellpadding=5 cellspacing=0>';
        echo '<tr><th>VLAN ID</th><th>propagation</th><th>';
        printImageHREF('net', 'IPv4 networks linked');
        echo '</th><th>ports</th><th>description</th></tr>';
        foreach ($myvlans as $vlan_id => $vlan_info) {
            echo "<tr class=row_{$order}>";
            echo '<td class=tdright>' . mkA($vlan_id, 'vlan', "{$vdom_id}-{$vlan_id}") . '</td>';
            echo '<td>' . $vtdecoder[$vlan_info['vlan_type']] . '</td>';
            echo '<td class=tdright>' . ($vlan_info['netc'] ? $vlan_info['netc'] : '&nbsp;') . '</td>';
            echo '<td class=tdright>' . ($vlan_info['portc'] ? $vlan_info['portc'] : '&nbsp;') . '</td>';
            echo "<td class=tdleft>{$vlan_info['vlan_descr']}</td></tr>";
            $order = $nextorder[$order];
        }
        echo '</table>';
    }
    finishPortlet();
    echo '</td></tr></table>';
}
コード例 #3
0
function renderVLANDomain($vdom_id)
{
    global $nextorder;
    $mydomain = getVLANDomain($vdom_id);
    echo '<table border=0 class=objectview cellspacing=0 cellpadding=0>';
    echo '<tr><td colspan=2 align=center><h1>' . stringForTD($mydomain['description']);
    echo '</h1></td></tr>';
    echo "<tr><td class=pcleft width='50%'>";
    if (!count($mydomain['switchlist'])) {
        startPortlet('no orders');
    } else {
        startPortlet('orders (' . count($mydomain['switchlist']) . ')');
        echo '<table cellspacing=0 cellpadding=5 align=center class=widetable>';
        echo '<tr><th>switch</th><th>template</th><th>status</th></tr>';
        $order = 'odd';
        $vstlist = getVSTOptions();
        global $dqtitle;
        foreach ($mydomain['switchlist'] as $switchinfo) {
            echo "<tr class=row_{$order}><td>";
            renderCell(spotEntity('object', $switchinfo['object_id']));
            echo '</td><td class=tdleft>';
            echo $vstlist[$switchinfo['template_id']];
            echo '</td><td>';
            $qcode = detectVLANSwitchQueue(getVLANSwitchInfo($switchinfo['object_id']));
            printImageHREF("DQUEUE {$qcode}", $dqtitle[$qcode]);
            echo '</td></tr>';
            $order = $nextorder[$order];
        }
        echo '</table>';
    }
    finishPortlet();
    echo '</td><td class=pcright>';
    $domain_options = getVLANDomainOptions();
    $myvlans = array();
    foreach (array_merge(array($vdom_id), getDomainGroupMembers($vdom_id)) as $domain_id) {
        foreach (getDomainVLANs($domain_id, TRUE) as $vlan_id => $vlan_info) {
            $vlan_info['domain_id'] = $domain_id;
            $vlan_info['domain_descr'] = $domain_options[$domain_id];
            $myvlans[$vlan_id][$domain_id] = $vlan_info;
        }
    }
    ksort($myvlans, SORT_NUMERIC);
    if (!count($myvlans)) {
        startPortlet('no VLANs');
    } else {
        startPortlet('VLANs (' . count($myvlans) . ')');
        $order = 'odd';
        global $vtdecoder;
        echo '<table class=cooltable align=center border=0 cellpadding=5 cellspacing=0>';
        echo '<tr><th>VLAN ID</th><th><span title="propagation flag">P</span></th><th>';
        printImageHREF('net', 'IPv4 networks linked');
        echo '</th><th>ports</th><th>description</th></tr>';
        foreach ($myvlans as $vlan_id => $vlan_list) {
            foreach ($vlan_list as $domain_id => $vlan_info) {
                echo "<tr class=row_{$order}>";
                echo '<td class=tdright>' . (count($vlan_list) > 1 ? stringForLabel($domain_options[$domain_id]) . ' ' : '') . formatVLANAsShortLink($vlan_info) . '</td>';
                echo '<td>' . $vtdecoder[$vlan_info['vlan_type']] . '</td>';
                echo '<td class=tdright>' . ($vlan_info['netc'] ? $vlan_info['netc'] : '&nbsp;') . '</td>';
                echo '<td class=tdright>' . ($vlan_info['portc'] ? $vlan_info['portc'] : '&nbsp;') . '</td>';
                echo '<td class=tdleft>' . stringForLabel($vlan_info['vlan_descr']) . '</td></tr>';
            }
            $order = $nextorder[$order];
        }
        echo '</table>';
    }
    finishPortlet();
    echo '</td></tr></table>';
}
コード例 #4
0
ファイル: syncdomain.php プロジェクト: ehironymous/racktables
        exit(1);
    }
    // don't indicate failure unless the pidfile is 15 minutes or more old
    if ($current_time < $pidfile_mtime + 15 * 60) {
        exit(0);
    }
    print_message_line("Failed to lock {$filename}, already locked by PID " . mb_substr(file_get_contents($filename), 0, 6));
    exit(1);
}
ftruncate($fp, 0);
fwrite($fp, getmypid() . "\n");
fclose($fp);
// fetch all the needed data from DB (preparing for DB connection loss)
$switch_queue = array();
foreach ($switch_list as $object_id) {
    if (in_array(detectVLANSwitchQueue(getVLANSwitchInfo($object_id)), $todo[$options['mode']])) {
        $cell = spotEntity('object', $object_id);
        if (considerConfiguredConstraint($cell, 'SYNC_802Q_LISTSRC')) {
            $switch_queue[] = $cell;
        }
    }
}
// YOU SHOULD NOT USE DB FUNCTIONS BELOW IN THE PARENT PROCESS
// THE PARENT'S DB CONNECTION IS LOST DUE TO RECONNECTING IN THE CHILD
$fork_slots = getConfigVar('SYNCDOMAIN_MAX_PROCESSES');
$do_fork = $fork_slots > 1 and extension_loaded('pcntl');
if ($fork_slots > 1 and !$do_fork) {
    throw new RackTablesError('PHP extension \'pcntl\' not found, can not use childs', RackTablesError::MISCONFIGURED);
}
$switches_working = 0;
$switchesdone = 0;
コード例 #5
0
    $vswitch_filter['domain_id'] = $options['vdid'];
}
$switch_list = getVLANSwitchInfoRows($vswitch_filter);
$enabled_switches = listConstraint('object', 'SYNC_802Q_LISTSRC');
$switch_queue = array();
foreach ($switch_list as $vswitch) {
    $object_id = $vswitch['object_id'];
    $new_disabled = !isset($enabled_switches[$object_id]);
    $queue = detectVLANSwitchQueue($vswitch);
    if ($queue != 'disabled' && $new_disabled) {
        setVLANSwitchError($object_id, E_8021Q_SYNC_DISABLED);
        continue;
    } elseif ($queue == 'disabled' && !$new_disabled) {
        $vswitch['last_errno'] = E_8021Q_NOERROR;
        setVLANSwitchError($object_id, $vswitch['last_errno']);
        $queue = detectVLANSwitchQueue($vswitch);
    }
    if (in_array($queue, $todo[$options['mode']])) {
        $switch_queue[] = spotEntity('object', $object_id);
    }
}
// YOU SHOULD NOT USE DB FUNCTIONS BELOW IN THE PARENT PROCESS
// THE PARENT'S DB CONNECTION IS LOST DUE TO RECONNECTING IN THE CHILD
$fork_slots = getConfigVar('SYNCDOMAIN_MAX_PROCESSES');
$do_fork = $fork_slots > 1 and extension_loaded('pcntl');
if ($fork_slots > 1 and !$do_fork) {
    throw new RackTablesError('PHP extension \'pcntl\' not found, can not use childs', RackTablesError::MISCONFIGURED);
}
$switches_working = 0;
$switchesdone = 0;
foreach ($switch_queue as $object) {
コード例 #6
0
ファイル: functions.php プロジェクト: rhysm/racktables
function get8021QDeployQueues()
{
    global $dqtitle;
    $ret = array();
    foreach (array_keys($dqtitle) as $qcode) {
        if ($qcode != 'disabled') {
            $ret[$qcode] = array('enabled' => array(), 'disabled' => array());
        }
    }
    foreach (getVLANSwitches() as $object_id) {
        $vswitch = getVLANSwitchInfo($object_id);
        if ('' != ($qcode = detectVLANSwitchQueue($vswitch))) {
            $cell = spotEntity('object', $vswitch['object_id']);
            $enabled_key = considerConfiguredConstraint($cell, 'SYNC_802Q_LISTSRC') ? 'enabled' : 'disabled';
            $ret[$qcode][$enabled_key][] = $vswitch;
        }
    }
    return $ret;
}