qubes/vm: remove duplicated check for duplicate name on rename
This commit is contained in:
parent
73d61bb378
commit
5b4e30524a
@ -523,9 +523,13 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
|
||||
@qubes.events.handler('property-pre-set:name')
|
||||
def on_property_pre_set_name(self, event, name, newvalue, oldvalue=None):
|
||||
# pylint: disable=unused-argument
|
||||
if newvalue in [d.name for d in self.app.domains.values()]:
|
||||
try:
|
||||
self.app.domains[newvalue]
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
raise qubes.exc.QubesValueError(
|
||||
"A domain with name %s already exists", newvalue)
|
||||
'VM named {!r} already exists'.format(newvalue))
|
||||
|
||||
# TODO not self.is_stopped() would be more appropriate
|
||||
if self.is_running():
|
||||
@ -536,14 +540,6 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
|
||||
subprocess.check_call(['sudo', 'systemctl', '-q', 'disable',
|
||||
'qubes-vm@{}.service'.format(oldvalue)])
|
||||
|
||||
try:
|
||||
self.app.domains[newvalue]
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
raise qubes.exc.QubesValueError(
|
||||
'VM named {!r} already exists'.format(newvalue))
|
||||
|
||||
@qubes.events.handler('property-set:name')
|
||||
def on_property_set_name(self, event, name, new_name, old_name=None):
|
||||
# pylint: disable=unused-argument
|
||||
|
Loading…
Reference in New Issue
Block a user