def call(self, auth, node_id_or_hostname):
# Get node information
- nodes = Nodes(self.api, [node_id_or_hostname]).values()
+ nodes = Nodes(self.api, [node_id_or_hostname])
if not nodes:
raise PLCInvalidArgument, "No such node"
node = nodes[0]
+ if node['peer_id'] is not None:
+ raise PLCInvalidArgument, "Not a local node"
+
# If we are not an admin, make sure that the caller is a
# member of the site at which the node is located.
if 'admin' not in self.caller['roles']:
# Get node networks for this node
primary = None
- nodenetworks = NodeNetworks(self.api, node['nodenetwork_ids']).values()
+ nodenetworks = NodeNetworks(self.api, node['nodenetwork_ids'])
for nodenetwork in nodenetworks:
if nodenetwork['is_primary']:
primary = nodenetwork
bytes = random.sample(xrange(0, 256), 32)
# Base64 encode their string representation
node['key'] = base64.b64encode("".join(map(chr, bytes)))
+ # XXX Boot Manager cannot handle = in the key
+ node['key'] = node['key'].replace("=", "")
# Save it
node.sync()
file += 'IP_NETADDR="%s"\n' % primary['network']
file += 'IP_BROADCASTADDR="%s"\n' % primary['broadcast']
file += 'IP_DNS1="%s"\n' % primary['dns1']
- file += 'IP_DNS2="%s"\n' % primary['dns2']
+ file += 'IP_DNS2="%s"\n' % (primary['dns2'] or "")
file += 'HOST_NAME="%s"\n' % host
file += 'DOMAIN_NAME="%s"\n' % domain