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

add flavor to project mapping #52

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions roles/os_flavors/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
OpenStack Flavors
=================

This role can be used to register flavors in Nova using the
`openstack.cloud.compute_flavor` module.
This role can be used to register flavors in Nova and map them to projects
using the `openstack.cloud.compute_flavor` module.

Requirements
------------
@@ -32,6 +32,16 @@ may contain 'ephemeral', 'flavorid', 'rxtx_factor' and 'swap' items.
Optionally, the dict may also contain an item 'extra_specs', which is a dict of
metadata to attach to the flavor object.

`is_public` default is `true`. It is a mandatory parameter when mapping flavor
to project, and it have to be set to `false` in that case. Non public
flavor can't be mapped. However there is possibility to create flavor which
is private and not mapped to any project. Only 'true' and 'false' are
allowed here.

`project` single value, or list of projects, to which flavor should be mapped.
In other words: this flavor will be visible and usable only in said project(s).


Dependencies
------------

@@ -63,6 +73,25 @@ The following playbook registers a Nova flavor.
hw:cpu_policy: "dedicated"
hw:numa_nodes: "1"

The following playbook will allow uasge of `flavor-1` only in project `projectA`.

---
- name: Map Nova flavors to projects
hosts: localhost
roles:
- role: openstack.cloud.compute_flavor_access
os_flavors_venv: "~/os-flavors-venv"
os_flavors_auth_type: "password"
os_flavors_auth:
project_name: <keystone project>
username: <keystone user>
password: <keystone password>
auth_url: <keystone auth URL>
os_flavors:
- name: flavor-1
is_public: false
project: "projectA"

Author Information
------------------

13 changes: 12 additions & 1 deletion roles/os_flavors/tasks/flavors.yml
Original file line number Diff line number Diff line change
@@ -12,8 +12,19 @@
ephemeral: "{{ item.ephemeral | default(omit) }}"
swap: "{{ item.swap | default(omit) }}"
rxtx_factor: "{{ item.rxtx_factor | default(omit) }}"
is_public: "{{ item.is_public | default(omit) }}"
is_public: "{{ item.is_public | default('true') }}"
flavorid: "{{ item.flavorid | default(omit) }}"
extra_specs: "{{ item.extra_specs | default(omit) }}"
GregWhiteyBialas marked this conversation as resolved.
Show resolved Hide resolved
state: "{{ item.state | default('present') }}"
with_items: "{{ os_flavors }}"

- name: Map nova flavors to projects
openstack.cloud.compute_flavor_access:
auth_type: "{{ os_flavors_auth_type }}"
auth: "{{ os_flavors_auth }}"
cacert: "{{ os_flavors_cacert | default(omit) }}"
interface: "{{ os_flavors_interface | default(omit, true) }}"
name: "{{ item.0.name }}"
state: "{{ item.0.state | default('present') }}"
project: "{{ item.1 | default(omit) }}"
loop: "{{ lookup('subelements', os_flavors, 'project', {'skip_missing': True}) }}"