Skip to content

Commit

Permalink
Merge pull request #847 from nuagenetworks/vmware_autostart_fix
Browse files Browse the repository at this point in the history
Vmware autostart fix and vcin assertion
  • Loading branch information
mpiecuch-nuage authored Oct 1, 2018
2 parents 2aae154 + 1e8e807 commit 0255044
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 18 deletions.
5 changes: 5 additions & 0 deletions Documentation/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Metro Automation Engine Release Notes
## Release 2.4.6
### Resolved Issues
* Update vmware_autostart for vCenter 6.5+
* Assert when VCIN is older than 5.2.2 on install

## Release 2.4.5
### Resolved Issues
* Set validate_certs to no for VMware playbooks
Expand Down
25 changes: 15 additions & 10 deletions library/vmware_autostart.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys
from pyVmomi import vim
from pyVim.connect import SmartConnect
from pyVim.connect import SmartConnectNoSSL
sys.dont_write_bytecode = True


Expand Down Expand Up @@ -55,7 +56,7 @@
description:
- Whether Ansible should validate ssh certificates
required: False
default: yes
default: True
'''

Expand All @@ -68,7 +69,7 @@
username: vCenter_username
password: vCenter_password
state: enable
validate_certs: no
validate_certs: False
# Example for disabling or not enabling autostart for vm_1
- vmware_autostart:
Expand All @@ -81,9 +82,9 @@
'''


def get_esxi_host(ip_addr, port, username, password, id):
def get_esxi_host(ip_addr, port, username, password, id, validate_certs):
uuid = id
si = get_connection(ip_addr, username, password, port)
si = get_connection(ip_addr, username, password, port, validate_certs)
vm = si.content.searchIndex.FindByUuid(None,
uuid,
True,
Expand All @@ -96,10 +97,13 @@ def get_esxi_host(ip_addr, port, username, password, id):
return None


def get_connection(ip_addr, user, password, port):
connection = SmartConnect(
host=ip_addr, port=port, user=user, pwd=password
)
def get_connection(ip_addr, user, password, port, validate_certs):
if validate_certs:
connection = SmartConnect(
host=ip_addr, port=port, user=user, pwd=password)
else:
connection = SmartConnectNoSSL(
host=ip_addr, port=port, user=user, pwd=password)
return connection


Expand Down Expand Up @@ -178,14 +182,15 @@ def main():
uuid = module.params['uuid']
port = module.params['port']
start_delay = module.params['delay']
validate_certs = module.params['validate_certs']

try:
connection = get_connection(ip_addr, username, password, port)
connection = get_connection(ip_addr, username, password, port, validate_certs)

if connection is None:
module.fail_json(msg="Establishing connection to %s failed" % ip_addr)

esxi_host = get_esxi_host(ip_addr, port, username, password, uuid)
esxi_host = get_esxi_host(ip_addr, port, username, password, uuid, validate_certs)

if esxi_host is None:
module.fail_json(msg="Could not find ESXi host using uuid %s" % uuid)
Expand Down
2 changes: 1 addition & 1 deletion roles/vsc-destroy/tasks/vcenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
username: "{{ vcenter.username }}"
password: "{{ vcenter.password }}"
state: disable
validate_certs: no
validate_certs: False

- name: Power off the VSC VM
connection: local
Expand Down
2 changes: 1 addition & 1 deletion roles/vsc-predeploy/tasks/vcenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
username: "{{ vcenter.username }}"
password: "{{ vcenter.password }}"
state: enable
validate_certs: no
validate_certs: False

- name: Verify VM is running
assert:
Expand Down
5 changes: 5 additions & 0 deletions roles/vsd-deploy/tasks/non_heat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
(vsd_major_version|int >= 5 and vsd_minor_version|int > 2) or
(vsd_major_version|int >= 5 and vsd_minor_version|int >= 2 and vsd_patch_version|int >= 2)

- name: Assert that vcin_mode is not true if version less than 5.2.2
assert:
that: deploy_vcin or not (vcin_mode|default(False))
msg: "MetroAE does not support the installation of VCIN for versions less than 5.2.2."

- block:

- name: Set VSD numbering for install
Expand Down
9 changes: 7 additions & 2 deletions roles/vsd-deploy/tasks/nuagex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
(vsd_major_version|int >= 5 and vsd_minor_version|int > 2) or
(vsd_major_version|int >= 5 and vsd_minor_version|int >= 2 and vsd_patch_version|int >= 2)

- name: Assert that vcin_mode is not true if version less than 5.2.2
assert:
that: deploy_vcin or not (vcin_mode|default(False))
msg: "MetroAE does not support the installation of VCIN for versions less than 5.2.2. Quitting."

- block:
- name: Set VSD numbering for install
set_fact:
Expand Down Expand Up @@ -182,7 +187,7 @@
command: /opt/vsd/vsd-install.sh -t v -y
when: deploy_vcin

when:
when:
- vsd_sa_or_ha | match ('sa')
- master_vcin is not defined

Expand Down Expand Up @@ -213,7 +218,7 @@
- name: Start the replication
command: "/opt/vsd/bin/vsd-start-replication-slave -m {{ master_vcin }}"

when:
when:
- vsd_sa_or_ha | match ('sa')
- deploy_vcin
- master_vcin is defined
Expand Down
2 changes: 1 addition & 1 deletion roles/vsd-destroy/tasks/vcenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
username: "{{ vcenter.username }}"
password: "{{ vcenter.password }}"
state: disable
validate_certs: no
validate_certs: False

- name: Power off the vsd VM
connection: local
Expand Down
2 changes: 1 addition & 1 deletion roles/vsd-predeploy/tasks/vcenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
username: "{{ vcenter.username }}"
password: "{{ vcenter.password }}"
state: enable
validate_certs: no
validate_certs: False

- name: Disabling cloud-init
connection: local
Expand Down
2 changes: 1 addition & 1 deletion roles/vstat-destroy/tasks/vcenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
username: "{{ vcenter.username }}"
password: "{{ vcenter.password }}"
state: disable
validate_certs: no
validate_certs: False

- name: Power off the Stats VM
connection: local
Expand Down
2 changes: 1 addition & 1 deletion roles/vstat-predeploy/tasks/vcenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
username: "{{ vcenter.username }}"
password: "{{ vcenter.password }}"
state: enable
validate_certs: no
validate_certs: False

- name: Writing eth0 network script file to the VM
connection: local
Expand Down

0 comments on commit 0255044

Please sign in to comment.