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

Fixes #35284 - Added ability for os_nova_flavor to update existing fl… #37170

Merged
merged 1 commit into from Oct 14, 2018

Conversation

Projects
None yet
6 participants
@bingoarun
Contributor

bingoarun commented Mar 8, 2018

SUMMARY

Added ability for os_nova_flavor to update existing flavors.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

os_nova_flavor

ANSIBLE VERSION
ansible 2.4.3.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/arun/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.14 (default, Feb 17 2018, 10:42:17) [GCC 7.3.1 20180130 (Red Hat 7.3.1-2)]

ADDITIONAL INFORMATION
  • As discussed in this email thread , if the flavor requires update, the old flavor is deleted and new one is created.
  • Since the extra_specs needs to be handled differently (not as part of other flavor parameters, as it requires unset), I had to move old_extra_specs = flavor['extra_specs'] up before deleting the old flavor.
  • Checked the following conditions -
    • New flavor creation
    • New flavor creation with extra specs
    • Flavor update (No extra specs in new and old) => Only flavor changed
    • Flavor update (No extra specs in new, Few extra specs in old) => Flavor updated and All extra specs gets deleted
    • Flavor update (Few extra specs in new, No extra specs in old) => Flavor updated and All extra specs gets added
    • Flavor update (M+N extra specs in new, N extra specs in old) => Flavor updated and M extra specs got added => M+N extra specs remains
    • Flavor update (N extra specs in new, M+N exra specs in old) => Flavor updated and M extra specs got removed => N extra specs remains
    • Extra specs update (M+N required, M existing) => N extra specs is added => M+N extra specs remains
    • Extra specs update (M required, M+N existing) => N extra specs is unset => M extra specs remains
    • Extra specs update (No extra specs required (in playbook) , M existing) => All extra specs deleted
    • Extra specs update (M extra specs required , None existing ) => M extra specs added

Basically, the extra_specs in the playbook is applied. If no extra_specs in playbook then the existing extra_specs will be deleted.

Before change
(test) [arun@fedora flavor-test(keystone_admin)]$ nova flavor-list
+--------------------------------------+-----------------+-----------+------+-----------+------+-------+-------------+-----------+
| ID                                   | Name            | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+--------------------------------------+-----------------+-----------+------+-----------+------+-------+-------------+-----------+
| 1                                    | m1.tiny         | 512       | 1    | 0         |      | 1     | 1.0         | True      |
| 2                                    | m1.small        | 2048      | 20   | 0         |      | 1     | 1.0         | True      |
| 3                                    | m1.medium       | 4096      | 40   | 0         |      | 2     | 1.0         | True      |
| 4                                    | m1.large        | 8192      | 80   | 0         |      | 4     | 1.0         | True      |
| 5                                    | m1.xlarge       | 16384     | 160  | 0         |      | 8     | 1.0         | True      |
| bebd100a-2daa-4e08-a9a1-a50a7d3abaa1 | existing_flavor | 510       | 21   | 0         |      | 55    | 1.0         | True      |
+--------------------------------------+-----------------+-----------+------+-----------+------+-------+-------------+-----------+

(test) [arun@fedora flavor-test(keystone_admin)]$ cat test.yml 
---
- hosts: localhost
  connection: local
  tasks:
    - name: Update flavor
      os_nova_flavor:
       cloud: packstack
       name: existing_flavor
       vcpus: 2
       ram: 512
       disk: 20
       ephemeral: 0
       is_public: true
       state: present
       extra_specs:
           quota:disk_read_iops_sec=5000
           quota:write_bytes_sec=10240000


(test) [arun@fedora flavor-test(keystone_admin)]$ ansible-playbook test.yml  --connection=local -vv
ansible-playbook 2.6.0 (devel ff28429e2a) last updated 2018/03/07 18:05:40 (GMT +550)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/arun/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/arun/Projects/bingoarun/flavor-test/ansible/lib/ansible
  executable location = /home/arun/Projects/bingoarun/flavor-test/ansible/bin/ansible-playbook
  python version = 2.7.14 (default, Feb 17 2018, 10:42:17) [GCC 7.3.1 20180130 (Red Hat 7.3.1-2)]
