Beispiel #1
0
def main():
    argument_spec = VmwareRestClient.vmware_client_argument_spec()
    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=True)

    vmware_tag_facts = VmTagFactManager(module)
    vmware_tag_facts.get_all_tags()
def main():
    argument_spec = VmwareRestClient.vmware_client_argument_spec()
    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=True)

    vmware_tag_facts = VmTagFactManager(module)
    vmware_tag_facts.get_all_tags()
Beispiel #3
0
def main():
    argument_spec = VmwareRestClient.vmware_client_argument_spec()
    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=True)

    vmware_category_facts = VmwareCategoryFactsManager(module)
    vmware_category_facts.get_all_tag_categories()
Beispiel #4
0
def main():
    argument_spec = VmwareRestClient.vmware_client_argument_spec()
    argument_spec.update(
        ovf_template=dict(type='str',
                          aliases=['template_src', 'ovf'],
                          required=True),
        name=dict(type='str', required=True, aliases=['vm_name']),
        datacenter=dict(type='str', required=True),
        datastore=dict(type='str', required=True),
        folder=dict(type='str', required=True),
        host=dict(type='str', required=True),
        resource_pool=dict(type='str', required=False),
        cluster=dict(type='str', required=False),
    )
    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=True)
    result = {'failed': False, 'changed': False}
    pyv = PyVmomi(module=module)
    vm = pyv.get_vm()
    if vm:
        module.exit_json(changed=False,
                         vm_deploy_info=dict(
                             msg="Virtual Machine '%s' already Exists." %
                             module.params['name'],
                             vm_id=vm._moId,
                         ))
    vmware_contentlib_create = VmwareContentDeployOvfTemplate(module)
    if module.check_mode:
        result.update(
            vm_name=module.params['name'],
            changed=True,
            desired_operation='Create VM with PowerOff State',
        )
        module.exit_json(**result)
    vmware_contentlib_create.deploy_vm_from_ovf_template()
Beispiel #5
0
def main():
    result = dict(changed=False)
    argument_spec = VmwareRestClient.vmware_client_argument_spec()
    argument_spec.update(name=dict(type="str"))

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=True)

    try:
        obj = VmwareRestClient(module)
        vm_svc = vcenter_client.VM(obj.connect)
    except Exception as e:
        module.fail_json(msg=str(e))

    vm_name = module.params["name"]
    if (vm_name):
        names = set([vm_name])
        vm = vm_svc.list(vcenter_client.VM.FilterSpec(names=names))
        r = list(map(lambda x: x.to_dict(), vm))
        if (len(r) > 0):
            result["virtual_machines"] = vm_svc.get(r[0]["vm"]).to_dict()
            module.exit_json(**result)
        else:
            module.fail_json(msg="%s not found." % vm_name)
    else:
        vms = vm_svc.list()
        r = list(map(lambda x: x.to_dict(), vms))

        r_array = []
        for vm in r:
            r_array.append(vm_svc.get(vm["vm"]).to_dict())

        result["virtual_machines"] = r_array
        module.exit_json(**result)
def main():
    argument_spec = VmwareRestClient.vmware_client_argument_spec()
    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=True)
    if module._name == 'vmware_tag_facts':
        module.deprecate("The 'vmware_tag_facts' module has been renamed to 'vmware_tag_info'", version='2.13')

    vmware_tag_info = VmTagInfoManager(module)
    vmware_tag_info.get_all_tags()
def main():
    argument_spec = VmwareRestClient.vmware_client_argument_spec()
    argument_spec.update(
        datacenter_name=dict(type='str', required=True),
    )

    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=False)
    dc_status = VmDCManager(module)
    dc_status.ensure_state()
Beispiel #8
0
def main():
    argument_spec = VmwareRestClient.vmware_client_argument_spec()
    argument_spec.update(
        tag_name=dict(type='str', required=True),
        tag_description=dict(type='str', default='', required=False),
        category_id=dict(type='str', required=False),
        state=dict(type='str', choices=['present', 'absent'], default='present', required=False),
    )
    module = AnsibleModule(argument_spec=argument_spec)

    vmware_tag = VmwareTag(module)
    vmware_tag.ensure_state()
def main():
    argument_spec = VmwareRestClient.vmware_client_argument_spec()
    argument_spec.update(library_id=dict(type='str', required=False), )
    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=True)

    vmware_contentlib_info = VmwareContentLibInfo(module)
    if module.params.get('library_id'):
        vmware_contentlib_info.get_content_lib_details(
            module.params['library_id'])
    else:
        vmware_contentlib_info.get_all_content_libs()
Beispiel #10
0
def main():
    argument_spec = VmwareRestClient.vmware_client_argument_spec()
    argument_spec.update(
        tag_name=dict(type='str', required=True),
        tag_description=dict(type='str', default='', required=False),
        category_id=dict(type='str', required=False),
        state=dict(type='str', choices=['present', 'absent'], default='present', required=False),
    )
    module = AnsibleModule(argument_spec=argument_spec)

    vmware_tag = VmwareTag(module)
    vmware_tag.ensure_state()
def main():
    argument_spec = VmwareRestClient.vmware_client_argument_spec()
    argument_spec.update(
        tag_names=dict(type='list', required=True),
        state=dict(type='str', choices=['absent', 'add', 'present', 'remove', 'set'], default='add'),
        object_name=dict(type='str', required=True),
        object_type=dict(type='str', required=True, choices=['VirtualMachine', 'Datacenter', 'ClusterComputeResource',
                                                             'HostSystem', 'DistributedVirtualSwitch',
                                                             'DistributedVirtualPortgroup']),
    )
    module = AnsibleModule(argument_spec=argument_spec)

    vmware_tag_manager = VmwareTagManager(module)
    vmware_tag_manager.ensure_state()
Beispiel #12
0
def main():
    argument_spec = VmwareRestClient.vmware_client_argument_spec()
    argument_spec.update(
        tag_names=dict(type='list', required=True),
        state=dict(type='str',
                   choices=['absent', 'add', 'present', 'remove', 'set'],
                   default='add'),
        object_name=dict(type='str', required=True),
        object_type=dict(type='str', required=True,
                         choices=['VirtualMachine']),
    )
    module = AnsibleModule(argument_spec=argument_spec)

    vmware_tag_manager = VmwareTagManager(module)
    vmware_tag_manager.ensure_state()
Beispiel #13
0
def main():
    argument_spec = VmwareRestClient.vmware_client_argument_spec()
    argument_spec.update(
        vm=dict(type='str', required=True),
        uuid=dict(type='str', required=True),
        tags=dict(type='dict', required=True),
        category_ids=dict(type='dict', required=True),
    )
    module = AnsibleModule(argument_spec=argument_spec)
    pyv = PyVmomi(module)
    vm = pyv.get_vm()
    vmware_tag = VmwareTag(module)
    result = vmware_tag.apply_tags(vm._moId, module.params['category_ids'],
                                   module.params['tags'])
    module.exit_json()
Beispiel #14
0
def main():
    argument_spec = VmwareRestClient.vmware_client_argument_spec()
    argument_spec.update(
        category_name=dict(type='str', required=True),
        category_description=dict(type='str', default='', required=False),
        category_cardinality=dict(type='str',
                                  choices=["multiple", "single"],
                                  default="multiple"),
        new_category_name=dict(type='str'),
        state=dict(type='str',
                   choices=['present', 'absent'],
                   default='present'),
    )
    module = AnsibleModule(argument_spec=argument_spec)

    vmware_category = VmwareCategory(module)
    vmware_category.ensure_state()
def main():
    argument_spec = VmwareRestClient.vmware_client_argument_spec()
    argument_spec.update(
        object_name=dict(),
        object_moid=dict(),
        new_name=dict(aliases=['object_new_name'], required=True),
        object_type=dict(type='str', required=True),
    )
    module = AnsibleModule(
        argument_spec=argument_spec,
        mutually_exclusive=[
            ['object_name', 'object_moid'],
        ]
    )

    vmware_object_rename = VmwareObjectRename(module)
    vmware_object_rename.ensure_state()
def main():
    argument_spec = VmwareRestClient.vmware_client_argument_spec()
    argument_spec.update(
        library_name=dict(type='str', required=False),
        library_description=dict(type='str', required=False),
        library_type=dict(type='str',
                          required=False,
                          choices=['local', 'subscribed'],
                          default='local'),
        datastore_name=dict(type='str', required=False, aliases=['datastore']),
        state=dict(type='str',
                   choices=['present', 'absent'],
                   default='present',
                   required=False),
    )
    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=True)

    vmware_contentlib_create = VmwareContentLibCreate(module)
    vmware_contentlib_create.process_state()
Beispiel #17
0
def main():
    argument_spec = VmwareRestClient.vmware_client_argument_spec()
    argument_spec.update(
        category_name=dict(type='str', required=True),
        category_description=dict(type='str', default='', required=False),
        category_cardinality=dict(type='str',
                                  choices=["multiple", "single"],
                                  default="multiple"),
        new_category_name=dict(type='str'),
        state=dict(type='str',
                   choices=['present', 'absent'],
                   default='present'),
        associable_object_types=dict(
            type='list',
            choices=[
                'All objects',
                'Folder',
                'Cluster',
                'Datacenter',
                'Datastore',
                'Datastore Cluster',
                'Distributed Port Group',
                'Distributed Switch',
                'Host',
                'Content Library',
                'Library item',
                'Network',
                'Resource Pool',
                'vApp',
                'Virtual Machine',
            ],
            elements=str,
        ),
    )
    module = AnsibleModule(argument_spec=argument_spec)

    vmware_category = VmwareCategory(module)
    vmware_category.ensure_state()