summaryrefslogtreecommitdiffstats
path: root/ci/config_tpl/maas_tpl/maas-nodes.yaml
blob: e32dd7ca89fce0b1e34800b6f8868ada7097e884 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{% for node in lab.racks[0].nodes %}
    - interfaces:
{% for nic in node.nics %}
      - mac_address: {{ nic.mac[0] }}
        mode: auto
        name: {{ nic.ifname }}
{% endfor %}
{% if node.architecture=='x86_64' %}
      architecture: amd64/generic
{% endif %}
      mac_addresses:
{% for nic in node.nics %}
      - {{ nic.mac[0] }}
{% endfor %}
      name: {{ node.name }}
      power:
{% if node.power.type=='ipmi' %}
        address: {{ node.power.address }}
        driver: LAN_2_0
        pass: {{ node.power.pass }}
        type: ipmi
        user: {{ node.power.user }}
{% elif node.power.type=='wakeonlan' %}
        type: ether_wake
        mac_address: {{ node.power.mac_address }}
{% endif %}
      tags: {{ ' '.join(node.roles) }}
{% endfor %}
span class="o">= os.path.dirname(os.path.abspath(__file__))+'/config_tpl/maas2/maas_tpl' HOME = os.environ['HOME'] USER = os.environ['USER'] # # Prepare variables # # Prepare a storage for passwords passwords_store = dict() # # Local Functions # def load_yaml(filepath): """Load YAML file""" with open(filepath, 'r') as stream: try: return yaml.load(stream) except yaml.YAMLError as exc: print(exc) def get_ip_address(ifname): """Get local IP""" s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) return socket.inet_ntoa(fcntl.ioctl( s.fileno(), 0x8915, # SIOCGIFADDR struct.pack('256s', bytes(ifname.encode('utf-8')[:15])) )[20:24]) # # Config import # def installMAAS(): subprocess.call(["echo", i], shell=True) def configMAAS(): # Create the jinja2 environment. env = Environment(loader=FileSystemLoader(TPL_DIR), trim_blocks=True) template = env.get_template('deployment.yaml') # Render the template output = template.render(**config) # Check output syntax try: yaml.load(output) except yaml.YAMLError as exc: print(exc) # print output print(output)