Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/196'
Browse files Browse the repository at this point in the history
* origin/pr/196:
  Added an Advanced tab to Create New Qube dialog
  • Loading branch information
marmarek committed Sep 23, 2019
2 parents b0d5263 + d85940c commit 0dc73fd
Show file tree
Hide file tree
Showing 2 changed files with 264 additions and 128 deletions.
51 changes: 43 additions & 8 deletions qubesmanager/create_new_vm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
#
# The Qubes OS Project, http://www.qubes-os.org
#
Expand Down Expand Up @@ -37,14 +37,16 @@

# pylint: disable=too-few-public-methods
class CreateVMThread(QtCore.QThread):
def __init__(self, app, vmclass, name, label, template, properties):
def __init__(self, app, vmclass, name, label, template, properties,
pool):
QtCore.QThread.__init__(self)
self.app = app
self.vmclass = vmclass
self.name = name
self.label = label
self.template = template
self.properties = properties
self.pool = pool
self.msg = None

def run(self):
Expand All @@ -54,15 +56,29 @@ def run(self):
src_vm = self.app.default_template
else:
src_vm = self.template
vm = self.app.clone_vm(src_vm, self.name, self.vmclass,
ignore_volumes=['private'])

args = {
'ignore_volumes': ['private']
}
if self.pool:
args['pool'] = self.pool

vm = self.app.clone_vm(src_vm, self.name, self.vmclass, **args)

vm.label = self.label
for k, v in self.properties.items():
setattr(vm, k, v)
else:
vm = self.app.add_new_vm(
self.vmclass, name=self.name,
label=self.label, template=self.template)
args = {
"name": self.name,
"label": self.label,
"template": self.template
}
if self.pool:
args['pool'] = self.pool

vm = self.app.add_new_vm(self.vmclass, **args)

for k, v in self.properties.items():
setattr(vm, k, v)

Expand Down Expand Up @@ -107,6 +123,16 @@ def __init__(self, qtapp, app, parent=None):
(lambda vm: vm.provides_network),
allow_internal=False, allow_default=True, allow_none=True)

self.pool_list, self.pool_idx = utils.prepare_choice(
widget=self.storage_pool,
holder=None,
propname=None,
choice=self.app.pools.values(),
default=self.app.default_pool,
allow_default=True,
allow_none=False
)

self.name.setValidator(QtGui.QRegExpValidator(
QtCore.QRegExp("[a-zA-Z0-9_-]*", QtCore.Qt.CaseInsensitive), None))
self.name.selectAll()
Expand Down Expand Up @@ -163,8 +189,17 @@ def accept(self):
properties['virt_mode'] = 'hvm'
properties['kernel'] = None

if self.pool_list[self.storage_pool.currentIndex()] is not \
qubesadmin.DEFAULT:
pool = self.pool_list[self.storage_pool.currentIndex()]
else:
pool = None

if self.init_ram.value() > 0:
properties['memory'] = self.init_ram.value()

self.thread = CreateVMThread(
self.app, vmclass, name, label, template, properties)
self.app, vmclass, name, label, template, properties, pool)
self.thread.finished.connect(self.create_finished)
self.thread.start()

Expand Down
Loading

0 comments on commit 0dc73fd

Please sign in to comment.