in api/plugins/registry.py [0:0]
def save(self):
""" Saves or updates a node in the registry """
nc = self.conn.cursor()
# Save a new node?
if not self.id:
self.fingerprint = plugins.crypto.fingerprint(self.pem)
print("Saving node with cert %s" % self.fingerprint)
nc.execute("INSERT INTO `registry` (`hostname`, `apikey`, `pubkey`, `verified`, `enabled`, `ip`, `lastping`, `version`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
(self.hostname, self.apikey, self.pem, 0, 0, self.ip, int(time.time()), self.version, )
)
# Save an existing node?
else:
nc.execute("UPDATE `registry` SET `hostname` = ?, `apikey` = ?, `pubkey` = ?, `location`= ?, `verified` = ?, `enabled` = ?, `ip` = ?, `lastping` = ?, `version` = ?, `description`= ? WHERE `id` = ? LIMIT 1",
(self.hostname, self.apikey, self.pem, self.location, 1 if self.verified else 0, 1 if self.enabled else 0, self.ip, self.lastping, self.version, self.description, self.id,)
)
self.conn.commit()