VMware Cloud Community
APJ_vm
Enthusiast
Enthusiast

Issue Calling VCO workflow from Python script

Hi

I am trying to call a VCO workflow from a python script on a ESXi 6.0 host. Hopefully this is the most appropriate forum. The below script works if I run it from a python install on my laptop. The expected out put is meant to be a listing of the Configure Mail workflow.

#! /bin/python

import urllib2

import base64

import ssl

import xml

from urlparse import urlparse

vroServer = '192.168.199.6:8281'

print vroServer

theurl = 'https://' + vroServer + '/vco/api/workflows/?conditions=name=Configure%20mail'

print theurl

username = 'vcoadmin@vsphere.local'

password = 'vcoadmin'

context = ssl.CERT_NONE

ssl._create_default_https_context = ssl._create_unverified_context

req = urllib2.Request(theurl)

print req

base64string = base64.encodestring('%s:%s' % (username, password))[:-1]

authheader =  "Basic %s" % base64string

req.add_header('User-agent', 'Mozilla/5.0')

req.add_header('Content-Type','application/xml')

req.add_header('Accept','application/xml')

req.add_header('Authorization', authheader)

print req

handle = urllib2.urlopen(req)

thepage = handle.read()

print thepage

The output I get is below

Traceback (most recent call last):

  File "./VCOTest.py", line 28, in <module>

    handle = urllib2.urlopen(req)

  File "/build/mts/release/bora-3247720/bora/build/esx/release/vmvisor/sys-boot/lib/python2.7/urllib2.py", line 154, in urlopen

  File "/build/mts/release/bora-3247720/bora/build/esx/release/vmvisor/sys-boot/lib/python2.7/urllib2.py", line 431, in open

  File "/build/mts/release/bora-3247720/bora/build/esx/release/vmvisor/sys-boot/lib/python2.7/urllib2.py", line 449, in _open

  File "/build/mts/release/bora-3247720/bora/build/esx/release/vmvisor/sys-boot/lib/python2.7/urllib2.py", line 409, in _call_chain

  File "/build/mts/release/bora-3247720/bora/build/esx/release/vmvisor/sys-boot/lib/python2.7/urllib2.py", line 1240, in https_open

  File "/build/mts/release/bora-3247720/bora/build/esx/release/vmvisor/sys-boot/lib/python2.7/urllib2.py", line 1197, in do_open

urllib2.URLError: <urlopen error [Errno 110] Connection timed out>

Thanks .

Tags (3)
0 Kudos
3 Replies
iiliev
VMware Employee
VMware Employee

Looks like a network setup issue.

Check if there is a proxy/firewall installed. Also, verify that the network port is open.

BTW, the default username (assuming you haven't changed vCO authentication configuration) is just vcoadmin, not vcoadmin@vsphere.local.

APJ_vm
Enthusiast
Enthusiast

This is just a test lab so there is no firewall or proxy involved. The python script I am trying to use works from a windows machine just not from my ESXi host. And my python skills are limited at best so not sure how or where to start troubleshooting. Maybe a tcmdump might show more info

0 Kudos
APJ_vm
Enthusiast
Enthusiast

So I figured it out after you mentioned firewall. I completely forgot about the firewall on the ESXi host itself. I just had to create a custom firewall rule and then I was able to call my VCO workflow.

0 Kudos