def main():

    try:
        si = None
        try:
            print "Trying to connect to VCENTER SERVER . . ."
            si = connect.Connect(inputs['vcenter_ip'], 443, inputs['vcenter_user'], inputs['vcenter_password'], version="vim.version.version8")
        except __HOLE__, e:
            pass
            atexit.register(Disconnect, si)

        print "Connected to VCENTER SERVER !"

        content = si.RetrieveContent()

        host = get_obj(content, [vim.HostSystem], inputs['host_name'])

        host_network_system = host.configManager.networkSystem

#         for pnic in host.config.network.pnic:
#             if pnic.device == inputs['nic_name']:
#                 pnic_key = pnic.key

        create_vswitch(host_network_system, inputs['switch_name'], inputs['num_ports'], inputs['nic_name'])

        create_port_group(host_network_system, inputs['port_group_name'], inputs['switch_name'])

        #add_virtual_nic(host_network_system, inputs['port_group_name'])

    except vmodl.MethodFault, e:
        print "Caught vmodl fault: %s" % e.msg
        return 1
    except Exception, e:
        print "Caught exception: %s" % str(e)
        return 1

# Start program
dataset/ETHPy150Open rreubenur/vmware-pyvmomi-examples/create_vswitch_and_portgroup.py/main