Exemple #1
0
function deleteVlan()
{
    genericAssertion('vlan_ck', 'uint-vlan');
    $confports = getVLANConfiguredPorts($_REQUEST['vlan_ck']);
    if (!empty($confports)) {
        throw new RackTablesError("You can not delete VLAN that has assosiated ports");
    }
    list($vdom_id, $vlan_id) = decodeVLANCK($_REQUEST['vlan_ck']);
    usePreparedDeleteBlade('VLANDescription', array('domain_id' => $vdom_id, 'vlan_id' => $vlan_id));
    showSuccess("VLAN {$vlan_id} has been deleted");
    return buildRedirectURL('vlandomain', 'default', array('vdom_id' => $vdom_id));
}
function deleteVlan()
{
    genericAssertion('vlan_ck', 'uint-vlan');
    list($vdom_id, $vlan_id) = decodeVLANCK($_REQUEST['vlan_ck']);
    $n_cleared = pinpointDeleteVlan($vdom_id, $vlan_id);
    if ($n_cleared > 0) {
        showSuccess("VLAN {$vlan_id} removed from {$n_cleared} ports");
    }
    // since there is no strict foreign keys refering VLANDescription, we can delete a row
    usePreparedDeleteBlade('VLANDescription', array('domain_id' => $vdom_id, 'vlan_id' => $vlan_id));
    showSuccess("VLAN {$vlan_id} has been deleted");
    return buildRedirectURL('vlandomain', 'default', array('vdom_id' => $vdom_id));
}
Exemple #3
0
function getVLANConfiguredPorts($vlan_ck)
{
    $result = usePreparedSelectBlade('SELECT PAV.object_id, PAV.port_name ' . 'FROM PortAllowedVLAN AS PAV ' . 'INNER JOIN VLANSwitch AS VS ON PAV.object_id = VS.object_id ' . 'WHERE domain_id = ? AND vlan_id = ? ' . 'ORDER BY PAV.object_id, PAV.port_name', decodeVLANCK($vlan_ck));
    $ret = array();
    while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
        $ret[$row['object_id']][] = $row['port_name'];
    }
    return $ret;
}
Exemple #4
0
function dynamic_title_decoder($path_position)
{
    global $sic, $page_by_realm;
    static $net_id;
    try {
        switch ($path_position) {
            case 'index':
                return array('name' => '/' . getConfigVar('enterprise'), 'params' => array());
            case 'chapter':
                $chapter_no = assertUIntArg('chapter_no');
                $chapters = getChapterList();
                $chapter_name = isset($chapters[$chapter_no]) ? $chapters[$chapter_no]['name'] : 'N/A';
                return array('name' => "Chapter '{$chapter_name}'", 'params' => array('chapter_no' => $chapter_no));
            case 'user':
                $userinfo = spotEntity('user', assertUIntArg('user_id'));
                return array('name' => "Local user '" . $userinfo['user_name'] . "'", 'params' => array('user_id' => $userinfo['user_id']));
            case 'ipv4rspool':
                $pool_info = spotEntity('ipv4rspool', assertUIntArg('pool_id'));
                return array('name' => !strlen($pool_info['name']) ? 'ANONYMOUS' : $pool_info['name'], 'params' => array('pool_id' => $pool_info['id']));
            case 'ipv4vs':
                $vs_info = spotEntity('ipv4vs', assertUIntArg('vs_id'));
                return array('name' => $vs_info['dname'], 'params' => array('vs_id' => $vs_info['id']));
            case 'ipvs':
                $vs_info = spotEntity('ipvs', assertUIntArg('vs_id'));
                return array('name' => $vs_info['name'], 'params' => array('vs_id' => $vs_info['id']));
            case 'object':
                $object = spotEntity('object', assertUIntArg('object_id'));
                return array('name' => $object['dname'], 'params' => array('object_id' => $object['id']));
            case 'location':
                $location = spotEntity('location', assertUIntArg('location_id'));
                return array('name' => $location['name'], 'params' => array('location_id' => $location['id']));
            case 'row':
                global $pageno;
                switch ($pageno) {
                    case 'rack':
                        $rack = spotEntity('rack', assertUIntArg('rack_id'));
                        return array('name' => $rack['row_name'], 'params' => array('row_id' => $rack['row_id'], 'location_id' => $rack['location_id']));
                    case 'row':
                        $row_info = getRowInfo(assertUIntArg('row_id'));
                        return array('name' => $row_info['name'], 'params' => array('row_id' => $row_info['id'], 'location_id' => $row_info['location_id']));
                    default:
                        break;
                }
            case 'rack':
                $rack_info = spotEntity('rack', assertUIntArg('rack_id'));
                return array('name' => $rack_info['name'], 'params' => array('rack_id' => $rack_info['id']));
            case 'search':
                if (isset($_REQUEST['q'])) {
                    return array('name' => "search results for '{$_REQUEST['q']}'", 'params' => array('q' => $_REQUEST['q']));
                } else {
                    return array('name' => 'search results', 'params' => array());
                }
            case 'file':
                $file = spotEntity('file', assertUIntArg('file_id'));
                return array('name' => niftyString($file['name'], 30, FALSE), 'params' => array('file_id' => $_REQUEST['file_id']));
            case 'ipaddress':
                $address = getIPAddress(ip_parse($_REQUEST['ip']));
                return array('name' => niftyString($address['ip'] . ($address['name'] != '' ? ' (' . $address['name'] . ')' : ''), 50, FALSE), 'params' => array('ip' => $address['ip']));
            case 'ipv4net':
            case 'ipv6net':
                global $pageno;
                switch ($pageno) {
                    case 'ipaddress':
                        $net = spotNetworkByIP(ip_parse($_REQUEST['ip']));
                        $ret = array('name' => $net['ip'] . '/' . $net['mask'], 'params' => array('id' => $net['id'], 'page' => $net['realm'], 'hl_ip' => $_REQUEST['ip']));
                        return $ret;
                    default:
                        $net = spotEntity($path_position, assertUIntArg('id'));
                        return array('name' => $net['ip'] . '/' . $net['mask'], 'params' => array('id' => $net['id']));
                }
                break;
            case 'ipv4space':
            case 'ipv6space':
                global $pageno;
                switch ($pageno) {
                    case 'ipaddress':
                        $net_id = getIPAddressNetworkId(ip_parse($_REQUEST['ip']));
                        break;
                    case 'ipv4net':
                    case 'ipv6net':
                        $net_id = $_REQUEST['id'];
                        break;
                    default:
                        $net_id = NULL;
                }
                $params = array();
                if (isset($net_id)) {
                    $params = array('eid' => $net_id, 'hl_net' => 1, 'clear-cf' => '');
                }
                unset($net_id);
                $ip_ver = preg_replace('/[^\\d]*/', '', $path_position);
                return array('name' => "IPv{$ip_ver} space", 'params' => $params);
            case 'vlandomain':
                global $pageno;
                switch ($pageno) {
                    case 'vlandomain':
                        $vdom_id = $_REQUEST['vdom_id'];
                        break;
                    case 'vlan':
                        list($vdom_id, $dummy) = decodeVLANCK($_REQUEST['vlan_ck']);
                        break;
                    default:
                        break;
                }
                $vdlist = getVLANDomainOptions();
                if (!array_key_exists($vdom_id, $vdlist)) {
                    throw new EntityNotFoundException('VLAN domain', $vdom_id);
                }
                return array('name' => niftyString("domain '" . $vdlist[$vdom_id] . "'", 20, FALSE), 'params' => array('vdom_id' => $vdom_id));
            case 'vlan':
                return array('name' => formatVLANAsPlainText(getVLANInfo($sic['vlan_ck'])), 'params' => array('vlan_ck' => $sic['vlan_ck']));
            case 'vst':
                $vst = spotEntity('vst', $sic['vst_id']);
                return array('name' => niftyString("template '" . $vst['description'] . "'", 50, FALSE), 'params' => array('vst_id' => $sic['vst_id']));
            case 'dqueue':
                global $dqtitle;
                return array('name' => 'queue "' . $dqtitle[$sic['dqcode']] . '"', 'params' => array('qcode' => $sic['dqcode']));
            default:
                break;
        }
        // default behaviour is throwing an exception
        throw new RackTablesError('dynamic_title decoding error', RackTablesError::INTERNAL);
    } catch (RackTablesError $e) {
        return array('name' => __FUNCTION__ . '() failure', 'params' => array());
    }
}