- suffix=".txt"
- type = ["txt"]
-
- if type != "txt":
- if 'serial' in options:
- suffix = "-serial" + suffix
- type.insert(1, "serial")
- if 'cramfs' in options:
- suffix = "-cramfs" + suffix
- # XXX must be the same index as above
- type.insert(1, "cramfs")
- type = "_".join(type)
-
- ### compute a 8 bytes random number
- tempbytes = random.sample (xrange(0,256), 8);
- def hexa2 (c):
- return chr((c>>4)+65) + chr ((c&16)+65)
- temp = "".join(map(hexa2,tempbytes))
-
- ### check node if needed
+ # create a dict for build.sh
+ build_sh_spec={'kargs':[]}
+ # use node tags as defaults
+ # check for node tag equivalents
+ tags = NodeTags(self.api,
+ {'node_id': node['node_id'],
+ 'tagname': ['serial', 'cramfs', 'kvariant', 'kargs',
+ 'no-hangcheck', 'systemd-debug' ]},
+ ['tagname', 'value'])
+ if tags:
+ for tag in tags:
+ if tag['tagname'] == 'serial':
+ build_sh_spec['serial'] = tag['value']
+ elif tag['tagname'] == 'cramfs':
+ build_sh_spec['cramfs'] = True
+ elif tag['tagname'] == 'kvariant':
+ build_sh_spec['variant'] = tag['value']
+ elif tag['tagname'] == 'kargs':
+ build_sh_spec['kargs'] += tag['value'].split()
+ elif tag['tagname'] == 'no-hangcheck':
+ build_sh_spec['kargs'].append('hcheck_reboot0')
+ elif tag['tagname'] == 'systemd-debug':
+ build_sh_spec['kargs'].append('systemd.log_level=debug')
+ build_sh_spec['kargs'].append('systemd.log_target=console')
+ # then options can override tags
+ for option in options:
+ if option == "cramfs":
+ build_sh_spec['cramfs']=True
+ elif option == 'partition':
+ if type != "usb":
+ raise PLCInvalidArgument("option 'partition' is for USB images only")
+ else:
+ type="usb_partition"
+ elif option == "serial":
+ build_sh_spec['serial']='default'
+ elif option.find("serial:") == 0:
+ build_sh_spec['serial']=option.replace("serial:","")
+ elif option.find("variant:") == 0:
+ build_sh_spec['variant']=option.replace("variant:","")
+ elif option == "no-hangcheck":
+ build_sh_spec['kargs'].append('hcheck_reboot0')
+ elif option == "systemd-debug":
+ build_sh_spec['kargs'].append('systemd.log_level=debug')
+ else:
+ raise PLCInvalidArgument("unknown option {}".format(option))
+
+ # compute nodename according the action