def __init__(self, config):
        self.logger = logging.getLogger("omni.protogeni")
        config['cert'] = os.path.expanduser(config['cert'])
        if not os.path.exists(config['cert']):
            sys.exit('PG Framework certfile %s doesnt exist' % config['cert'])
        config['key'] = os.path.expanduser(config['key'])
        if not os.path.exists(config['key']):
            sys.exit('PG Framework keyfile %s doesnt exist' % config['key'])
        if not config.has_key('verbose'):
            config['verbose'] = False
	else:
	    config['verbose'] = config['verbose'].lower() in ['true', '1', 't', 'yes', 'on']
	if config['verbose']:
		self.logger.info('Verbose logging is on')
        self.config = config
        self.logger.debug("Configured with key file %s", config['key'])
        
        self.logger.debug('Using clearinghouse %s', self.config['ch'])
        self.ch = make_client(self.config['ch'], self.config['key'],
                              self.config['cert'], self.config['verbose'])
        self.logger.debug('Using slice authority %s', self.config['sa'])
        self.sa = make_client(self.config['sa'], self.config['key'],
                              self.config['cert'], self.config['verbose'])
        self.user_cred = None
        
        # For now, no override aggregates.
        self.aggs = None
示例#2
0
    def __init__(self, config):
        self.logger = logging.getLogger("omni.protogeni")
        config['cert'] = os.path.expanduser(config['cert'])
        if not os.path.exists(config['cert']):
            sys.exit('PG Framework certfile %s doesnt exist' % config['cert'])
        config['key'] = os.path.expanduser(config['key'])
        if not os.path.exists(config['key']):
            sys.exit('PG Framework keyfile %s doesnt exist' % config['key'])
        if not config.has_key('verbose'):
            config['verbose'] = False
        else:
            config['verbose'] = config['verbose'].lower() in [
                'true', '1', 't', 'yes', 'on'
            ]
        if config['verbose']:
            self.logger.info('Verbose logging is on')
        self.config = config
        self.logger.debug("Configured with key file %s", config['key'])

        self.logger.debug('Using clearinghouse %s', self.config['ch'])
        self.ch = make_client(self.config['ch'], self.config['key'],
                              self.config['cert'], self.config['verbose'])
        self.logger.debug('Using slice authority %s', self.config['sa'])
        self.sa = make_client(self.config['sa'], self.config['key'],
                              self.config['cert'], self.config['verbose'])
        self.user_cred = None

        # For now, no override aggregates.
        self.aggs = None
示例#3
0
    def __init__(self, config):
        config['cert'] = os.path.expanduser(config['cert'])
        config['key'] = os.path.expanduser(config['key'])        

        self.config = config

        # Download a cert from PLC if necessary
        if not os.path.exists(config['cert']):
            res = raw_input("Your certificate file (%s) was not found, would you like me to download it for you to %s? (Y/n)" % (config['cert'],config['cert']))
            if not res.lower().startswith('n'):
                # Create a self-signed cert to talk to the registry with
                create_selfsigned_cert2(config['cert'], config['user'], config['key'])
                try:
                    # use the self signed cert to get the gid
                    self.registry = make_client(config['registry'], config['key'], config['cert'])
                    self.user_cred = None
                    self.cert_string = file(config['cert'],'r').read()
                    cred = self.get_user_cred()
                    gid = self.registry.Resolve(config['user'], cred)[0]['gid']
                    # Finally, copy the gid to the cert location
                    f = open(self.config['cert'],'w')
                    f.write(gid)
                    f.close()
                except Exception, exc:
                    os.remove(self.config['cert'])
                    sys.exit("Failed to download a user certificate from the PL registry: %s" % exc)
            else:            
                sys.exit("SFA Framework certfile %s doesn't exist" % config['cert'])
 def _find_geni_ams(self, cm_dicts):
     """Finds ComponentManagers that also support the GENI AM API.
     Returns a list of dicts containing those CMs that implement the AM API.
     The AM URL is included in the dict in the key 'am_url'.
     """
     result = list()
     for cm_dict in cm_dicts:
         cm_url = cm_dict['url']
         self.logger.debug('Checking for AM at %s', cm_url)
         am_url = self._cm_to_am(cm_url)
         self.logger.debug('AM URL = %s', am_url)
         if am_url != cm_url:
             # Test the am_url...
             client = make_client(am_url, self.config['key'],
                                  self.config['cert'],
                                  self.config['verbose'],
                                  timeout=5)
             try:
                 version = client.GetVersion()
                 self.logger.debug('version = %r', version)
                 # Temporarily accept pg style result until pgeni3 is upgraded.
                 if version.has_key('output'):
                     version = version['value']
                 if version.has_key('geni_api'):
                     cm_dict['am_url'] = am_url
                     result.append(cm_dict)
             except xmlrpclib.ProtocolError, err:
                 self.logger.debug("Skipping %s due to xml rpc error: %s",
                                   cm_url, err)
             except ssl.SSLError, err:
                 self.logger.debug("Skipping %s due to ssl error: %s",
                                   cm_url, err)
             except socket.error, err:
                 self.logger.debug("Skipping %s due to socket error: %s",
                                   cm_url, err)
