Allow labels for NetVM/ProxyVM. Require it in qvm-create.
This commit is contained in:
parent
588f4b91c8
commit
993d34e7d5
@ -1098,6 +1098,7 @@ class QubesNetVm(QubesCowVm):
|
|||||||
updateable=str(self.updateable),
|
updateable=str(self.updateable),
|
||||||
private_img=self.private_img,
|
private_img=self.private_img,
|
||||||
installed_by_rpm=str(self.installed_by_rpm),
|
installed_by_rpm=str(self.installed_by_rpm),
|
||||||
|
label=self.label.name,
|
||||||
)
|
)
|
||||||
return element
|
return element
|
||||||
|
|
||||||
@ -1242,6 +1243,7 @@ class QubesProxyVm(QubesNetVm):
|
|||||||
netvm_qid=str(self.netvm_vm.qid) if self.netvm_vm is not None else "none",
|
netvm_qid=str(self.netvm_vm.qid) if self.netvm_vm is not None else "none",
|
||||||
private_img=self.private_img,
|
private_img=self.private_img,
|
||||||
installed_by_rpm=str(self.installed_by_rpm),
|
installed_by_rpm=str(self.installed_by_rpm),
|
||||||
|
label=self.label.name,
|
||||||
)
|
)
|
||||||
return element
|
return element
|
||||||
|
|
||||||
@ -1593,12 +1595,13 @@ class QubesVmCollection(dict):
|
|||||||
|
|
||||||
def add_new_netvm(self, name, template_vm,
|
def add_new_netvm(self, name, template_vm,
|
||||||
dir_path = None, conf_file = None,
|
dir_path = None, conf_file = None,
|
||||||
private_img = None):
|
private_img = None,
|
||||||
|
label = None):
|
||||||
|
|
||||||
qid = self.get_new_unused_qid()
|
qid = self.get_new_unused_qid()
|
||||||
netid = self.get_new_unused_netid()
|
netid = self.get_new_unused_netid()
|
||||||
vm = QubesNetVm (qid=qid, name=name, template_vm=template_vm,
|
vm = QubesNetVm (qid=qid, name=name, template_vm=template_vm,
|
||||||
netid=netid,
|
netid=netid, label=label,
|
||||||
private_img=private_img,
|
private_img=private_img,
|
||||||
dir_path=dir_path, conf_file=conf_file)
|
dir_path=dir_path, conf_file=conf_file)
|
||||||
|
|
||||||
@ -1613,12 +1616,13 @@ class QubesVmCollection(dict):
|
|||||||
|
|
||||||
def add_new_proxyvm(self, name, template_vm,
|
def add_new_proxyvm(self, name, template_vm,
|
||||||
dir_path = None, conf_file = None,
|
dir_path = None, conf_file = None,
|
||||||
private_img = None):
|
private_img = None,
|
||||||
|
label = None):
|
||||||
|
|
||||||
qid = self.get_new_unused_qid()
|
qid = self.get_new_unused_qid()
|
||||||
netid = self.get_new_unused_netid()
|
netid = self.get_new_unused_netid()
|
||||||
vm = QubesProxyVm (qid=qid, name=name, template_vm=template_vm,
|
vm = QubesProxyVm (qid=qid, name=name, template_vm=template_vm,
|
||||||
netid=netid,
|
netid=netid, label=label,
|
||||||
private_img=private_img,
|
private_img=private_img,
|
||||||
dir_path=dir_path, conf_file=conf_file,
|
dir_path=dir_path, conf_file=conf_file,
|
||||||
netvm_vm = self.get_default_fw_netvm_vm())
|
netvm_vm = self.get_default_fw_netvm_vm())
|
||||||
@ -1836,7 +1840,7 @@ class QubesVmCollection(dict):
|
|||||||
try:
|
try:
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
attr_list = ("qid", "netid", "name", "dir_path", "conf_file",
|
attr_list = ("qid", "netid", "name", "dir_path", "conf_file",
|
||||||
"private_img", "template_qid", "updateable",
|
"private_img", "template_qid", "updateable", "label",
|
||||||
)
|
)
|
||||||
|
|
||||||
for attribute in attr_list:
|
for attribute in attr_list:
|
||||||
@ -1855,6 +1859,13 @@ class QubesVmCollection(dict):
|
|||||||
kwargs["template_vm"] = template_vm
|
kwargs["template_vm"] = template_vm
|
||||||
kwargs["netid"] = int(kwargs["netid"])
|
kwargs["netid"] = int(kwargs["netid"])
|
||||||
|
|
||||||
|
if kwargs["label"] is not None:
|
||||||
|
if kwargs["label"] not in QubesVmLabels:
|
||||||
|
print "ERROR: incorrect label for VM '{0}'".format(kwargs["name"])
|
||||||
|
kwargs.pop ("label")
|
||||||
|
else:
|
||||||
|
kwargs["label"] = QubesVmLabels[kwargs["label"]]
|
||||||
|
|
||||||
vm = QubesNetVm(**kwargs)
|
vm = QubesNetVm(**kwargs)
|
||||||
self[vm.qid] = vm
|
self[vm.qid] = vm
|
||||||
|
|
||||||
@ -1869,7 +1880,7 @@ class QubesVmCollection(dict):
|
|||||||
try:
|
try:
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
attr_list = ("qid", "netid", "name", "dir_path", "conf_file", "updateable",
|
attr_list = ("qid", "netid", "name", "dir_path", "conf_file", "updateable",
|
||||||
"private_img", "template_qid")
|
"private_img", "template_qid", "label")
|
||||||
|
|
||||||
for attribute in attr_list:
|
for attribute in attr_list:
|
||||||
kwargs[attribute] = element.get(attribute)
|
kwargs[attribute] = element.get(attribute)
|
||||||
@ -1887,6 +1898,13 @@ class QubesVmCollection(dict):
|
|||||||
kwargs["template_vm"] = template_vm
|
kwargs["template_vm"] = template_vm
|
||||||
kwargs["netid"] = int(kwargs["netid"])
|
kwargs["netid"] = int(kwargs["netid"])
|
||||||
|
|
||||||
|
if kwargs["label"] is not None:
|
||||||
|
if kwargs["label"] not in QubesVmLabels:
|
||||||
|
print "ERROR: incorrect label for VM '{0}'".format(kwargs["name"])
|
||||||
|
kwargs.pop ("label")
|
||||||
|
else:
|
||||||
|
kwargs["label"] = QubesVmLabels[kwargs["label"]]
|
||||||
|
|
||||||
vm = QubesProxyVm(**kwargs)
|
vm = QubesProxyVm(**kwargs)
|
||||||
self[vm.qid] = vm
|
self[vm.qid] = vm
|
||||||
|
|
||||||
|
@ -67,8 +67,6 @@ def main():
|
|||||||
if options.netvm and options.proxyvm:
|
if options.netvm and options.proxyvm:
|
||||||
parser.error ("You must specify at most one of --proxy and --net")
|
parser.error ("You must specify at most one of --proxy and --net")
|
||||||
|
|
||||||
label = None
|
|
||||||
if not options.proxyvm and not options.netvm:
|
|
||||||
if options.label is None:
|
if options.label is None:
|
||||||
print "You must choose a label for the new VM by passing the --label option."
|
print "You must choose a label for the new VM by passing the --label option."
|
||||||
print "Possible values are:"
|
print "Possible values are:"
|
||||||
@ -113,7 +111,7 @@ def main():
|
|||||||
|
|
||||||
vm = None
|
vm = None
|
||||||
if options.netvm:
|
if options.netvm:
|
||||||
vm = qvm_collection.add_new_netvm(vmname, template_vm)
|
vm = qvm_collection.add_new_netvm(vmname, template_vm, label = label)
|
||||||
|
|
||||||
net_devices = find_net_devices()
|
net_devices = find_net_devices()
|
||||||
print "Found the following net devices in your system:"
|
print "Found the following net devices in your system:"
|
||||||
@ -126,7 +124,7 @@ def main():
|
|||||||
vm.pcidevs = dev_str
|
vm.pcidevs = dev_str
|
||||||
|
|
||||||
elif options.proxyvm:
|
elif options.proxyvm:
|
||||||
vm = qvm_collection.add_new_proxyvm(vmname, template_vm)
|
vm = qvm_collection.add_new_proxyvm(vmname, template_vm, label = label)
|
||||||
else:
|
else:
|
||||||
vm = qvm_collection.add_new_appvm(vmname, template_vm, label = label)
|
vm = qvm_collection.add_new_appvm(vmname, template_vm, label = label)
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user