def properties_facts(self):
        ansible_facts = self.to_json(self.host, self.params.get('properties'))
        if self.params.get('show_tag'):
            vmware_client = VmwareRestClient(self.module)
            tag_info = {
                'tags':
                vmware_client.get_tags_for_hostsystem(
                    hostsystem_mid=self.host._moId)
            }
            ansible_facts.update(tag_info)

        self.module.exit_json(changed=False, ansible_facts=ansible_facts)
def main():
    argument_spec = VmwareRestClient.vmware_client_argument_spec()
    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=True)

    vmware_category_info = VmwareCategoryInfoManager(module)
    vmware_category_info.get_all_tag_categories()
    def all_facts(self):
        ansible_facts = {}
        ansible_facts.update(self.get_cpu_facts())
        ansible_facts.update(self.get_memory_facts())
        ansible_facts.update(self.get_datastore_facts())
        ansible_facts.update(self.get_network_facts())
        ansible_facts.update(self.get_system_facts())
        ansible_facts.update(self.get_vsan_facts())
        ansible_facts.update(self.get_cluster_facts())
        if self.params.get('show_tag'):
            vmware_client = VmwareRestClient(self.module)
            tag_info = {
                'tags':
                vmware_client.get_tags_for_hostsystem(
                    hostsystem_mid=self.host._moId)
            }
            ansible_facts.update(tag_info)

        self.module.exit_json(changed=False, ansible_facts=ansible_facts)
Exemplo n.º 4
0
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(
        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()
Exemplo n.º 6
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()
Exemplo n.º 8
0
    def gather_cluster_info(self):
        """
        Gather information about cluster
        """
        results = dict(changed=False, clusters=dict())
        for cluster in self.cluster_objs:
            # Default values
            ha_failover_level = None
            ha_restart_priority = None
            ha_vm_tools_monitoring = None
            ha_vm_min_up_time = None
            ha_vm_max_failures = None
            ha_vm_max_failure_window = None
            ha_vm_failure_interval = None
            enabled_vsan = False
            vsan_auto_claim_storage = False
            hosts = []

            # Hosts
            for host in cluster.host:
                hosts.append({
                    'name': host.name,
                    'folder': self.get_vm_path(self.content, host),
                })

            # HA
            das_config = cluster.configurationEx.dasConfig
            if das_config.admissionControlPolicy:
                ha_failover_level = das_config.admissionControlPolicy.failoverLevel
            if das_config.defaultVmSettings:
                ha_restart_priority = das_config.defaultVmSettings.restartPriority,
                ha_vm_tools_monitoring = das_config.defaultVmSettings.vmToolsMonitoringSettings.vmMonitoring,
                ha_vm_min_up_time = das_config.defaultVmSettings.vmToolsMonitoringSettings.minUpTime,
                ha_vm_max_failures = das_config.defaultVmSettings.vmToolsMonitoringSettings.maxFailures,
                ha_vm_max_failure_window = das_config.defaultVmSettings.vmToolsMonitoringSettings.maxFailureWindow,
                ha_vm_failure_interval = das_config.defaultVmSettings.vmToolsMonitoringSettings.failureInterval,

            # DRS
            drs_config = cluster.configurationEx.drsConfig

            # VSAN
            if hasattr(cluster.configurationEx, 'vsanConfig'):
                vsan_config = cluster.configurationEx.vsanConfig
                enabled_vsan = vsan_config.enabled,
                vsan_auto_claim_storage = vsan_config.defaultConfig.autoClaimStorage,

            tag_info = []
            if self.params.get('show_tag'):
                vmware_client = VmwareRestClient(self.module)
                tag_info = vmware_client.get_tags_for_cluster(
                    cluster_mid=cluster._moId)

            results['clusters'][cluster.name] = dict(
                hosts=hosts,
                enable_ha=das_config.enabled,
                ha_failover_level=ha_failover_level,
                ha_vm_monitoring=das_config.vmMonitoring,
                ha_host_monitoring=das_config.hostMonitoring,
                ha_admission_control_enabled=das_config.
                admissionControlEnabled,
                ha_restart_priority=ha_restart_priority,
                ha_vm_tools_monitoring=ha_vm_tools_monitoring,
                ha_vm_min_up_time=ha_vm_min_up_time,
                ha_vm_max_failures=ha_vm_max_failures,
                ha_vm_max_failure_window=ha_vm_max_failure_window,
                ha_vm_failure_interval=ha_vm_failure_interval,
                enabled_drs=drs_config.enabled,
                drs_enable_vm_behavior_overrides=drs_config.
                enableVmBehaviorOverrides,
                drs_default_vm_behavior=drs_config.defaultVmBehavior,
                drs_vmotion_rate=drs_config.vmotionRate,
                enabled_vsan=enabled_vsan,
                vsan_auto_claim_storage=vsan_auto_claim_storage,
                tags=tag_info,
            )

        self.module.exit_json(**results)