示例#5
0
    def __init__(self, config):
        config["cert"] = os.path.expanduser(config["cert"])
        config["key"] = os.path.expanduser(config["key"])

        self.config = config

        # Download a cert from PLC if necessary
        if not os.path.exists(config["cert"]):
            res = raw_input(
                "Your certificate file (%s) was not found, would you like me to download it for you to %s? (Y/n)"
                % (config["cert"], config["cert"])
            )
            if not res.lower().startswith("n"):
                # Create a self-signed cert to talk to the registry with
                create_selfsigned_cert2(config["cert"], config["user"], config["key"])
                try:
                    # use the self signed cert to get the gid
                    self.registry = make_client(config["registry"], config["key"], config["cert"])
                    self.user_cred = None
                    self.cert_string = file(config["cert"], "r").read()
                    cred = self.get_user_cred()
                    gid = self.registry.Resolve(config["user"], cred)[0]["gid"]
                    # Finally, copy the gid to the cert location
                    f = open(self.config["cert"], "w")
                    f.write(gid)
                    f.close()
                except Exception, exc:
                    os.remove(self.config["cert"])
                    sys.exit("Failed to download a user certificate from the PL registry: %s" % exc)
            else:
                sys.exit("SFA Framework certfile %s doesn't exist" % config["cert"])
示例#6
0
文件: proxyam.py 项目: EICT/C-BAS
 def make_proxy_client(self):
     key_certs = get_inside_cert_and_key(self._server.peercert, self.ma_url, self.logger)
     key_fname = key_certs["key"]
     cert_fname = key_certs["cert"]
     client = make_client(self.am_url, key_fname, cert_fname)
     client.key_fname = key_fname
     client.cert_fname = cert_fname
     return client
示例#7
0
文件: proxyam.py 项目: EICT/C-BAS
 def make_proxy_client(self):
     key_certs = get_inside_cert_and_key(self._server.peercert, \
                                             self.ma_url, self.logger);
     key_fname = key_certs['key'];
     cert_fname = key_certs['cert'];
     client = make_client(self.am_url, key_fname, cert_fname)
     client.key_fname = key_fname;
     client.cert_fname = cert_fname;
     return client;
示例#8
0
文件: proxyam.py 项目: wvdemeer/C-BAS
 def make_proxy_client(self):
     key_certs = get_inside_cert_and_key(self._server.peercert, \
                                             self.ma_url, self.logger);
     key_fname = key_certs['key'];
     cert_fname = key_certs['cert'];
     client = make_client(self.am_url, key_fname, cert_fname)
     client.key_fname = key_fname;
     client.cert_fname = cert_fname;
     return client;
