예제 #1
0
파일: vmstart.php 프로젝트: ankit-iitb/vlab
            echo "<script>alert(\"VM not created.\")</script>";
        }
    } else {
        echo "<script>alert(\"No such VM for you.\")</script>";
    }
}
if (isset($_POST['start']) && $_POST['start'] == "") {
    echo "<script>alert(\"You cannot give blank VM Name\")</script>";
}
//						STOP VM
if (isset($_POST['stop']) && $_POST['stop'] != "") {
    $vmname = $_POST['stop'];
    $vmname = trim($vmname);
    $user = trim($user);
    if (strlen(strstr($vmname, $user)) > 0) {
        if ($libvirt->is_active($vmname) == '1') {
            $libvirt->domain_shutdown($vmname);
        } else {
            $result = mysql_query("SELECT status from vm_info where vmname='{$vmname}'");
            $row = mysql_fetch_array($result);
            $status = $row['status'];
            if ($status == 0) {
                echo "<script>alert(\"VM not created.\")</script>";
            } else {
                echo "<script>alert(\"VM is not running.\")</script>";
            }
        }
    } else {
        echo "<script>alert(\"No such VM for you.\")</script>";
    }
}
예제 #2
0
			<pre style="float:right;">Filter By: </pre>			
		</div>
		<div id="listing">
			<a style="float:left;margin-left:8%;font:Arial;font-size:80%;">VM Name</a>
			<a style="margin-left:8%;font:Arial;font-size:80%;">Screenshot</a>
			<a style="margin-left:15%;font:Arial;font-size:80%;">VM Info</a>
			<a style="margin-left:15%;font:Arial;font-size:80%;">Start/Shutdown VM</a>
			<?php 
if ((isset($_POST['type']) && $_POST['type'] == 'ALL' || empty($_POST['type'])) && empty($_POST['courseid'])) {
    $list = libvirt_list_domains($libvirt->conn);
    $size = sizeof($list);
    for ($i = 0; $i < $size; $i++) {
        echo "<div id=\"uppervm\">";
        echo "<div id=\"vmname\">" . $list[$i] . "</div>";
        echo "<div id=\"vmscreen\">";
        if ($libvirt->is_active($list[$i])) {
            echo "<img src=\"images/running.jpg\" height=95% style=\"border:2px solid gray;border-radius:10px;\">";
        } else {
            echo "<img src=\"images/vm.png\" height=95% style=\"border:2px solid gray;border-radius:10px;\">";
        }
        echo "</div>";
        echo "<div id=\"vminfo\">";
        $res = libvirt_domain_lookup_by_name($libvirt->conn, $list[$i]) or die(libvirt_get_last_error());
        $info = libvirt_domain_get_info($res) or die(libvirt_get_last_error());
        $result = mysql_query("select template_info.os from template_info,course_info where template_info.templatename=course_info.template && course_info.courseid in \t\t\t\t\t\t\t(SELECT courseid from vm_info where vmname='{$list[$i]}')");
        $row = mysql_fetch_array($result);
        //	if(strlen(strstr($row['os'],"Ubuntu"))>0)
        //	{ echo "<img src=\"images/icon-ubuntu.png\" height=95% style=\"float:right;margin-right:10%;\">";}
        echo "Max memory:\t" . $info['maxMem'] . " KB<br>";
        echo "Used Memory:\t" . $info['memory'] . " KB<br>";
        if ($info['state'] == '5') {
예제 #3
0
    while ($row = mysql_fetch_array($result)) {
        $course = $row['courseid'];
        echo "<div id=\"topwidget\" style=\"float:left;\">";
        echo "<div id=\"topstrip\">";
        echo "VM(s) for {$course}";
        echo "<button type=\"button\" class=\"primary\">-</button>";
        echo "</div>";
        echo "<div id=\"topwidget-main\">";
        echo "<table style=\"font:serif;font-size:80%;text-align:left;\">";
        $result1 = mysql_query("select * from vm_info where courseid='{$course}'");
        if (mysql_num_rows($result1) == 0) {
            echo "No student is enrolled in this course<br>";
        }
        while ($row = mysql_fetch_array($result1)) {
            $vm = $row['vmname'];
            $a = $libvirt->is_active($vm) or libvirt_get_last_error();
            if ($a) {
                echo "<tr><th>VM " . $vm . "</th><td>: Running</td></tr>";
            } else {
                echo "<tr><th>VM " . $vm . "</th><td>: Shutdown</td></tr>";
            }
        }
        echo "</table>";
        echo "</div>";
        echo "</div>";
    }
}
?>
</div>
<?php 
if ($option == 3) {