Using /etc/ansible/ansible.cfg as config file
 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'


PLAYBOOK: test.yml *******************************************************************************************************************************************************************************************
1 plays in test.yml

PLAY [localhost] *********************************************************************************************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************************************************************************************************
task path: /home/arun/Projects/bingoarun/flavor-test/test.yml:2
ok: [localhost]
META: ran handlers

TASK [Update flavor] *****************************************************************************************************************************************************************************************
task path: /home/arun/Projects/bingoarun/flavor-test/test.yml:5
ok: [localhost] => {"changed": false, "flavor": {"OS-FLV-DISABLED:disabled": false, "OS-FLV-EXT-DATA:ephemeral": 0, "disk": 21, "ephemeral": 0, "extra_specs": {"quota:disk_read_iops_sec": "5000", "quota:write_bytes_sec": "10240000"}, "id": "bebd100a-2daa-4e08-a9a1-a50a7d3abaa1", "is_disabled": false, "is_public": true, "location": {"cloud": "packstack", "project": {"domain_id": null, "domain_name": "default", "id": "6ed3c427f9274406afd7a1c62e118497", "name": "admin"}, "region_name": "RegionOne", "zone": null}, "name": "existing_flavor", "os-flavor-access:is_public": true, "properties": {"OS-FLV-DISABLED:disabled": false, "OS-FLV-EXT-DATA:ephemeral": 0, "os-flavor-access:is_public": true}, "ram": 510, "rxtx_factor": 1.0, "swap": 0, "vcpus": 55}, "id": "bebd100a-2daa-4e08-a9a1-a50a7d3abaa1"}
META: ran handlers
META: ran handlers

PLAY RECAP ***************************************************************************************************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0   

(test) [arun@fedora flavor-test(keystone_admin)]$ 

Flavor changes are not getting applied

After change
(test) [arun@fedora flavor-test(keystone_admin)]$ ansible-playbook test.yml  --connection=local -vv
ansible-playbook 2.6.0 (devel ff28429e2a) last updated 2018/03/07 18:05:40 (GMT +550)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/arun/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/arun/Projects/bingoarun/flavor-test/ansible/lib/ansible
  executable location = /home/arun/Projects/bingoarun/flavor-test/ansible/bin/ansible-playbook
  python version = 2.7.14 (default, Feb 17 2018, 10:42:17) [GCC 7.3.1 20180130 (Red Hat 7.3.1-2)]
Using /etc/ansible/ansible.cfg as config file
 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'


PLAYBOOK: test.yml *******************************************************************************************************************************************************************************************
1 plays in test.yml

PLAY [localhost] *********************************************************************************************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************************************************************************************************
task path: /home/arun/Projects/bingoarun/flavor-test/test.yml:2
ok: [localhost]
META: ran handlers

TASK [Update flavor] *****************************************************************************************************************************************************************************************
task path: /home/arun/Projects/bingoarun/flavor-test/test.yml:5
changed: [localhost] => {"changed": true, "flavor": {"OS-FLV-DISABLED:disabled": false, "OS-FLV-EXT-DATA:ephemeral": 0, "disk": 20, "ephemeral": 0, "extra_specs": {}, "id": "1755bc60-cdad-4d70-abb2-5059f359f5b2", "is_disabled": false, "is_public": true, "location": {"cloud": "packstack", "project": {"domain_id": null, "domain_name": "default", "id": "6ed3c427f9274406afd7a1c62e118497", "name": "admin"}, "region_name": "RegionOne", "zone": null}, "name": "existing_flavor", "os-flavor-access:is_public": true, "properties": {"OS-FLV-DISABLED:disabled": false, "OS-FLV-EXT-DATA:ephemeral": 0, "os-flavor-access:is_public": true}, "ram": 512, "rxtx_factor": 1.0, "swap": 0, "vcpus": 2}, "id": "1755bc60-cdad-4d70-abb2-5059f359f5b2"}
META: ran handlers
META: ran handlers

