X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fclient%2Fsfi.py;h=094c6be4f1eae0b7b751f5cc06f867c4b09c1950;hb=a8007ffe1b28614b26f03e4537659b1234003f2d;hp=a8d96d66823d5bcf1b9652e9ae11ee86807cf7b8;hpb=5375bea15f3cb276b902bb6371ab41842a04b6cb;p=sfa.git diff --git a/sfa/client/sfi.py b/sfa/client/sfi.py old mode 100755 new mode 100644 index a8d96d66..094c6be4 --- a/sfa/client/sfi.py +++ b/sfa/client/sfi.py @@ -15,7 +15,7 @@ from lxml import etree from StringIO import StringIO from types import StringTypes, ListType from optparse import OptionParser -from sfa.util.sfalogging import _SfaLogger, logging +from sfa.util.sfalogging import sfi_logger from sfa.trust.certificate import Keypair, Certificate from sfa.trust.gid import GID from sfa.trust.credential import Credential @@ -26,6 +26,8 @@ import sfa.util.xmlrpcprotocol as xmlrpcprotocol from sfa.util.config import Config from sfa.util.version import version_core from sfa.util.cache import Cache +from sfa.rspecs.rspec_version import RSpecVersion +from sfa.rspecs.pg_rspec import pg_rspec_request_version AGGREGATE_PORT=12346 CM_PORT=12346 @@ -141,9 +143,8 @@ class Sfi: self.user = None self.authority = None self.hashrequest = False - #sfa_logger_goes_to_console() - #self.logger=sfa_logger() - self.logger = _SfaLogger(self.sfi_dir + 'sfi.log', level = logging.INFO) + self.logger = sfi_logger + self.logger.enable_console() def create_cmd_parser(self, command, additional_cmdargs=None): cmdargs = {"list": "authority", @@ -372,6 +373,8 @@ class Sfi: version = server.GetVersion() # cache version for 24 hours cache.add(cache_key, version, ttl= 60*60*24) + self.logger.info("Updating cache file %s" % cache_file) + cache.save_to_file(cache_file) return version @@ -434,13 +437,11 @@ class Sfi: cert.set_issuer(k, self.user) cert.sign() self.logger.info("Writing self-signed certificate to %s"%cert_file) - print "Writing self-signed certificate to %s"%cert_file cert.save_to_file(cert_file) self.cert = cert # try to get registry issued cert try: self.logger.info("Getting Registry issued cert") - print "Getting Registry issued cert" self.read_config() # *hack. need to set registyr before _get_gid() is called self.registry = xmlrpcprotocol.get_server(self.reg_url, key_file, cert_file, self.options) @@ -449,8 +450,6 @@ class Sfi: self.logger.info("Writing certificate to %s"%cert_file) gid.save_to_file(cert_file) except: - - print "Failed to download Registry issued cert" self.logger.info("Failed to download Registry issued cert") return cert_file @@ -485,6 +484,7 @@ class Sfi: hrn = self.user gidfile = os.path.join(self.options.sfi_dir, hrn + ".gid") + print gidfile gid = self.get_cached_gid(gidfile) if not gid: user_cred = self.get_user_cred() @@ -812,6 +812,8 @@ class Sfi: """ trusted_certs = self.registry.get_trusted_certs() for trusted_cert in trusted_certs: + gid = GID(string=trusted_cert) + gid.dump() cert = Certificate(string=trusted_cert) self.logger.debug('Sfi.get_trusted_certs -> %r'%cert.get_subject()) return @@ -894,7 +896,14 @@ class Sfi: delegated_cred = self.delegate_cred(cred, get_authority(self.authority)) creds.append(delegated_cred) if opts.rspec_version: - call_options['rspec_version'] = opts.rspec_version + server_version = self.get_cached_server_version(server) + if 'sfa' in server_version: + # just request the version the client wants + call_options['rspec_version'] = dict(RSpecVersion(opts.rspec_version)) + else: + # this must be a protogeni aggregate. We should request a v2 ad rspec + # regardless of what the client user requested + call_options['rspec_version'] = dict(pg_rspec_request_version) #panos add info options if opts.info: call_options['info'] = opts.info @@ -932,7 +941,7 @@ class Sfi: # }] users = [] server = self.get_server_from_opts(opts) - version = server.GetVersion() + version = self.get_cached_server_version(server) if 'sfa' not in version: # need to pass along user keys if this request is going to a ProtoGENI aggregate # ProtoGeni Aggregates will only install the keys of the user that is issuing the @@ -1136,7 +1145,7 @@ class Sfi: self.logger.debug("resources cmd_opts %s" % cmd_opts.format) elif command in ("list", "show", "remove"): self.logger.debug("cmd_opts.type %s" % cmd_opts.type) - self.logger.debug('cmd_args %s',cmd_args) + self.logger.debug('cmd_args %s' % cmd_args) try: self.dispatch(command, cmd_opts, cmd_args)