コード例 #1
0
ファイル: xenimport.php プロジェクト: xtha/salt
function showImportTab()
{
    global $tagtree;
    echo "<h2 style='padding-left: 10px;'>Xen VM Import</h2>";
    startPortlet("Errors");
    echo "<div style='color: red;font-weight: bold;'>";
    echo "Can only have one tag selected!";
    echo "</div><br>";
    finishPortlet();
    echo "<style>label {display: block; font-weight: bold;} th {background-color: #eee; }</style>\n\t\t<div style='float: left; width: 30%'>";
    startPortlet("Options");
    ?>
	<form method='post' name='discover' action='?module=redirect&page=depot&tab=xen_import&op=discoverVMs'>
		<table align='center'>
			<tr>
				<td>
					<label for='vmMasters'>Xen Pool Masters (IP, one per line)</label>
					<textarea rows='20' cols='20' name='vmMasters'></textarea><br><br>
					<input type='submit' value='Discover VMs'>
				</td>
				<td>
					<label for='xenUser'>Username:</label><input type='text' length='20' name='xenUser'>
                                        <label for='xenPass'>Password:</label><input type='password' length='20' name='xenPass'><br><br>
					<strong>Pool Tag</strong>
					<div class=tagselector><table border=0 align=center cellspacing=0 class="tagtree">
	<?php 
    printTagCheckboxTable('pooltags', array(), array(), $tagtree, 'object');
    ?>
					</table></div>
					<br><br>
					<strong>VM Tag</strong>
					<div class=tagselector><table border=0 align=center cellspacing=0 class="tagtree">
	<?php 
    printTagCheckboxTable('vmtags', array(), array(), $tagtree, 'object');
    ?>
					</table></div>
				</td>
			</tr>
		</table>
	<?php 
    finishPortlet();
    echo "</form></div>\n\t\t<div style='float: left; width: 70%'>";
    startPortlet("VMs Discovered");
    echo "<strong>No virtual machines discovered.</strong><br><br>";
    ?>

	<table border="1" bordercolor="CCCCCC" cellspacing="0" style="width: 100%;">
		<tr>
			<th></th>
			<th>VM Name</th>
			<th>IP Address</th>
			<th>Guest OS</th>
			<th>VM UUID</th>
		<tr>
		
		<tr>
			<th colspan="5">Pool TX-C5220-Pool1</th>
		</tr>

		<tr>
			<td><input type="checkbox" name="check1"></td>
			<td>TX-Box01</td>
			<td>192.168.129.150</td>
			<td>Centos 5.2 (Nawahee)</td>
			<td>somereallynonsenselongnumberhereforaUID</td>
		</tr>
	</table>
	<br>
	<strong>Import VM Pools into:</strong> Pools<br>
	<strong>Import VMs into:</strong> Virtuals
	<br><br>
	<input type="submit" name="import" value="Import Selected VMs and pools">
	<input type="submit" name="clear" value="Clear discovered VMs">
	
	<?php 
    finishPortlet();
    startPortlet("Debug");
    echo "<div style='text-align: left;'>";
    echo "<pre>";
    print_r($_SESSION);
    echo "</pre>";
    finishPortlet();
    echo "</div>";
    echo "</div><br clear='both'>";
    startPortlet();
    echo "XenVMImport by Tyler Montgomery";
    finishPortlet();
}
コード例 #2
0
ファイル: interface.php プロジェクト: xtha/salt
function renderCellFilterPortlet($preselect, $realm, $cell_list = array(), $bypass_params = array())
{
    addJS('js/tag-cb.js');
    addJS('tag_cb.enableNegation()', TRUE);
    global $pageno, $tabno, $taglist, $tagtree;
    $filterc = count($preselect['tagidlist']) + count($preselect['pnamelist']) + (mb_strlen($preselect['extratext']) ? 1 : 0);
    $title = $filterc ? "Tag filters ({$filterc})" : 'Tag filters';
    startPortlet($title);
    echo "<form method=get>\n";
    echo '<table border=0 align=center cellspacing=0 class="tagtree">';
    $ruler = "<tr><td colspan=2 class=tagbox><hr></td></tr>\n";
    $hr = '';
    // "reset filter" button only gets active when a filter is applied
    $enable_reset = FALSE;
    // "apply filter" button only gets active when there are checkbox/textarea inputs on the roster
    $enable_apply = FALSE;
    // and/or block
    if (getConfigVar('FILTER_SUGGEST_ANDOR') == 'yes' or strlen($preselect['andor'])) {
        echo $hr;
        $hr = $ruler;
        $andor = strlen($preselect['andor']) ? $preselect['andor'] : getConfigVar('FILTER_DEFAULT_ANDOR');
        echo '<tr>';
        foreach (array('and', 'or') as $boolop) {
            $class = 'tagbox' . ($andor == $boolop ? ' selected' : '');
            $checked = $andor == $boolop ? ' checked' : '';
            echo "<td class='{$class}'><label><input type=radio name=andor value={$boolop}";
            echo $checked . ">{$boolop}</input></label></td>";
        }
    }
    $negated_chain = array();
    foreach ($preselect['negatedlist'] as $key) {
        $negated_chain[] = array('id' => $key);
    }
    // tags block
    if (getConfigVar('FILTER_SUGGEST_TAGS') == 'yes' or count($preselect['tagidlist'])) {
        if (count($preselect['tagidlist'])) {
            $enable_reset = TRUE;
        }
        echo $hr;
        $hr = $ruler;
        // Show a tree of tags, pre-select according to currently requested list filter.
        $objectivetags = getShrinkedTagTree($cell_list, $realm, $preselect);
        if (!count($objectivetags)) {
            echo "<tr><td colspan=2 class='tagbox sparenetwork'>(nothing is tagged yet)</td></tr>";
        } else {
            $enable_apply = TRUE;
            printTagCheckboxTable('cft', buildTagChainFromIds($preselect['tagidlist']), $negated_chain, $objectivetags, $realm);
        }
        if (getConfigVar('SHRINK_TAG_TREE_ON_CLICK') == 'yes') {
            addJS('tag_cb.enableSubmitOnClick()', TRUE);
        }
    }
    // predicates block
    if (getConfigVar('FILTER_SUGGEST_PREDICATES') == 'yes' or count($preselect['pnamelist'])) {
        if (count($preselect['pnamelist'])) {
            $enable_reset = TRUE;
        }
        echo $hr;
        $hr = $ruler;
        global $pTable;
        $myPredicates = array();
        $psieve = getConfigVar('FILTER_PREDICATE_SIEVE');
        // Repack matching predicates in a way that tagOnChain() understands.
        foreach (array_keys($pTable) as $pname) {
            if (preg_match("/{$psieve}/", $pname)) {
                $myPredicates[] = array('id' => $pname, 'tag' => $pname);
            }
        }
        if (!count($myPredicates)) {
            echo "<tr><td colspan=2 class='tagbox sparenetwork'>(no predicates to show)</td></tr>";
        } else {
            $enable_apply = TRUE;
            // Repack preselect likewise.
            $myPreselect = array();
            foreach ($preselect['pnamelist'] as $pname) {
                $myPreselect[] = array('id' => $pname);
            }
            printTagCheckboxTable('cfp', $myPreselect, $negated_chain, $myPredicates);
        }
    }
    // extra code
    $enable_textify = FALSE;
    if (getConfigVar('FILTER_SUGGEST_EXTRA') == 'yes' or strlen($preselect['extratext'])) {
        $enable_textify = !empty($preselect['text']) || !empty($preselect['extratext']);
        $enable_apply = TRUE;
        if (strlen($preselect['extratext'])) {
            $enable_reset = TRUE;
        }
        echo $hr;
        $hr = $ruler;
        $class = isset($preselect['extraclass']) ? 'class=' . $preselect['extraclass'] : '';
        echo "<tr><td colspan=2><textarea name=cfe {$class}>\n" . $preselect['extratext'];
        echo "</textarea></td></tr>\n";
    }
    echo $hr;
    $hr = $ruler;
    echo '<tr><td class=tdleft>';
    // "apply"
    echo "<input type=hidden name=page value={$pageno}>\n";
    echo "<input type=hidden name=tab value={$tabno}>\n";
    foreach ($bypass_params as $bypass_name => $bypass_value) {
        echo '<input type=hidden name="' . htmlspecialchars($bypass_name, ENT_QUOTES) . '" value="' . htmlspecialchars($bypass_value, ENT_QUOTES) . '">' . "\n";
    }
    // FIXME: The user will be able to "submit" the empty form even without a "submit"
    // input. To make things consistent, it is necessary to avoid pritning both <FORM>
    // and "and/or" radio-buttons, when enable_apply isn't TRUE.
    if (!$enable_apply) {
        printImageHREF('setfilter gray');
    } else {
        printImageHREF('setfilter', 'set filter', TRUE);
    }
    echo '</form>';
    if ($enable_textify) {
        $text = empty($preselect['text']) || empty($preselect['extratext']) ? $preselect['text'] : '(' . $preselect['text'] . ')';
        $text .= !empty($preselect['extratext']) && !empty($preselect['text']) ? ' ' . $preselect['andor'] . ' ' : '';
        $text .= empty($preselect['text']) || empty($preselect['extratext']) ? $preselect['extratext'] : '(' . $preselect['extratext'] . ')';
        $text = addslashes($text);
        echo " <a href=\"#\" onclick=\"textifyCellFilter(this, '{$text}'); return false\">";
        printImageHREF('COPY', 'Make text expression from current filter');
        echo '</a>';
        addJS(<<<END
function textifyCellFilter(target, text)
{
\tvar portlet = \$(target).closest ('.portlet');
\tportlet.find ('textarea[name="cfe"]').html (text);
\tportlet.find ('input[type="checkbox"]').attr('checked', '');
\tportlet.find ('input[type="radio"][value="and"]').attr('checked','true');
}
END
, TRUE);
    }
    echo '</td><td class=tdright>';
    // "reset"
    if (!$enable_reset) {
        printImageHREF('resetfilter gray');
    } else {
        echo "<form method=get>\n";
        echo "<input type=hidden name=page value={$pageno}>\n";
        echo "<input type=hidden name=tab value={$tabno}>\n";
        echo "<input type=hidden name='cft[]' value=''>\n";
        echo "<input type=hidden name='cfp[]' value=''>\n";
        echo "<input type=hidden name='nft[]' value=''>\n";
        echo "<input type=hidden name='nfp[]' value=''>\n";
        echo "<input type=hidden name='cfe' value=''>\n";
        foreach ($bypass_params as $bypass_name => $bypass_value) {
            echo '<input type=hidden name="' . htmlspecialchars($bypass_name, ENT_QUOTES) . '" value="' . htmlspecialchars($bypass_value, ENT_QUOTES) . '">' . "\n";
        }
        printImageHREF('resetfilter', 'reset filter', TRUE);
        echo '</form>';
    }
    echo '</td></tr>';
    echo '</table>';
    finishPortlet();
}
コード例 #3
0
ファイル: importtab.php プロジェクト: xtha/salt
						</td>
						<td>
							<strong>Pool Tag</strong>
							<div class="tagselector">
								<table border=0 align=center cellspacing=0 class="tagtree">
									<?php 
printTagCheckboxTable('pooltags', array(), array(), $tagtree, 'object');
?>
								</table>
							</div>
							<br>
							<strong>VM Tag</strong>
							<div class="tagselector">
								<table border=0 align=center cellspacing=0 class="tagtree">
									<?php 
printTagCheckboxTable('vmtags', array(), array(), $tagtree, 'object');
?>
								</table>
							</div>
							<br><br>
							<input type='submit' value='Process VMs' onclick="finalizeForm()">
						</td>
					</tr>
				</table>
			</form>
	<?php 
finishPortlet();
?>
</div>

<div style='width: auto; overflow: auto; min-width: 500px;/*width: 70%*/'>
コード例 #4
0
function renderCopyEntityTagsPortlet($title, $tags, $preselect, $realm)
{
    startPortlet($title);
    echo '<a class="toggleTreeMode" style="display:none" href="#"></a>';
    echo '<table border=0 cellspacing=0 cellpadding=1 align=center class="tagtree">';
    printTagCheckboxTable('taglist', $preselect, array(), $tags, $realm);
    echo '<tr><td class=tdleft>';
    //echo "</form></td><td class=tdright>";
    echo '</td></tr></table>';
    finishPortlet();
}
コード例 #5
0
ファイル: interface.php プロジェクト: ehironymous/racktables
function renderNewEntityTags($for_realm = '')
{
    global $taglist, $tagtree;
    if (!count($taglist)) {
        echo "No tags defined";
        return;
    }
    echo '<div class=tagselector><table border=0 align=center cellspacing=0 class="tagtree">';
    printTagCheckboxTable('taglist', array(), array(), $tagtree, $for_realm);
    echo '</table></div>';
}