PLAY RECAP ***************************************************************************************************************************************************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0   

(test) [arun@fedora flavor-test(keystone_admin)]$ nova flavor-show existing_flavor
+----------------------------+--------------------------------------+
| Property                   | Value                                |
+----------------------------+--------------------------------------+
| OS-FLV-DISABLED:disabled   | False                                |
| OS-FLV-EXT-DATA:ephemeral  | 0                                    |
| disk                       | 20                                   |
| extra_specs                | {}                                   |
| id                         | 1755bc60-cdad-4d70-abb2-5059f359f5b2 |
| name                       | existing_flavor                      |
| os-flavor-access:is_public | True                                 |
| ram                        | 512                                  |
| rxtx_factor                | 1.0                                  |
| swap                       |                                      |
| vcpus                      | 2                                    |
+----------------------------+--------------------------------------+
(test) [arun@fedora flavor-test(keystone_admin)]$ 

Flavor changes are applied

@ansibot

This comment has been minimized.

@ansibot

This comment has been minimized.

Contributor

ansibot commented Mar 8, 2018

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

lib/ansible/modules/cloud/openstack/os_nova_flavor.py:234:40: E231 missing whitespace after ','
lib/ansible/modules/cloud/openstack/os_nova_flavor.py:234:48: E231 missing whitespace after ','
lib/ansible/modules/cloud/openstack/os_nova_flavor.py:234:55: E231 missing whitespace after ','
lib/ansible/modules/cloud/openstack/os_nova_flavor.py:234:67: E231 missing whitespace after ','
lib/ansible/modules/cloud/openstack/os_nova_flavor.py:234:74: E231 missing whitespace after ','
lib/ansible/modules/cloud/openstack/os_nova_flavor.py:234:88: E231 missing whitespace after ','
lib/ansible/modules/cloud/openstack/os_nova_flavor.py:235:69: E203 whitespace before ':'

click here for bot help

@openstack-zuul

This comment has been minimized.

openstack-zuul bot commented Mar 8, 2018

Build succeeded (third-party-check pipeline).

@openstack-zuul

This comment has been minimized.

openstack-zuul bot commented Mar 8, 2018

Build succeeded (third-party-check pipeline).

@s-hertel s-hertel removed the needs_triage label Mar 9, 2018

@ansibot ansibot added the stale_ci label Mar 17, 2018

@ansibot ansibot removed the stale_ci label Mar 23, 2018

@ansibot ansibot added the stale_ci label Mar 31, 2018

@ansibot

This comment has been minimized.

Contributor

ansibot commented May 18, 2018

@ansibot ansibot added the affects_2.6 label May 18, 2018

@emonty

emonty approved these changes May 26, 2018

shipit

@emonty

This comment has been minimized.

Contributor

emonty commented Jun 4, 2018

recheck

2 similar comments
@emonty

This comment has been minimized.

Contributor

emonty commented Jun 4, 2018

recheck

@omgjlk

This comment has been minimized.

Member

omgjlk commented Jun 4, 2018

recheck

@ansibot

This comment has been minimized.

Contributor

ansibot commented Oct 10, 2018

@mnaser

This comment has been minimized.

Contributor

mnaser commented Oct 13, 2018

recheck

@mnaser

This comment has been minimized.

Contributor

mnaser commented Oct 13, 2018

recheck

@openstack-zuul

This comment has been minimized.

openstack-zuul bot commented Oct 13, 2018

Build succeeded (third-party-check pipeline).

@mnaser

This comment has been minimized.

Contributor

mnaser commented Oct 13, 2018

shipit

@ansibot ansibot merged commit 23b60d8 into ansible:devel Oct 14, 2018

2 checks passed

Shippable Run 88356 status is SUCCESS.
Details
openstack/third-party-check third-party-check status: success
Details

jsenecal added a commit to connectitnet/ansible that referenced this pull request Oct 19, 2018

kbreit added a commit to kbreit/ansible that referenced this pull request Nov 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment