Get the vsphere object associated with a given text name
    Source: https://github.com/rreubenur/vmware-pyvmomi-examples/blob/master/create_template.py

def get_object_by_name(content, object_type, name, regex=False):
    '''
    Get the vsphere object associated with a given text name
    Source: https://github.com/rreubenur/vmware-pyvmomi-examples/blob/master/create_template.py
    '''
    container = content.viewManager.CreateContainerView(
        content.rootFolder, [object_type], True
    )
    for c in container.view:
        if regex:
            if re.match(name, c.name):
                return c
        elif c.name == name:
            return c