Permalink
Browse files

Added implementation for listing the hard disks (Josh Wright, with so…

…me modifications).

git-svn-id: http://vboxweb.googlecode.com/svn/trunk@27 729376a8-6c6b-11de-afdd-bb9f892af8c1
  • Loading branch information...
1 parent 952de57 commit 019a712b3cd40ffc00eae5272412ef83e9babe38 vboxweb committed Aug 6, 2009
View
18 VBoxWebSrv.py
@@ -86,6 +86,20 @@ def __init__(self, ctx, guestOSType):
self.recommendedVRAM = guestOSType.recommendedVRAM
self.recommendedHDD = guestOSType.recommendedHDD
+class jsHardDiskAttachment:
+ def __init__(self, attachment):
+ self.hardDisk = jsHardDisk(attachment.hardDisk)
+ self.controller = attachment.controller
+ self.port = attachment.port
+ self.device = attachment.device
+
+class jsHardDisk:
+ def __init__(self, hardDisk):
+ self.id = hardDisk.id
+ self.name = hardDisk.name
+ self.type = hardDisk.type
+ self.logicalSize = hardDisk.logicalSize
+
class jsMachine:
def __init__(self, ctx, machine):
self.accessible = machine.accessible
@@ -104,6 +118,10 @@ def __init__(self, ctx, machine):
self.state = machine.state
self.sessState = machine.sessionState
+ self.hardDiskAttachments = []
+ for i in ctx['global'].getArray(machine, 'hardDiskAttachments'):
+ self.hardDiskAttachments.append(jsHardDiskAttachment(i))
+
maxBootPosition = ctx['vb'].systemProperties.maxBootPosition
for i in range(1, maxBootPosition + 1):
self.bootOrder.append(machine.getBootOrder(i))
View
64 www/static/js/main/vboxHardDiskAttachmentImpl.js
@@ -0,0 +1,64 @@
+
+/* Copyright (C) 2009 Sun Microsystems, Inc.
+
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+var vboxHardDiskAttachment = Class.create(
+{
+ initialize: function()
+ {
+ this.mHardDisk = new vboxHardDisk();
+ this.mPort = "";
+ this.mAddress = 0;
+ this.mAuthType = 0;
+ },
+
+ loadSettingsJSON: function(jsonObject)
+ {
+ this.mHardDisk.loadSettingsJSON(jsonObject.hardDisk)
+ this.mController = jsonObject.controller;
+ this.mPort = jsonObject.port;
+ this.mDevice = jsonObject.device;
+ },
+
+ /* Public attributes. */
+ getHardDisk: function()
+ {
+ return this.mHardDisk;
+ },
+
+ getController: function()
+ {
+ return this.mController;
+ },
+
+ getPort: function()
+ {
+ return this.mPort;
+ },
+
+ getDevice: function()
+ {
+ return this.mDevice;
+ }
+});
View
69 www/static/js/main/vboxHardDiskImpl.js
@@ -0,0 +1,69 @@
+
+/* Copyright (C) 2009 Sun Microsystems, Inc.
+
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+var vboxHardDisk = Class.create(
+{
+ initialize: function()
+ {
+ this.mId = ""
+ this.mName = "";
+ this.mType = -1;
+ this.mLogicalSize = 0;
+ },
+
+ loadSettingsJSON: function(jsonObject)
+ {
+ this.mId = jsonObject.id;
+ this.mName = jsonObject.name;
+ this.mType = jsonObject.type;
+ this.mLogicalSize = jsonObject.logicalSize;
+ },
+
+ /* Public attributes. */
+ getId: function()
+ {
+ return this.mId;
+ },
+
+ getName: function()
+ {
+ return this.mName;
+ },
+
+ getType: function()
+ {
+ return this.mType;
+ },
+
+ getLogicalSize: function()
+ {
+ return this.mLogicalSize;
+ },
+
+ getLogicalSizeGB: function()
+ {
+ return this.mLogicalSize / 1024;
+ }
+});
View
58 www/static/js/main/vboxMachineImpl.js
@@ -23,51 +23,6 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
-var vboxMachineVRDPServer = Class.create(
-{
- initialize: function()
- {
- this.mEnabled = false;
- this.mPort = 0;
- this.mAddress = "";
- this.mAuthType = "";
- },
-
- loadSettingsJSON: function(jsonObject, arrIndex)
- {
- this.mEnabled = jsonObject.enabled == "1" ? true : false;
- this.mPort = jsonObject.port;
- this.mAddress = jsonObject.netAddress;
- this.mAuthType = jsonObject.authType;
- },
-
- getEnabled: function()
- {
- return this.mEnabled;
- },
-
- getPort: function()
- {
- if ((this.mPort == "") || (this.mPort == "0"))
- return "3389";
- return this.mPort;
- },
-
- getNetAddress: function()
- {
- if (this.mAddress == "")
- return tr("127.0.0.1");
- return this.mAddress;
- },
-
- getAuthType: function()
- {
- if (this.mAuthType == "")
- return "0";
- return this.mAuthType;
- }
-});
-
var vboxMachineImpl = Class.create(
{
initialize: function()
@@ -87,6 +42,7 @@ var vboxMachineImpl = Class.create(
this.mVRDPServer = new vboxMachineVRDPServer();
this.mSessionState = -1;
this.mState = -1;
+ this.mHardDiskAttachments = [];
},
loadSettingsJSON: function(jsonObject)
@@ -106,6 +62,13 @@ var vboxMachineImpl = Class.create(
this.mVRDPServer.loadSettingsJSON(jsonObject.VRDPServer);
this.mState = jsonObject.state;
this.mSessionState = jsonObject.sessState;
+
+ for(i=0; i<jsonObject.hardDiskAttachments.length; i++)
+ {
+ attachment = new vboxHardDiskAttachment();
+ attachment.loadSettingsJSON(jsonObject.hardDiskAttachments[i]);
+ this.mHardDiskAttachments.push(attachment);
+ }
},
getBootOrder: function(position)
@@ -187,5 +150,10 @@ var vboxMachineImpl = Class.create(
getSessionState: function()
{
return this.mSessionState;
+ },
+
+ getHardDiskAttachments: function()
+ {
+ return this.mHardDiskAttachments;
}
});
View
69 www/static/js/main/vboxVRDPServerImpl.js
@@ -0,0 +1,69 @@
+
+/* Copyright (C) 2009 Sun Microsystems, Inc.
+
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+var vboxMachineVRDPServer = Class.create(
+{
+ initialize: function()
+ {
+ this.mEnabled = false;
+ this.mPort = 0;
+ this.mAddress = "";
+ this.mAuthType = "";
+ },
+
+ loadSettingsJSON: function(jsonObject, arrIndex)
+ {
+ this.mEnabled = jsonObject.enabled == "1" ? true : false;
+ this.mPort = jsonObject.port;
+ this.mAddress = jsonObject.netAddress;
+ this.mAuthType = jsonObject.authType;
+ },
+
+ getEnabled: function()
+ {
+ return this.mEnabled;
+ },
+
+ getPort: function()
+ {
+ if ((this.mPort == "") || (this.mPort == "0"))
+ return "3389";
+ return this.mPort;
+ },
+
+ getNetAddress: function()
+ {
+ if (this.mAddress == "")
+ return tr("127.0.0.1");
+ return this.mAddress;
+ },
+
+ getAuthType: function()
+ {
+ if (this.mAuthType == "")
+ return "0";
+ return this.mAuthType;
+ }
+});
View
26 www/static/js/vboxGlobal.js
@@ -271,4 +271,30 @@ var vboxGlobal = Class.create(
return strBasePath + strIcon;
},
+ hardDiskType: function (type)
+ {
+ var strType = 'Unkown'
+ switch (type)
+ {
+ case 0: strType = 'Normal'; break;
+ case 1: strType = 'Immutable'; break;
+ case 2: strType = 'Writethrough'; break;
+
+ default: break;
+ }
+ return strType;
+ },
+
+ vmGuestOSTypeDescription: function (osTypeId)
+ {
+ var strOS = osTypeId;
+ switch (osTypeId)
+ {
+ /** @todo translate ID name to something more beautiful. */
+
+ default:
+ break;
+ }
+ return strOS;
+ }
});
View
34 www/static/js/vboxTabWidget.js
@@ -130,7 +130,7 @@ var vboxTabWidget = Class.create(
strBootOrder = strBootOrder + ", " + vbGlobal.deviceType(bootOrder[i]);
}
}
-
+
jQuery("#tab-details-vm-general-name-val").text(curItem.name());
jQuery("#tab-details-vm-general-osname-val").text(curItem.machine().getOSTypeDescription());
@@ -143,6 +143,38 @@ var vboxTabWidget = Class.create(
jQuery("#tab-details-vm-display-videomem-val").text(curItem.machine().getVRAMSize() + tr(" MB"));
jQuery("#tab-details-vm-display-3daccel-val").text(curItem.machine().getAccelerate3DEnabled() ? tr("Enabled") : tr("Disabled"));
jQuery("#tab-details-vm-display-rdpport-val").text(curItem.machine().getVRDPServer().getPort());
+
+ jQuery("li.harddisks-list-item").remove();
+ var hardDiskAttachments = curItem.machine().getHardDiskAttachments();
+ for(i=0; i<hardDiskAttachments.length; i++)
+ {
+ attachment = hardDiskAttachments[i];
+ hardDisk = attachment.getHardDisk();
+ if (attachment.getController() === 'IDE')
+ {
+ port = (attachment.getPort() === 0) ? tr('Primary') : tr('Secondary');
+ device = (attachment.getDevice() === 0) ? tr('Master') : tr('Slave');
+ }
+ else if (attachment.getController() === 'SATA')
+ {
+ port = 'Port ' + attachment.getPort();
+ device = '';
+ }
+ else
+ {
+ port = attachment.getPort();
+ device = attachment.getDevice();
+ }
+ strHardDisk = hardDisk.getName() + ' (' + vbGlobal.hardDiskType(hardDisk.getType()) + ', ' + hardDisk.getLogicalSizeGB() + ' GB)';
+ strListItem = attachment.getController() + ' ' + port + ' ' + device + ' - ' + strHardDisk;
+ jQuery("#tab-details-vm-harddisks-list").append("<li class='harddisks-list-item'>" + strListItem + "</li>");
+ }
+
+ if (hardDiskAttachments.length <= 0)
+ {
+ jQuery("#tab-details-vm-harddisks-list").
+ append("<li class='harddisks-list-item'>" + tr("No hard disks attached") + "</li>");
+ }
},
invalidatePageRDP: function(curItem, pageSelected)
View
12 www/templates/index.html
@@ -65,8 +65,11 @@
<!-- Utility stuff. -->
<script type="text/javascript" src="/static/js/vboxHelper.js"></script>
<!-- Main-like classes. -->
+ <script type="text/javascript" src="/static/js/main/vboxHardDiskImpl.js"></script>
+ <script type="text/javascript" src="/static/js/main/vboxHardDiskAttachmentImpl.js"></script>
<script type="text/javascript" src="/static/js/main/vboxMachineImpl.js"></script>
<script type="text/javascript" src="/static/js/main/vboxVirtualBoxImpl.js"></script>
+ <script type="text/javascript" src="/static/js/main/vboxVRDPServerImpl.js"></script>
<!-- COM-like classes. -->
<script type="text/javascript" src="/static/js/vboxConfig.js"></script>
<script type="text/javascript" src="/static/js/vboxVirtualBox.js"></script>
@@ -277,6 +280,15 @@
<div id="tab-details-vm-display-3daccel">3D Acceleration: <span id="tab-details-vm-display-3daccel-val"/></div>
<div id="tab-details-vm-display-rdpport">Remote Display Server Port: <span id="tab-details-vm-display-rdpport-val"/></div>
</div>
+
+ <div class="tab-section" id="tab-details-sec-vm-harddisks">
+ <div id="tab-details-hdr-harddisks" class="tab-section-header">
+ <img class="tab-section-hdr-icon" alt="Hard Disks" src="/images/vbox/hd_16px.png"/>
+ <span class="tab-section-hdr-text">Hard Disks</span>
+ </div>
+ <ul id="tab-details-vm-harddisks-list"></ul>
+ </div>
+
</div>
</div>

0 comments on commit 019a712

Please sign in to comment.