From c71756ab46cd29391fcfea608df09029f216aedd Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Thu, 28 Jan 2016 11:59:04 -0700 Subject: [PATCH] Disable VNC by default --- salt/modules/virt.py | 9 ++++++++- salt/runners/virt.py | 4 +++- salt/templates/virt/libvirt_domain.jinja | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/salt/modules/virt.py b/salt/modules/virt.py index 025bd7e9cb..8a08c1b4a7 100644 --- a/salt/modules/virt.py +++ b/salt/modules/virt.py @@ -251,6 +251,11 @@ def _gen_xml(name, # TODO: make bus and model parameterized, this works for 64-bit Linux context['controller_model'] = 'lsilogic' + if kwargs.get('enable_vnc', True): + context['enable_vnc'] = True + else: + context['enable_vnc'] = False + if 'boot_dev' in kwargs: context['boot_dev'] = [] for dev in kwargs['boot_dev'].split(): @@ -556,6 +561,7 @@ def init(name, pub_key=None, priv_key=None, seed_cmd='seed.apply', + enable_vnc=False, **kwargs): ''' Initialize a new vm @@ -651,6 +657,7 @@ def init(name, define_vol_xml_str(xml) log.debug('Generating VM XML') + kwargs['enable_vnc'] = enable_vnc xml = _gen_xml(name, cpu, mem, diskp, nicp, hypervisor, **kwargs) try: define_xml_str(xml) @@ -901,7 +908,7 @@ def get_graphics(vm_): 'keymap': 'None', 'listen': 'None', 'port': 'None', - 'type': 'vnc'} + 'type': 'None'} xml = get_xml(vm_) ssock = _StringIO(xml) doc = minidom.parse(ssock) diff --git a/salt/runners/virt.py b/salt/runners/virt.py index 768427a841..49dcf78dbd 100644 --- a/salt/runners/virt.py +++ b/salt/runners/virt.py @@ -213,7 +213,8 @@ def init( install=True, start=True, disk='default', - saltenv='base'): + saltenv='base', + enable_vnc=False): ''' This routine is used to create a new virtual machine. This routines takes a number of options to determine what the newly created virtual machine @@ -322,6 +323,7 @@ def init( install, pub_key, priv_key, + enable_vnc, ], timeout=600) except SaltClientError as client_error: diff --git a/salt/templates/virt/libvirt_domain.jinja b/salt/templates/virt/libvirt_domain.jinja index ea37bde218..c545528dbe 100644 --- a/salt/templates/virt/libvirt_domain.jinja +++ b/salt/templates/virt/libvirt_domain.jinja @@ -33,9 +33,9 @@ {% endfor %} - + {% if enable_vnc %} - + {% endif %} {% if serial_type == 'pty' %}