Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VMware: Add new module: vmware_host_service_manager #34862

Merged
merged 1 commit into from
Jan 16, 2018

Conversation

Akasurde
Copy link
Member

SUMMARY

Signed-off-by: Abhijeet Kasurde akasurde@redhat.com

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

lib/ansible/modules/cloud/vmware/vmware_host_service_manager.py
test/integration/targets/vmware_host_service_manager/aliases
test/integration/targets/vmware_host_service_manager/tasks/main.yml

ANSIBLE VERSION
2.5devel

@ansibot
Copy link
Contributor

ansibot commented Jan 15, 2018

@Akasurde @bedecarroll @chrrrles @dav1x @garbled1 @jcpowermac @jjahns @kamsz @mtnbikenc @nafpliot-ibm @nerzhul @pdellaert @rhoop @ritzk @tchernomax @woshihaoren

As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add shipit if you would like to see it merged.

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Jan 15, 2018

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 cloud community_review In order to be merged, this PR must follow the community review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. new_module This PR includes a new module. new_plugin This PR includes a new plugin. support:community This issue/PR relates to code supported by the Ansible community. test This PR relates to tests. vmware VMware community labels Jan 15, 2018
@Akasurde Akasurde removed the needs_triage Needs a first human triage before being processed. label Jan 15, 2018
Copy link
Contributor

@pdellaert pdellaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition, just some remarks/potential improvements

- ESXi hostname.
- Service settings are applied to this ESXi host system.
- If C(cluster_name) is not given, this parameter is required.
state:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a state to enable/disable the service on host boot?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good idea.

Copy link
Contributor

@tchernomax tchernomax Jan 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's now handle by the "service_policy" option.

changed = True
self.module.exit_json(changed=changed, results=self.results)

def check_service_state(self, host, service_name):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be replaced with:

def check_service_state(self, host, service_name):
    host_service_system = host.configManager.serviceSystem
    if host_service_system:
        services = host_service_system.serviceInfo.service
        for service in services:
            if service.key == service_name:
                return service.running

    msg = "Failed to find '%s' service on host system '%s'" % (service_name, host.name)
    cluster_name = self.params.get('cluster_name', None)
    if cluster_name:
        msg += " located on cluster '%s'" % cluster_name
    msg += ", please check if you have specified a valid ESXi service name."
    self.module.fail_json(msg=msg)

This way it stops looping through services as soon as it finds the correct one, and if it finds none, it fails

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

actual_service_state = self.check_service_state(host=host, service_name=self.service_name)
host_service_system = host.configManager.serviceSystem
if host_service_system:
service_state = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally i'd like it better if this was changed_state, for instance, as that better indicates the purpose of this variable, looking at the code

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Copy link
Contributor

@tchernomax tchernomax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ansibot ansibot added shipit This PR is ready to be merged by Core and removed community_review In order to be merged, this PR must follow the community review workflow. labels Jan 15, 2018
Copy link
Contributor

@pdellaert pdellaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
shipit

@Akasurde Akasurde merged commit eca3fcd into ansible:devel Jan 16, 2018
@Akasurde Akasurde deleted the vmware_host_service_manager branch January 16, 2018 04:21
@Akasurde
Copy link
Member Author

@tchernomax @pdellaert Thanks for your valuable comments and reviews.

@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 cloud module This issue/PR relates to a module. new_module This PR includes a new module. new_plugin This PR includes a new plugin. shipit This PR is ready to be merged by Core support:community This issue/PR relates to code supported by the Ansible community. test This PR relates to tests. vmware VMware community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants