diff --git a/salt/soc/dynamic_annotations/hypervisor/add_node b/salt/soc/dynamic_annotations/hypervisor/add_node new file mode 100644 index 000000000..498db1460 --- /dev/null +++ b/salt/soc/dynamic_annotations/hypervisor/add_node @@ -0,0 +1,11 @@ +hostname: +network_mode: +ip4: +gw4: +dns4: +sarch4: +cpu: +memory: +disk: +copper: +sfp: diff --git a/salt/soc/dynamic_annotations/hypervisor/hypervisor.yaml b/salt/soc/dynamic_annotations/hypervisor/hypervisor.yaml index f52779e9c..0ec53ff30 100644 --- a/salt/soc/dynamic_annotations/hypervisor/hypervisor.yaml +++ b/salt/soc/dynamic_annotations/hypervisor/hypervisor.yaml @@ -1,9 +1,14 @@ hypervisor: hosts: defaultHost: - add_guest: - description: Add a new guest to the hypervisor. - forcedType: "[]string" + add_searchnode: + description: Add a new searchnode to the hypervisor. + file: True + global: True + multiline: True + add_sensor: + description: Add a new sensor to the hypervisor. + file: True global: True multiline: True guests: diff --git a/salt/soc/dynamic_annotations/hypervisor/init.sls b/salt/soc/dynamic_annotations/hypervisor/init.sls index 74db9d9a2..8c857e72f 100644 --- a/salt/soc/dynamic_annotations/hypervisor/init.sls +++ b/salt/soc/dynamic_annotations/hypervisor/init.sls @@ -1,5 +1,28 @@ +{% from 'soc/dynamic_annotations/hypervisor/map.jinja' import HYPERVISORS %} + hypervisor_annotation: file.managed: - name: /opt/so/saltstack/default/salt/hypervisor/soc_hypervisor.yaml - source: salt://soc/dynamic_annotations/hypervisor/soc_hypervisor.yaml.jinja - template: jinja + - defaults: + HYPERVISORS: {{ HYPERVISORS }} + +{% for role in HYPERVISORS %} +{% for hypervisor in HYPERVISORS[role].keys() %} +hypervisor_host_directory_{{hypervisor}}: + file.directory: + - name: /opt/so/saltstack/local/salt/hypervisor/hosts/{{hypervisor}} + - makedirs: True + +add_searchnode_file_{{hypervisor}}: + file.managed: + - name: /opt/so/saltstack/local/salt/hypervisor/hosts/{{hypervisor}}/add_searchnode + - source: salt://soc/dynamic_annotations/hypervisor/add_node + +add_sensor_file_{{hypervisor}}: + file.managed: + - name: /opt/so/saltstack/local/salt/hypervisor/hosts/{{hypervisor}}/add_sensor + - source: salt://soc/dynamic_annotations/hypervisor/add_node +{% endfor %} +{% endfor %} diff --git a/salt/soc/dynamic_annotations/hypervisor/map.jinja b/salt/soc/dynamic_annotations/hypervisor/map.jinja new file mode 100644 index 000000000..b14a437b5 --- /dev/null +++ b/salt/soc/dynamic_annotations/hypervisor/map.jinja @@ -0,0 +1 @@ +{% set HYPERVISORS = salt['pillar.get']('hypervisor:nodes', {}) %} diff --git a/salt/soc/dynamic_annotations/hypervisor/soc_hypervisor.yaml.jinja b/salt/soc/dynamic_annotations/hypervisor/soc_hypervisor.yaml.jinja index f96b3ea13..c9dd8200d 100644 --- a/salt/soc/dynamic_annotations/hypervisor/soc_hypervisor.yaml.jinja +++ b/salt/soc/dynamic_annotations/hypervisor/soc_hypervisor.yaml.jinja @@ -1,12 +1,13 @@ {% import_yaml 'soc/dynamic_annotations/hypervisor/hypervisor.yaml' as ANNOTATION %} -{% set HYPERVISORS = salt['pillar.get']('hypervisor:nodes', {}) %} {% set TEMPLATE = ANNOTATION.hypervisor.hosts.pop('defaultHost') %} {# remove defaultGuest so that it is not shown in Grid Configuration UI #} {% do TEMPLATE['guests'].pop('defaultGuest') %} -{% for hypervisor in HYPERVISORS.hypervisor %} -{% do ANNOTATION.hypervisor.hosts.update({hypervisor: TEMPLATE}) %} +{% for role in HYPERVISORS %} +{% for hypervisor in HYPERVISORS[role].keys() %} +{% do ANNOTATION.hypervisor.hosts.update({hypervisor: TEMPLATE}) %} +{% endfor %} {% endfor %} {{ ANNOTATION | yaml(False) }}