@@ -159,7 +159,7 @@ public void valueChanged(ListSelectionEvent arg0) {
159
159
return scroll ;
160
160
}
161
161
162
- private void showVmConsole (int firstIndex ) throws BadServerResponse , XenAPIException , XmlRpcException {
162
+ private void showVmConsole (int firstIndex ) throws BadServerResponse , XenAPIException , XmlRpcException , Exception {
163
163
164
164
// Get the console ID for the VM
165
165
VMEntry vm = (VMEntry ) model .getElementAt (firstIndex );
@@ -172,13 +172,26 @@ private void showVmConsole(int firstIndex) throws BadServerResponse, XenAPIExcep
172
172
173
173
System .out .println ("Session reference: " +conn .getSessionReference ());
174
174
String location = c .getLocation (conn );
175
- System .out .println ("Setting up terminal connection to " +location +" for VM " +vm );
176
-
177
- // location = server_url.getText()+"/"+location.substring(location.indexOf("console?"));
178
- // System.out.println("Setting up terminal connection to "+location+" for VM "+vm);
179
175
176
+ URL consoleURL = new URL (location );
177
+ URL connURL = new URL (server_url .getText ());
178
+ if ("" .equals (consoleURL .getHost ())) {
179
+ // If console URL is missing the host, HMN may be disabled.
180
+ // Use http and host from the original connection in this case
181
+ location = "http://" + connURL .getHost () + consoleURL .getFile ();
182
+ System .out .println ("HMN appears disabled. Fixing location to " + location );
183
+ consoleURL = new URL (location );
184
+ }
185
+ System .out .println ("Setting up terminal connection to " +location +" for VM " +vm );
186
+
187
+ String usessl = "false" ;
188
+ String port = "80" ;
189
+ if ("https" .equals (consoleURL .getProtocol ())) {
190
+ usessl = "true" ;
191
+ port = "443" ;
192
+ }
180
193
JavaInitialize ji = new JavaInitialize ();
181
- ji .init (new String [] {location , conn .getSessionReference (), "true" });
194
+ ji .init (new String [] {location , conn .getSessionReference (), usessl , port });
182
195
ji .start ();
183
196
ji .setSize (800 ,600 );
184
197
ji .setVisible (true );
0 commit comments