Skip to content

Commit

Permalink
Issue #8: Initial commit of the VirtualMachineHardwareWidget class
Browse files Browse the repository at this point in the history
  • Loading branch information
dnaeon committed Apr 15, 2015
1 parent eb3f566 commit dce1fb1
Showing 1 changed file with 52 additions and 2 deletions.
54 changes: 52 additions & 2 deletions src/pvc/widget/virtualmachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
'VirtualMachinePowerWidget',
'VirtualMachineExportWidget',
'CreateVirtualMachineWidget',
'VirtualMachineHardwareWidget',
]


Expand Down Expand Up @@ -101,8 +102,10 @@ def display(self):
on_select_args=(self.agent, self.dialog, self.obj)
),
pvc.widget.menu.MenuItem(
tag='Configuration',
description='Virtual Machine settings'
tag='Hardware',
description='Manage virtual hardware',
on_select=VirtualMachineHardwareWidget,
on_select_args=(self.agent, self.dialog, self.obj)
),
pvc.widget.menu.MenuItem(
tag='Datastore',
Expand Down Expand Up @@ -1273,3 +1276,50 @@ def get_vm_specs(self):
return

return fields


class VirtualMachineHardwareWidget(object):
def __init__(self, agent, dialog, obj):
"""
Widget for managing hardware on a Virtual Machine
Args:
agent (VConnector): A VConnector instance
dialog (dialog.Dialog): A Dialog instance
obj (vim.VirtualMachine): A VirtualMachine managed entity
"""
self.agent = agent
self.dialog = dialog
self.obj = obj
self.title = '{} ({})'.format(self.obj.name, self.obj.__class__.__name__)
self.display()

def display(self):
items = [
pvc.widget.menu.MenuItem(
tag='Add',
description='Add virtual hardware',
),
pvc.widget.menu.MenuItem(
tag='Remove',
description='Remove virtual hardware'
),
pvc.widget.menu.MenuItem(
tag='Change',
description='Change virtual hardware'
),
pvc.widget.menu.MenuItem(
tag='View',
description='View virtual hardware',
),
]

menu = pvc.widget.menu.Menu(
items=items,
dialog=self.dialog,
title=self.title,
text='Select an action to be performed'
)

menu.display()

0 comments on commit dce1fb1

Please sign in to comment.