示例#9
0
class Framework(Framework_Base):
    def __init__(self, config):
        config['cert'] = os.path.expanduser(config['cert'])
        config['key'] = os.path.expanduser(config['key'])        

        self.config = config

        # Download a cert from PLC if necessary
        if not os.path.exists(config['cert']):
            res = raw_input("Your certificate file (%s) was not found, would you like me to download it for you to %s? (Y/n)" % (config['cert'],config['cert']))
            if not res.lower().startswith('n'):
                # Create a self-signed cert to talk to the registry with
                create_selfsigned_cert2(config['cert'], config['user'], config['key'])
                try:
                    # use the self signed cert to get the gid
                    self.registry = make_client(config['registry'], config['key'], config['cert'])
                    self.user_cred = None
                    self.cert_string = file(config['cert'],'r').read()
                    cred = self.get_user_cred()
                    gid = self.registry.Resolve(config['user'], cred)[0]['gid']
                    # Finally, copy the gid to the cert location
                    f = open(self.config['cert'],'w')
                    f.write(gid)
                    f.close()
                except Exception, exc:
                    os.remove(self.config['cert'])
                    sys.exit("Failed to download a user certificate from the PL registry: %s" % exc)
            else:            
                sys.exit("SFA Framework certfile %s doesn't exist" % config['cert'])
                
                
        if not os.path.exists(config['key']):
            sys.exit('SFA Framework keyfile %s doesnt exist' % config['key'])
        if not config.has_key('verbose'):
            config['verbose'] = False
        logger = logging.getLogger('omni.sfa')
        logger.info('SFA Registry: %s', config['registry'])
        self.registry = make_client(config['registry'], config['key'], config['cert'], allow_none=True)
        logger.info('SFA Slice Manager: %s', config['slicemgr'])
        self.slicemgr = make_client(config['slicemgr'], config['key'], config['cert'])
        self.cert_string = file(config['cert'],'r').read()
        self.user_cred = None
 def __init__(self, config):
     config['cert'] = os.path.expanduser(config['cert'])
     if not os.path.exists(config['cert']):
         sys.exit('GCF Framework certfile %s doesnt exist' % config['cert'])
     config['key'] = os.path.expanduser(config['key'])        
     if not os.path.exists(config['key']):
         sys.exit('GCF Framework keyfile %s doesnt exist' % config['key'])
     if not config.has_key('verbose'):
         config['verbose'] = False
     self.config = config
     
     self.ch = make_client(config['ch'], config['key'], config['cert'])
     self.cert_string = file(config['cert'],'r').read()
     self.user_cred = None
示例#11
0
    def __init__(self, config):
        config['cert'] = os.path.expanduser(config['cert'])
        if not os.path.exists(config['cert']):
            sys.exit('GCF Framework certfile %s doesnt exist' % config['cert'])
        config['key'] = os.path.expanduser(config['key'])
        if not os.path.exists(config['key']):
            sys.exit('GCF Framework keyfile %s doesnt exist' % config['key'])
        if not config.has_key('verbose'):
            config['verbose'] = False
        self.config = config

        self.ch = make_client(config['ch'], config['key'], config['cert'])
        self.cert_string = file(config['cert'], 'r').read()
        self.user_cred = None
示例#12
0
 def _find_geni_ams(self, cm_dicts):
     """Finds ComponentManagers that also support the GENI AM API.
     Returns a list of dicts containing those CMs that implement the AM API.
     The AM URL is included in the dict in the key 'am_url'.
     """
     result = list()
     for cm_dict in cm_dicts:
         cm_url = cm_dict['url']
         self.logger.debug('Checking for AM at %s', cm_url)
         am_url = self._cm_to_am(cm_url)
         self.logger.debug('AM URL = %s', am_url)
         if am_url != cm_url:
             # Test the am_url...
             client = make_client(am_url,
                                  self.config['key'],
                                  self.config['cert'],
                                  self.config['verbose'],
                                  timeout=5)
             try:
                 version = client.GetVersion()
                 self.logger.debug('version = %r', version)
                 # Temporarily accept pg style result until pgeni3 is upgraded.
                 if version.has_key('output'):
                     version = version['value']
                 if version.has_key('geni_api'):
                     cm_dict['am_url'] = am_url
                     result.append(cm_dict)
             except xmlrpclib.ProtocolError, err:
                 self.logger.debug("Skipping %s due to xml rpc error: %s",
                                   cm_url, err)
             except ssl.SSLError, err:
                 self.logger.debug("Skipping %s due to ssl error: %s",
                                   cm_url, err)
             except socket.error, err:
                 self.logger.debug("Skipping %s due to socket error: %s",
                                   cm_url, err)