[one-users] vnc port in onemc

Rogier Mars rogier at fortytwo.nl
Wed Feb 24 17:42:58 PST 2010


Hi,

I've made some quick changes to ONEMC to show the VNC port in the  
interface. I've updated the template that onemc creates with a  
GRAPHICS section, enabling vnc on the quest.

As a workaround until ONE can use the VMID in the graphics section, I  
use a virsh command to get the vncport. To get this working the  
webserver user should be allowed to execute the virsh command via  
sudo. Add the following to sudoers:
apache     ALL=(ALL)       NOPASSWD: /usr/bin/virsh *

Also I encountered some problems with the model section in the KVM  
template so I commented that out as well.

Cheers,

rogier

ONE Management Console show VNC display

--- onemc/include/onemc_funcs.php	2010-02-25 02:33:04.000000000 +0100
+++ /var/www/html/onemc/include/onemc_funcs.php	2010-02-25  
02:30:51.000000000 +0100
@@ -237,11 +237,12 @@
          if (valid('nbridge')) { if ($comma) { $template .= ",\n"; };  
$comma = TRUE; $template .= "BRIDGE = \"".$_GET['nbridge']."\" "; }
          if (valid('ntarget')) { if ($comma) { $template .= ",\n"; };  
$comma = TRUE; $template .= "TARGET = \"".$_GET['ntarget']."\" "; }
          if (valid('nscript')) { if ($comma) { $template .= ",\n"; };  
$comma = TRUE; $template .= "SCRIPT = \"".$_GET['nscript']."\" "; }
-        if (valid('nmodel')) { if ($comma) { $template .= ",\n"; };  
$comma = TRUE; $template .= "MODEL = \"".$_GET['nmodel']."\" "; }
+        //if (valid('nmodel')) { if ($comma) { $template .= ",\n"; };  
$comma = TRUE; $template .= "MODEL = \"".$_GET['nmodel']."\" "; }
          $template .= "]\n";
+        $template .= "GRAPHICS = [ type = \"vnc\",listen  =  
\"0.0.0.0\"] ";
          $status = rpc2_request("one.vm.allocate",  
array($_SESSION['auth'], $template));
          if (isset($status['failed'])) {
-            print "<tr><td>Err: ".$status['failed']."</td><td></td></ 
tr>\n";
+            print "<tr><td>Err: ".$status['failed']." $template</ 
td><td></td></tr>\n";
          }
      }

@@ -344,9 +345,10 @@
              $vmpool_info = $vmpool_info['VM_POOL'];
          else
              $vmpool_info = array();
-
-        print "<tr><td>Id</td><td>User</td><td>Name</td><td>VM State</ 
td><td>LCM State</td><td>Cpu</td><td>Memory</td><td>Host</td><td>Time</ 
td><td></td><td></td></tr>\n";
+        print "<tr><td>Id</td><td>User</td><td>Name</td><td>VM State</ 
td><td>LCM State</td><td>Cpu</td><td>Memory</td><td>Host</td><td>Time</ 
td><td>VNC port</td><td></td><td></td></tr>\n";
          foreach ($vmpool_info as $vm) {
+	    $vnccommand = "sudo /usr/bin/virsh -c remote:///".$vm['HISTORY'] 
['HOSTNAME'] ." vncdisplay one-" . $vm['ID'];
+	    $vncport = `$vnccommand`;
              $_vm_state = $vm_state[$vm['STATE']];
              $_lcm_state = $lcm_state[$vm['LCM_STATE']];
              $time = $vm['ETIME'] - $vm['STIME'];
@@ -357,7 +359,7 @@
              $time = (int)$days."d ".(int)$hours.":".(int) 
$minutes.":".$seconds;
              print "<tr><td>".$vm['ID']."</td><td>". 
$vm['USERNAME']."</td><td>".$vm['NAME']."</td><td>".$_vm_state."</ 
td><td>"
                  .$_lcm_state."</td><td>".$vm['CPU']."</td><td>". 
$vm['MEMORY']."</td><td>".$vm['HISTORY']['HOSTNAME']."</td>"
-                ."<td>".$time."</td><td><a href=\"?details=". 
$vm['ID']."\">details</a> "
+                ."<td>".$time."</td><td>$vncport</td><td><a href=\"? 
details=".$vm['ID']."\">details</a> "
                  ."<a href=\"?log=".$vm['ID']."\">log</a></td>";
              print "<td><form method=\"GET\"><select name=\"action\">";
              if ($_vm_state == "pending") {

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20100225/c6011418/attachment-0002.htm>


More information about the Users mailing list