Commit 332fe29a authored by Anael Beutot's avatar Anael Beutot
Browse files

Prevents name conflicts with VMs

parent 1120919e
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
"""KVM hypervisor support."""

import re
import logging
import weakref

@@ -14,6 +15,7 @@ from cloudcontrol.node.hypervisor.domains import VirtualMachine


logger = logging.getLogger(__name__)
BAD_VM_NAME = re.compile('^job-(0|([1-9]\d*))$')


# FIXME create abstract base class for any hypervisor
@@ -87,6 +89,11 @@ class KVM(object):
        event = EVENTS[event]

        if event == 'Added':
            # prevents name conflicts with others cc-node objects
            if BAD_VM_NAME.match(dom.name()):
                logger.error('Cannot register VM %s as its name would '
                             'conflits with others cc-node objects')
                return
            # update Storage pools in case VM has volumes that were created
            self.storage.update()
            if dom.name() in self.domains: