From 47db27e55e2b98e71f6c30eb8e6296353d33e475 Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Tue, 9 Sep 2008 02:42:36 +0000 Subject: [PATCH] checking in initial version of component interface --- component/component.py | 77 ++++++++++++++++++++++++++++++++++++++++++ component/copynode.sh | 5 +++ component/sshnode.sh | 2 ++ 3 files changed, 84 insertions(+) create mode 100644 component/component.py create mode 100755 component/copynode.sh create mode 100755 component/sshnode.sh diff --git a/component/component.py b/component/component.py new file mode 100644 index 00000000..c584a85e --- /dev/null +++ b/component/component.py @@ -0,0 +1,77 @@ +import tempfile +import os + +import sys + +from cert import * +from gid import * +from geniserver import * +from excep import * +from trustedroot import * +from misc import * +from record import * + +import accounts + + +class ComponentManager(GeniServer): + def __init__(self, ip, port, key_file, cert_file): + GeniServer.__init__(self, ip, port, key_file, cert_file) + + def register_functions(self): + GeniServer.register_functions(self) + self.server.register_function(self.stop_slice) + self.server.register_function(self.start_slice) + self.server.register_function(self.reset_slice) + self.server.register_function(self.delete_slice) + + def stop_slice(self, cred_str): + self.decode_authentication(cred_str, "stopslice") + slicename = hrn_to_pl_slicename(self.object_gid.get_hrn()) + print "stopslice:", slicename + accounts.get(slicename).start() + + def start_slice(self, cred_str): + self.decode_authentication(cred_str, "startslice") + slicename = hrn_to_pl_slicename(self.object_gid.get_hrn()) + print "startslice:", slicename + accounts.get(slicename).start() + + def reset_slice(self, cred_str): + self.decode_authentication(cred_str, "resetslice") + slicename = hrn_to_pl_slicename(self.object_gid.get_hrn()) + print "resetslice:", slicename + accounts.get(slicename).stop() + accounts.get(slicename).ensure_destroyed() + accounts.get(slicename).ensure_created() + + def delete_slice(self, cred_str): + self.decode_authentication(cred_str, "deleteslice") + slicename = hrn_to_pl_slicename(self.object_gid.get_hrn()) + print "deleteslice:", slicename + accounts.get(slicename).ensure_destroyed() + + +if __name__ == "__main__": + global TrustedRoots + + key_file = "component.key" + cert_file = "component.cert" + + # if no key is specified, then make one up + if (not os.path.exists(key_file)) or (not os.path.exists(cert_file)): + key = Keypair(create=True) + key.save_to_file(key_file) + + cert = Certificate(subject="component") + cert.set_issuer(key=key, subject="component") + cert.set_pubkey(key) + cert.sign() + cert.save_to_file(cert_file) + + TrustedRoots = TrustedRootList() + + s = ComponentManager("", 12345, key_file, cert_file) + s.trusted_cert_list = TrustedRoots.get_list() + s.run() + diff --git a/component/copynode.sh b/component/copynode.sh new file mode 100755 index 00000000..572a2e0a --- /dev/null +++ b/component/copynode.sh @@ -0,0 +1,5 @@ +#!/bin/bash +echo connecting to node: $1 +export FILES="component.py ../util/cert.py ../util/credential.py ../util/excep.py ../util/geniserver.py ../util/gid.py ../util/misc.py ../util/record.py ../util/rights.py ../util/report.py ../util/trustedroot.py ../registry/trusted_roots install" +echo $FILES +scp -i root_ssh_key.rsa -r $FILES root@$1:/usr/share/NodeManager diff --git a/component/sshnode.sh b/component/sshnode.sh new file mode 100755 index 00000000..d25eb301 --- /dev/null +++ b/component/sshnode.sh @@ -0,0 +1,2 @@ +echo connecting to node: $1 +ssh -i root_ssh_key.rsa root@$1 -- 2.43.0