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

Adding reboot action for os_server_action module #62828

Closed
wants to merge 10 commits into from

Conversation

gabicrisan
Copy link

@gabicrisan gabicrisan commented Sep 25, 2019

SUMMARY

This enables the reboot action within the os_server_action module. Since there are two types of reboot actions currently supported by Openstack API, a new argument reboot_type has been added in order to be able to select between these two options. The action is defaulted to soft reboot.

Reboot states references: https://docs.openstack.org/api-ref/compute/?expanded=reboot-server-reboot-action-detail

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

reboot action for os_server_action module

ADDITIONAL INFORMATION
TASK [Reboot VM] *********************************************************************************************************************************************************************************************
task path: /ansible/playbooks/test_reboot.yml:50
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1569413986.96-138881467066555 `" && echo ansible-tmp-1569413986.96-138881467066555="` echo $HOME/.ansible/tmp/ansible-tmp-1569413986.96-138881467066555 `" ) && sleep 0'
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/basic.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/openstack.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/_text.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/parsing/convert_bool.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/parsing/__init__.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/pycompat24.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/six/__init__.py
Using module file /usr/lib/python2.7/site-packages/ansible/modules/cloud/openstack/os_server_action.py
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-569NxyXFX/tmpvjy2pC TO /root/.ansible/tmp/ansible-tmp-1569413986.96-138881467066555/os_server_action.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1569413986.96-138881467066555/ /root/.ansible/tmp/ansible-tmp-1569413986.96-138881467066555/os_server_action.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'OS_PROJECT_NAME=Redacted OS_USERNAME=Redacted OS_USER_DOMAIN_NAME=Redacted OS_AUTH_URL=Redacted OS_PASSWORD=Redacted OS_PROJECT_DOMAIN_NAME=Redacted /usr/bin/python2 /root/.ansible/tmp/ansible-tmp-1569413986.96-138881467066555/os_server_action.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1569413986.96-138881467066555/ > /dev/null 2>&1 && sleep 0'
changed: [test-vm.internal -> 127.0.0.1] => {
    "changed": true,
    "invocation": {
        "module_args": {
            "action": "reboot",
            "api_timeout": null,
            "auth": null,
            "auth_type": null,
            "availability_zone": null,
            "cacert": null,
            "cert": null,
            "image": null,
            "interface": "public",
            "key": null,
            "region_name": null,
            "server": "test-vm.internal",
            "timeout": 180,
            "verify": null,
            "wait": true
        }
    }
}

@ansibot
Copy link
Contributor

ansibot commented Sep 25, 2019

@ansibot ansibot added affects_2.10 This issue/PR affects Ansible v2.10 cloud community_review In order to be merged, this PR must follow the community review workflow. feature This issue/PR relates to a feature request. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. new_contributor This PR is the first contribution by a new community member. openstack support:community This issue/PR relates to code supported by the Ansible community. labels Sep 25, 2019
@ansibot
Copy link
Contributor

ansibot commented Sep 25, 2019

The test ansible-test sanity --test validate-modules [explain] failed with 3 errors:

lib/ansible/modules/cloud/openstack/os_server_action.py:0:0: python-syntax-error: Python SyntaxError while parsing module
test/sanity/ignore.txt:1650:1: A100: Ignoring 'doc-default-does-not-match-spec' on 'lib/ansible/modules/cloud/openstack/os_server_action.py' is unnecessary
test/sanity/ignore.txt:1651:1: A100: Ignoring 'doc-missing-type' on 'lib/ansible/modules/cloud/openstack/os_server_action.py' is unnecessary

The test ansible-test sanity --test pylint [explain] failed with 1 error:

lib/ansible/modules/cloud/openstack/os_server_action.py:249:0: syntax-error: unindent does not match any outer indentation level (&lt;unknown&gt;, line 249)

The test ansible-test sanity --test ansible-doc [explain] failed with the error:

Command "ansible-doc -t module os_server_action" returned exit status 1.
>>> Standard Error
ERROR! module os_server_action missing documentation (or could not parse documentation): unindent does not match any outer indentation level (<unknown>, line 249)

The test ansible-test sanity --test docs-build [explain] failed with the error:

Command "/usr/bin/python3.6 /root/ansible/test/sanity/code-smell/docs-build.py" returned exit status 1.
>>> Standard Error
Command 'make singlehtmldocs' failed with status code: 2
--> Standard Output
PYTHONPATH=../../lib ../../hacking/build-ansible.py collection-meta --template-file=../templates/collections_galaxy_meta.rst.j2 --output-dir=rst/dev_guide/ ../../lib/ansible/galaxy/data/collections_galaxy_meta.yml
PYTHONPATH=../../lib ../../hacking/build-ansible.py document-config --template-file=../templates/config.rst.j2 --output-dir=rst/reference_appendices/ ../../lib/ansible/config/base.yml
mkdir -p rst/cli
PYTHONPATH=../../lib ../../hacking/build-ansible.py generate-man --template-file=../templates/cli_rst.j2 --output-dir=rst/cli/ --output-format rst ../../lib/ansible/cli/*.py
PYTHONPATH=../../lib ../../hacking/build-ansible.py document-keywords --template-dir=../templates --output-dir=rst/reference_appendices/ ./keyword_desc.yml
PYTHONPATH=../../lib ../../hacking/build-ansible.py document-plugins -t rst --template-dir=../templates --module-dir=../../lib/ansible/modules -o rst/modules/ 
Evaluating module files...
Makefile:99: recipe for target 'modules' failed
--> Standard Error
Traceback (most recent call last):
  File "../../hacking/build-ansible.py", line 92, in <module>
    main()
  File "../../hacking/build-ansible.py", line 81, in main
    retval = command.main(args)
  File "/root/ansible/hacking/build_library/build_ansible/command_plugins/plugin_formatter.py", line 721, in main
    plugin_info, categories = get_plugin_info(args.module_dir, limit_to=args.limit_to, verbose=(args.verbosity > 0))
  File "/root/ansible/hacking/build_library/build_ansible/command_plugins/plugin_formatter.py", line 225, in get_plugin_info
    doc, examples, returndocs, metadata = plugin_docs.get_docstring(module_path, fragment_loader, verbose=verbose)
  File "/root/ansible/lib/ansible/utils/plugin_docs.py", line 124, in get_docstring
    data = read_docstring(filename, verbose=verbose, ignore_errors=ignore_errors)
  File "/root/ansible/lib/ansible/parsing/plugin_docs.py", line 40, in read_docstring
    M = ast.parse(b_module_data.read())
  File "/usr/lib/python3.6/ast.py", line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 249
    elif action == 'reboot':
                           ^
IndentationError: unindent does not match any outer indentation level
make: *** [modules] Error 1

The test ansible-test sanity --test package-data [explain] failed with the error:

Command "/usr/bin/python3.6 /root/ansible/test/sanity/code-smell/package-data.py" returned exit status 1.
>>> Standard Error
Traceback (most recent call last):
  File "/root/ansible/test/sanity/code-smell/package-data.py", line 383, in <module>
    main()
  File "/root/ansible/test/sanity/code-smell/package-data.py", line 360, in main
    sdist_path = create_sdist(tmp_dir)
  File "/root/ansible/test/sanity/code-smell/package-data.py", line 174, in create_sdist
    raise Exception('make snapshot failed:\n%s' % stderr)
Exception: make snapshot failed:
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
docs/man/man1/ansible-galaxy.1.rst:51: (WARNING/2) Definition list ends without a blank line; unexpected unindent.
docs/man/man1/ansible-galaxy.1.rst:57: (WARNING/2) Definition list ends without a blank line; unexpected unindent.
ERROR! module os_server_action at /tmp/tmp_o4b_ebq/lib/ansible/modules/cloud/openstack/os_server_action.py has a documentation error formatting or is missing documentation.
Traceback (most recent call last):
  File "packaging/release/changelogs/changelog.py", line 835, in <module>
    main()
  File "packaging/release/changelogs/changelog.py", line 102, in main
    args.func(args)
  File "packaging/release/changelogs/changelog.py", line 132, in command_release
    plugins = load_plugins(version=version, force_reload=reload_plugins)
  File "packaging/release/changelogs/changelog.py", line 184, in load_plugins
    '--json', '--metadata-dump', '-t', plugin_type])
  File "/usr/lib/python3.6/subprocess.py", line 356, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/tmp/tmp_o4b_ebq/bin/ansible-doc', '--json', '--metadata-dump', '-t', 'module']' returned non-zero exit status 1.
make: *** [changelog] Error 1

The test ansible-test sanity --test compile --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/cloud/openstack/os_server_action.py:249:34: SyntaxError: elif action == 'reboot':

The test ansible-test sanity --test compile --python 2.7 [explain] failed with 1 error:

lib/ansible/modules/cloud/openstack/os_server_action.py:249:34: SyntaxError: elif action == 'reboot':

The test ansible-test sanity --test compile --python 3.5 [explain] failed with 1 error:

lib/ansible/modules/cloud/openstack/os_server_action.py:249:34: SyntaxError: elif action == 'reboot':

The test ansible-test sanity --test compile --python 3.6 [explain] failed with 1 error:

lib/ansible/modules/cloud/openstack/os_server_action.py:249:34: SyntaxError: elif action == 'reboot':

The test ansible-test sanity --test compile --python 3.8 [explain] failed with 1 error:

lib/ansible/modules/cloud/openstack/os_server_action.py:249:34: SyntaxError: elif action == 'reboot':

The test ansible-test sanity --test compile --python 3.7 [explain] failed with 1 error:

lib/ansible/modules/cloud/openstack/os_server_action.py:249:34: SyntaxError: elif action == 'reboot':

The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/cloud/openstack/os_server_action.py:249:34: IndentationError: unindent does not match any outer indentation level

The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:

lib/ansible/modules/cloud/openstack/os_server_action.py:249:34: IndentationError: unindent does not match any outer indentation level

The test ansible-test sanity --test import --python 3.5 [explain] failed with 1 error:

lib/ansible/modules/cloud/openstack/os_server_action.py:249:34: IndentationError: unindent does not match any outer indentation level

The test ansible-test sanity --test import --python 3.6 [explain] failed with 1 error:

lib/ansible/modules/cloud/openstack/os_server_action.py:249:34: IndentationError: unindent does not match any outer indentation level

The test ansible-test sanity --test import --python 3.7 [explain] failed with 1 error:

lib/ansible/modules/cloud/openstack/os_server_action.py:249:34: IndentationError: unindent does not match any outer indentation level

The test ansible-test sanity --test import --python 3.8 [explain] failed with 1 error:

lib/ansible/modules/cloud/openstack/os_server_action.py:249:34: IndentationError: unindent does not match any outer indentation level

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

lib/ansible/modules/cloud/openstack/os_server_action.py:119:1: E302: expected 2 blank lines, found 1
lib/ansible/modules/cloud/openstack/os_server_action.py:249:10: E901: IndentationError: unindent does not match any outer indentation level

The test ansible-test sanity --test yamllint [explain] failed with 1 error:

lib/ansible/modules/cloud/openstack/os_server_action.py:249:34: python-syntax-error: unindent does not match any outer indentation level (<unknown>, line 249)

click here for bot help

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Sep 25, 2019
@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Sep 25, 2019
@ansibot ansibot removed needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Sep 25, 2019
@opendev-zuul
Copy link

opendev-zuul bot commented Sep 25, 2019

Build succeeded (third-party-check pipeline).

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Oct 3, 2019
Copy link
Contributor

@piroux piroux left a comment

Choose a reason for hiding this comment

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

There's also a soft reboot option but that works only when a VM is in an ACTIVE state and that case can be easily covered by the generic reboot module.

Actually a VM might be purposefully unreachable from the controller network, but still manageable from Openstack, so the use-case for soft rebooting is still valid, according to me.

For instance, a module argument like reboot_type could be offered and set to SOFT by default. In that case, the VM state should be ACTIVE beforehand.


cloud.compute.post(
_action_url(server.id),
json={'reboot': {'type': 'HARD'}})
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really want a default and only "hard" reboot ?

Copy link
Author

Choose a reason for hiding this comment

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

That's right. Added soft reboot as default and new argument reboot_type.

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Nov 8, 2019
Copy link
Contributor

@cloudnull cloudnull left a comment

Choose a reason for hiding this comment

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

shipit

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Jan 3, 2020
@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. stale_review Updates were made after the last review and the last review is more than 7 days old. labels Jan 4, 2020
@sshnaidm
Copy link
Contributor

Thanks for submitting patch for Openstack Ansible modules!
We moved Openstack Ansible modules to Openstack repositories.
Next patches should be submitted not with Ansible Github but with
Openstack Gerrit: https://review.opendev.org/#/q/project:openstack/ansible-collections-openstack
Please submit your code there from now.
Thanks for your contribution and sorry for inconvienience.

Copy link
Contributor

@sshnaidm sshnaidm left a comment

Choose a reason for hiding this comment

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

Because we moved Openstack Ansible modules to Openstack repositories, please submit all changes from openstack modules to Openstack Gerrit: https://review.opendev.org/#/q/project:openstack/ansible-collections-openstack Thanks for your contribution and sorry for inconvienience.

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Jan 21, 2020
@jamescassell
Copy link
Contributor

@sshnaidm does that require a CLA? I know openstacksdk requires a CLA to send fixes, so I'm carrying local patches since I can't get the CLA signed. To date, I've been able to send fixes to the openstack ansible modules since no CLA is required for ansible contributions.

@sshnaidm
Copy link
Contributor

@jamescassell yes, you are right, all Openstack contributions require License Agreement to be signed.
Please take a look: https://docs.openstack.org/contributors/common/accounts.html

@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Mar 8, 2020
@ansibot ansibot added needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. new_module This PR includes a new module. new_plugin This PR includes a new plugin. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Mar 24, 2020
@ansibot ansibot removed the new_module This PR includes a new module. label Apr 1, 2020
@ansibot ansibot added collection Related to Ansible Collections work collection:openstack.cloud needs_collection_redirect https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md labels Apr 29, 2020
@ansibot ansibot removed collection:openstack.cloud needs_collection_redirect https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md labels Jul 14, 2020
@Akasurde
Copy link
Member

@gabicrisan Thanks for the contribution. Closing as per above.

@Akasurde Akasurde closed this Aug 19, 2020
@ansible ansible locked as resolved and limited conversation to collaborators Aug 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.10 This issue/PR affects Ansible v2.10 cloud collection Related to Ansible Collections work feature This issue/PR relates to a feature request. module This issue/PR relates to a module. needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. new_contributor This PR is the first contribution by a new community member. new_plugin This PR includes a new plugin. openstack stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants