• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sfatime.utcparse函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sfa.util.sfatime.utcparse函数的典型用法代码示例。如果您正苦于以下问题:Python utcparse函数的具体用法?Python utcparse怎么用?Python utcparse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了utcparse函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: sliver_status

    def sliver_status(self, slice_urn, slice_hrn):
        # find out where this slice is currently running
        slice_name = hrn_to_dummy_slicename(slice_hrn)

        slice = self.shell.GetSlices({"slice_name": slice_name})
        if len(slices) == 0:
            raise SliverDoesNotExist("%s (used %s as slicename internally)" % (slice_hrn, slicename))

        # report about the local nodes only
        nodes = self.shell.GetNodes({"node_ids": slice["node_ids"]})

        if len(nodes) == 0:
            raise SliverDoesNotExist("You have not allocated any slivers here")

        # get login info
        user = {}
        keys = []
        if slice["user_ids"]:
            users = self.shell.GetUsers({"user_ids": slice["user_ids"]})
            for user in users:
                keys.extend(user["keys"])

            user.update(
                {"urn": slice_urn, "login": slice["slice_name"], "protocol": ["ssh"], "port": ["22"], "keys": keys}
            )

        result = {}
        top_level_status = "unknown"
        if nodes:
            top_level_status = "ready"
        result["geni_urn"] = slice_urn
        result["dummy_login"] = slice["slice_name"]
        result["dummy_expires"] = datetime_to_string(utcparse(slice["expires"]))
        result["geni_expires"] = datetime_to_string(utcparse(slice["expires"]))

        resources = []
        for node in nodes:
            res = {}
            res["dummy_hostname"] = node["hostname"]
            res["geni_expires"] = datetime_to_string(utcparse(slice["expires"]))
            sliver_id = Xrn(slice_urn, type="slice", id=node["node_id"], authority=self.hrn).urn
            res["geni_urn"] = sliver_id
            res["geni_status"] = "ready"
            res["geni_error"] = ""
            res["users"] = [users]

            resources.append(res)

        result["geni_status"] = top_level_status
        result["geni_resources"] = resources
        return result
开发者ID:tubav,项目名称:sfa,代码行数:51,代码来源:dummydriver.py


示例2: get_rspec

    def get_rspec(self, slice_xrn=None, version = None, options={}):

        version_manager = VersionManager()
        version = version_manager.get_version(version)
        if not slice_xrn:
            rspec_version = version_manager._get_version(version.type, version.version, 'ad')
        else:
            rspec_version = version_manager._get_version(version.type, version.version, 'manifest')

        slice, slivers = self.get_slice_and_slivers(slice_xrn)
        rspec = RSpec(version=rspec_version, user_options=options)
        if slice and 'expires' in slice:
            rspec.xml.set('expires',  datetime_to_string(utcparse(slice['expires'])))

        nodes = self.get_nodes(slice_xrn, slice, slivers, options)
        rspec.version.add_nodes(nodes)
        # add sliver defaults
        default_sliver = slivers.get(None, [])
        if default_sliver:
            default_sliver_attribs = default_sliver.get('tags', [])
            for attrib in default_sliver_attribs:
                 logger.info(attrib)
                 rspec.version.add_default_sliver_attribute(attrib['tagname'], attrib['value'])
        
        return rspec.toxml()
开发者ID:tubav,项目名称:sfa,代码行数:25,代码来源:dummyaggregate.py


示例3: describe

    def describe(self, urns, version=None, options=None):
        if options is None: options={}
        version_manager = VersionManager()
        version = version_manager.get_version(version)
        rspec_version = version_manager._get_version(version.type, version.version, 'manifest')
        rspec = RSpec(version=rspec_version, user_options=options)

        # Update connection for the current user
        xrn = Xrn(urns[0], type='slice')
        user_name = xrn.get_authority_hrn() + '.' + xrn.leaf.split('-')[0]
        tenant_name = OSXrn(xrn=urns[0], type='slice').get_hrn()
        self.driver.shell.compute_manager.connect(username=user_name, tenant=tenant_name, password=user_name)

        # For delay to collect instance info 
        time.sleep(3)
        # Get instances from the Openstack
        instances = self.get_instances(xrn)

        # Add sliver(s) from instance(s)
        geni_slivers = []
        rspec.xml.set( 'expires',  datetime_to_string(utcparse(time.time())) )
        rspec_nodes = []
        for instance in instances:
            rspec_nodes.append(self.instance_to_rspec_node(instance))
            geni_sliver = self.instance_to_geni_sliver(instance)
            geni_slivers.append(geni_sliver)
        rspec.version.add_nodes(rspec_nodes)

        result = { 'geni_urn': xrn.get_urn(),
                   'geni_rspec': rspec.toxml(), 
                   'geni_slivers': geni_slivers }
        return result
开发者ID:kongseokhwan,项目名称:sfa,代码行数:32,代码来源:osaggregate.py


示例4: verify_slice

    def verify_slice(self, slice_hrn, slice_record, peer, sfa_peer, options={}):
        slicename = hrn_to_pl_slicename(slice_hrn)
        parts = slicename.split("_")
        login_base = parts[0]
        slices = self.driver.shell.GetSlices([slicename]) 
        if not slices:
            slice = {'name': slicename,
                     'url': slice_record.get('url', slice_hrn), 
                     'description': slice_record.get('description', slice_hrn)}
            # add the slice                          
            slice['slice_id'] = self.driver.shell.AddSlice(slice)
            slice['node_ids'] = []
            slice['person_ids'] = []
            if peer:
                slice['peer_slice_id'] = slice_record.get('slice_id', None) 
            # mark this slice as an sfa peer record
#            if sfa_peer:
#                peer_dict = {'type': 'slice', 'hrn': slice_hrn, 
#                             'peer_authority': sfa_peer, 'pointer': slice['slice_id']}
#                self.registry.register_peer_object(self.credential, peer_dict)
        else:
            slice = slices[0]
            if peer:
                slice['peer_slice_id'] = slice_record.get('slice_id', None)
                # unbind from peer so we can modify if necessary. Will bind back later
                self.driver.shell.UnBindObjectFromPeer('slice', slice['slice_id'], peer['shortname'])
	        #Update existing record (e.g. expires field) it with the latest info.
            if slice_record.get('expires'):
                requested_expires = int(datetime_to_epoch(utcparse(slice_record['expires'])))
                if requested_expires and slice['expires'] != requested_expires:
                    self.driver.shell.UpdateSlice( slice['slice_id'], {'expires' : requested_expires})
       
        return slice
开发者ID:tubav,项目名称:sfa,代码行数:33,代码来源:plslices.py


示例5: delete

    def delete(self, urns, options={}):
        # collect sliver ids so we can update sliver allocation states after
        # we remove the slivers.
        aggregate = unigetestbedAggregate(self)
        slivers = aggregate.get_slivers(urns)
        if slivers:
            slice_id = slivers[0]['slice_id']
            node_ids = []
            sliver_ids = []
            for sliver in slivers:
                node_ids.append(sliver['node_id'])
                sliver_ids.append(sliver['sliver_id'])

            # determine if this is a peer slice
            # xxx I wonder if this would not need to use PlSlices.get_peer instead 
            # in which case plc.peers could be deprecated as this here
            # is the only/last call to this last method in plc.peers
            slice_hrn = unigetestbedXrn(auth=self.hrn, slicename=slivers[0]['slice_name']).get_hrn()
            try:
                self.shell.DeleteSliceFromNodes({'slice_id': slice_id, 'node_ids': node_ids})
                # delete sliver allocation states
                dbsession=self.api.dbsession()
                SliverAllocation.delete_allocations(sliver_ids,dbsession)
            finally:
                pass

        # prepare return struct
        geni_slivers = []
        for sliver in slivers:
            geni_slivers.append(
                {'geni_sliver_urn': sliver['sliver_id'],
                 'geni_allocation_status': 'geni_unallocated',
                 'geni_expires': datetime_to_string(utcparse(sliver['expires']))})  
        return geni_slivers
开发者ID:tcslab,项目名称:unige_sfawrap,代码行数:34,代码来源:unigetestbeddriver.py


示例6: sliver_to_rspec_node

    def sliver_to_rspec_node(self, sliver, sites, interfaces, node_tags, \
                             pl_initscripts, sliver_allocations):
        # get the granularity in second for the reservation system
        grain = self.driver.shell.GetLeaseGranularity()
        rspec_node = self.node_to_rspec_node(sliver, sites, interfaces, node_tags, pl_initscripts, grain)
        # xxx how to retrieve site['login_base']
        rspec_node['expires'] = datetime_to_string(utcparse(sliver['expires']))
        # remove interfaces from manifest
        rspec_node['interfaces'] = []
        # add sliver info
        rspec_sliver = Sliver({'sliver_id': sliver['urn'],
                         'name': sliver['name'],
                         'type': 'plab-vserver',
                         'tags': []})
        rspec_node['sliver_id'] = rspec_sliver['sliver_id']
        if sliver['urn'] in sliver_allocations:
            rspec_node['client_id'] = sliver_allocations[sliver['urn']].client_id
            if sliver_allocations[sliver['urn']].component_id:
                rspec_node['component_id'] = sliver_allocations[sliver['urn']].component_id
        rspec_node['slivers'] = [rspec_sliver]

        # slivers always provide the ssh service
        login = Login({'authentication': 'ssh-keys', 
                       'hostname': sliver['hostname'], 
                       'port':'22', 
                       'username': sliver['name'],
                       'login': sliver['name']
                      })
        service = ServicesElement({'login': login,
                            'services_user': sliver['services_user']})
        rspec_node['services'] = [service]    
        return rspec_node      
开发者ID:nfvproject,项目名称:SFA,代码行数:32,代码来源:plaggregate.py


示例7: describe

    def describe(self, urns, version=None, options={}):
        # update nova connection
        tenant_name = OSXrn(xrn=urns[0], type='slice').get_tenant_name()
        self.driver.shell.nova_manager.connect(tenant=tenant_name)
        instances = self.get_instances(urns)
        # lookup the sliver allocations
        sliver_ids = [sliver['sliver_id'] for sliver in slivers]
        constraint = SliverAllocation.sliver_id.in_(sliver_ids)
        sliver_allocations = self.driver.api.dbsession().query(SliverAllocation).filter(constraint)
        sliver_allocation_dict = {}
        for sliver_allocation in sliver_allocations:
            sliver_allocation_dict[sliver_allocation.sliver_id] = sliver_allocation

        geni_slivers = []
        rspec_nodes = []
        for instance in instances:
            rspec_nodes.append(self.instance_to_rspec_node(instance))
            geni_sliver = self.instance_to_geni_sliver(instance, sliver_sllocation_dict)
            geni_slivers.append(geni_sliver)
        version_manager = VersionManager()
        version = version_manager.get_version(version)
        rspec_version = version_manager._get_version(version.type, version.version, 'manifest')
        rspec = RSpec(version=rspec_version, user_options=options)
        rspec.xml.set('expires',  datetime_to_string(utcparse(time.time())))
        rspec.version.add_nodes(rspec_nodes)
        result = {'geni_urn': Xrn(urns[0]).get_urn(),
                  'geni_rspec': rspec.toxml(), 
                  'geni_slivers': geni_slivers}
        
        return result
开发者ID:aquila,项目名称:sfa,代码行数:30,代码来源:osaggregate.py


示例8: instance_to_geni_sliver

    def instance_to_geni_sliver(self, instance, sliver_allocations = {}):
        sliver_hrn = '%s.%s' % (self.driver.hrn, instance.id)
        sliver_id = Xrn(sliver_hrn, type='sliver').urn
 
        # set sliver allocation and operational status
        sliver_allocation = sliver_allocations[sliver_id]
        if sliver_allocation:
            allocation_status = sliver_allocation.allocation_state
            if allocation_status == 'geni_allocated':
                op_status =  'geni_pending_allocation'
            elif allocation_status == 'geni_provisioned':
                state = instance.state.lower()
                if state == 'active':
                    op_status = 'geni_ready'
                elif state == 'building':
                    op_status = 'geni_notready'
                elif state == 'failed':
                    op_status =' geni_failed'
                else:
                    op_status = 'geni_unknown'
            else:
                allocation_status = 'geni_unallocated'    
        # required fields
        geni_sliver = {'geni_sliver_urn': sliver_id, 
                       'geni_expires': None,
                       'geni_allocation_status': allocation_status,
                       'geni_operational_status': op_status,
                       'geni_error': None,
                       'plos_created_at': datetime_to_string(utcparse(instance.created)),
                       'plos_sliver_type': self.shell.nova_manager.flavors.find(id=instance.flavor['id']).name,
                        }

        return geni_sliver
开发者ID:aquila,项目名称:sfa,代码行数:33,代码来源:osaggregate.py


示例9: GetCredential

    def GetCredential(self, api, xrn, type, caller_xrn=None):
        # convert xrn to hrn     
        if type:
            hrn = urn_to_hrn(xrn)[0]
        else:
            hrn, type = urn_to_hrn(xrn)

        # Is this a root or sub authority
        auth_hrn = api.auth.get_authority(hrn)
        if not auth_hrn or hrn == api.config.SFA_INTERFACE_HRN:
            auth_hrn = hrn
        auth_info = api.auth.get_auth_info(auth_hrn)
        # get record info
        record=dbsession.query(RegRecord).filter_by(type=type,hrn=hrn).first()
        if not record:
            raise RecordNotFound("hrn=%s, type=%s"%(hrn,type))

        # get the callers gid
        # if caller_xrn is not specified assume the caller is the record
        # object itself.
        if not caller_xrn:
            caller_hrn = hrn
            caller_gid = record.get_gid_object()
        else:
            caller_hrn, caller_type = urn_to_hrn(caller_xrn)
            if caller_type:
                caller_record = dbsession.query(RegRecord).filter_by(hrn=caller_hrn,type=caller_type).first()
            else:
                caller_record = dbsession.query(RegRecord).filter_by(hrn=caller_hrn).first()
            if not caller_record:
                raise RecordNotFound("Unable to associated caller (hrn=%s, type=%s) with credential for (hrn: %s, type: %s)"%(caller_hrn, caller_type, hrn, type))
            caller_gid = GID(string=caller_record.gid)i

        object_hrn = record.get_gid_object().get_hrn()
        # call the builtin authorization/credential generation engine
        rights = api.auth.determine_user_rights(caller_hrn, record)
        # make sure caller has rights to this object
        if rights.is_empty():
            raise PermissionError("%s has no rights to %s (%s)" % \
                                  (caller_hrn, object_hrn, xrn))
        object_gid = GID(string=record.gid)
        new_cred = Credential(subject = object_gid.get_subject())
        new_cred.set_gid_caller(caller_gid)
        new_cred.set_gid_object(object_gid)
        new_cred.set_issuer_keys(auth_info.get_privkey_filename(), auth_info.get_gid_filename())
        #new_cred.set_pubkey(object_gid.get_pubkey())
        new_cred.set_privileges(rights)
        new_cred.get_privileges().delegate_all_privileges(True)
        if hasattr(record,'expires'):
            date = utcparse(record.expires)
            expires = datetime_to_epoch(date)
            new_cred.set_expiration(int(expires))
        auth_kind = "authority,ma,sa"
        # Parent not necessary, verify with certs
        #new_cred.set_parent(api.auth.hierarchy.get_auth_cred(auth_hrn, kind=auth_kind))
        new_cred.encode()
        new_cred.sign()

        return new_cred.save_to_string(save_parents=True)
开发者ID:fp7-alien,项目名称:C-BAS,代码行数:59,代码来源:registry.py


示例10: set_expiration

 def set_expiration(self, expiration):
     if isinstance(expiration, (int, float)):
         self.expiration = datetime.datetime.fromtimestamp(expiration)
     elif isinstance(expiration, datetime.datetime):
         self.expiration = expiration
     elif isinstance(expiration, StringTypes):
         self.expiration = utcparse(expiration)
     else:
         logger.error("unexpected input type in Credential.set_expiration")
开发者ID:planetlab,项目名称:sfa,代码行数:9,代码来源:credential.py


示例11: date_repr

 def date_repr (self,fields):
     if not isinstance(fields,list): fields=[fields]
     for field in fields:
         value=getattr(self,field,None)
         if isinstance (value,datetime):
             return datetime_to_string (value)
         elif isinstance (value,(int,float)):
             return datetime_to_string(utcparse(value))
     # fallback
     return "** undef_datetime **"
开发者ID:kongseokhwan,项目名称:sfa,代码行数:10,代码来源:record.py


示例12: renew

 def renew (self, urns, expiration_time, options={}):
     aggregate = unigetestbedAggregate(self)
     slivers = aggregate.get_slivers(urns)
     if not slivers:
         raise SearchFailed(urns)
     slice = slivers[0]
     requested_time = utcparse(expiration_time)
     record = {'expires': int(datetime_to_epoch(requested_time))}
     self.shell.UpdateSlice({'slice_id': slice['slice_id'], 'fileds': record})
     description = self.describe(urns, 'GENI 3', options)
     return description['geni_slivers']
开发者ID:tcslab,项目名称:unige_sfawrap,代码行数:11,代码来源:unigetestbeddriver.py


示例13: describe

    def describe(self, urns, version=None, options=None):
        if options is None: options={}
        version_manager = VersionManager()
        version = version_manager.get_version(version)
        rspec_version = version_manager._get_version(version.type, version.version, 'manifest')
        rspec = RSpec(version=rspec_version, user_options=options)

        # get slivers
        geni_slivers = []
        slivers = self.get_slivers(urns, options)
        if slivers:
            rspec_expires = datetime_to_string(utcparse(slivers[0]['expires']))
        else:
            rspec_expires = datetime_to_string(utcparse(time.time()))
        rspec.xml.set('expires',  rspec_expires)

        # lookup the sliver allocations
        geni_urn = urns[0]
        sliver_ids = [sliver['sliver_id'] for sliver in slivers]
        constraint = SliverAllocation.sliver_id.in_(sliver_ids)
        sliver_allocations = self.driver.api.dbsession().query(SliverAllocation).filter(constraint)
        sliver_allocation_dict = {}
        for sliver_allocation in sliver_allocations:
            geni_urn = sliver_allocation.slice_urn
            sliver_allocation_dict[sliver_allocation.sliver_id] = sliver_allocation

        # add slivers
        nodes_dict = {}
        for sliver in slivers:
            nodes_dict[sliver['node_id']] = sliver
        rspec_nodes = []
        for sliver in slivers:
            rspec_node = self.sliver_to_rspec_node(sliver, sliver_allocation_dict)
            rspec_nodes.append(rspec_node)
            geni_sliver = self.rspec_node_to_geni_sliver(rspec_node, sliver_allocation_dict)
            geni_slivers.append(geni_sliver)
        rspec.version.add_nodes(rspec_nodes)

        return {'geni_urn': geni_urn,
                'geni_rspec': rspec.toxml(),
                'geni_slivers': geni_slivers}
开发者ID:kongseokhwan,项目名称:sfa,代码行数:41,代码来源:dummyaggregate.py


示例14: Renew

    def Renew(self, api, xrns, creds, expiration_time, options):
        call_id = options.get('call_id')
        if Callids().already_handled(call_id): return True

        # extend as long as possible
        if options.get('geni_extend_alap'):
            now = datetime.datetime.now()
            requested = utcparse(expiration_time)
            max = adjust_datetime(now, days=int(api.config.SFA_MAX_SLICE_RENEW))
            if requested > max:
                expiration_time = max
        options['creds']=creds
        return api.driver.renew(xrns, expiration_time, options)
开发者ID:gnogueras,项目名称:sfa,代码行数:13,代码来源:aggregate_manager.py


示例15: renew_sliver

 def renew_sliver (self, slice_urn, slice_hrn, creds, expiration_time, options):
     slicename = hrn_to_pl_slicename(slice_hrn)
     slices = self.shell.GetSlices({'name': slicename}, ['slice_id'])
     if not slices:
         raise RecordNotFound(slice_hrn)
     slice = slices[0]
     requested_time = utcparse(expiration_time)
     record = {'expires': int(datetime_to_epoch(requested_time))}
     try:
         self.shell.UpdateSlice(slice['slice_id'], record)
         return True
     except:
         return False
开发者ID:tubav,项目名称:sfa,代码行数:13,代码来源:pldriver.py


示例16: renew_sliver

 def renew_sliver(self, slice_urn, slice_hrn, creds, expiration_time, options):
     slicename = hrn_to_dummy_slicename(slice_hrn)
     slices = self.shell.GetSlices({"slice_name": slicename})
     if not slices:
         raise RecordNotFound(slice_hrn)
     slice = slices[0]
     requested_time = utcparse(expiration_time)
     record = {"expires": int(datetime_to_epoch(requested_time))}
     try:
         self.shell.UpdateSlice({"slice_id": slice["slice_id"], "fields": record})
         return True
     except:
         return False
开发者ID:tubav,项目名称:sfa,代码行数:13,代码来源:dummydriver.py


示例17: RenewSliver

def RenewSliver(api, xrn, creds, expiration_time, call_id):
    if Callids().already_handled(call_id): return True
    (hrn, type) = urn_to_hrn(xrn)
    slicename = hrn_to_pl_slicename(hrn)
    slices = api.plshell.GetSlices(api.plauth, {'name': slicename}, ['slice_id'])
    if not slices:
        raise RecordNotFound(hrn)
    slice = slices[0]
    requested_time = utcparse(expiration_time)
    record = {'expires': int(time.mktime(requested_time.timetuple()))}
    try:
        api.plshell.UpdateSlice(api.plauth, slice['slice_id'], record)
        return True
    except:
        return False
开发者ID:planetlab,项目名称:sfa,代码行数:15,代码来源:aggregate_manager_pl.py


示例18: sliver_status

    def sliver_status (self, slice_urn, slice_hrn):
        # update nova connection
        tenant_name = OSXrn(xrn=slice_hrn, type='slice').get_tenant_name()
        self.shell.nova_manager.connect(tenant=tenant_name)

        # find out where this slice is currently running
        project_name = hrn_to_os_slicename(slice_hrn)
        instances = self.shell.nova_manager.servers.findall(name=project_name)
        if len(instances) == 0:
            raise SliverDoesNotExist("You have not allocated any slivers here") 
        
        result = {}
        top_level_status = 'ready'
        result['geni_urn'] = slice_urn
        result['plos_login'] = 'root'
        # do we need real dates here? 
        result['plos_expires'] = None
        result['geni_expires'] = None
        
        resources = []
        for instance in instances:
            res = {}
            # instances are accessed by ip, not hostname. We need to report the ip
            # somewhere so users know where to ssh to.     
            res['geni_expires'] = None
            #res['plos_hostname'] = instance.hostname
            res['plos_created_at'] = datetime_to_string(utcparse(instance.created))    
            res['plos_boot_state'] = instance.status
            res['plos_sliver_type'] = self.shell.nova_manager.flavors.find(id=instance.flavor['id']).name 
            res['geni_urn'] =  Xrn(slice_urn, type='slice', id=instance.id).get_urn()

            if instance.status.lower() == 'active':
                res['boot_state'] = 'ready'
                res['geni_status'] = 'ready'
            elif instance.status.lower() == 'error':
                res['boot_state'] = 'failed'
                res['geni_status'] = 'failed'
                top_level_status = 'failed'
            else:
                res['boot_state'] = 'notready'  
                res['geni_status'] = 'notready'
                top_level_status = 'notready'
            resources.append(res)
            
        result['geni_status'] = top_level_status
        result['geni_resources'] = resources
        return result
开发者ID:tubav,项目名称:sfa,代码行数:47,代码来源:nova_driver.py


示例19: call

    def call(self, slice_xrn, creds, expiration_time, options):

        (hrn, type) = urn_to_hrn(slice_xrn)

        self.api.logger.info("interface: %s\ttarget-hrn: %s\tcaller-creds: %s\tmethod-name: %s"%(self.api.interface, hrn, creds, self.name))

        # Find the valid credentials
        valid_creds = self.api.auth.checkCredentials(creds, 'renewsliver', hrn)

        # Validate that the time does not go beyond the credential's expiration time
        requested_time = utcparse(expiration_time)
        max_renew_days = int(self.api.config.SFA_MAX_SLICE_RENEW)
        if requested_time > Credential(string=valid_creds[0]).get_expiration():
            raise InsufficientRights('Renewsliver: Credential expires before requested expiration time')
        if requested_time > datetime.datetime.utcnow() + datetime.timedelta(days=max_renew_days):
            raise Exception('Cannot renew > %s days from now' % max_renew_days)
        return self.api.manager.RenewSliver(self.api, slice_xrn, valid_creds, expiration_time, options)
开发者ID:tubav,项目名称:sfa,代码行数:17,代码来源:RenewSliver.py


示例20: sliver_to_rspec_node

    def sliver_to_rspec_node(self, sliver, sliver_allocations):
        """Used by describe to format node information into a rspec compliant
        structure.

        Creates a node rspec compliant structure by calling node_to_rspec_node.
        Adds slivers, if any, to rspec node structure. Returns the updated
        rspec node struct.

        :param sliver: sliver dictionary. Contains keys: urn, slice_id, hostname
            and slice_name.
        :type sliver: dictionary
        :param sliver_allocations: dictionary of slivers
        :type sliver_allocations: dict

        :returns: Node dictionary with all necessary data.

        .. seealso:: node_to_rspec_node
        """
        rspec_node = self.node_to_rspec_node(sliver)
        rspec_node['expires'] = datetime_to_string(utcparse(sliver['expires']))
        # add sliver info
        logger.debug("IOTLABAGGREGATE api \t  sliver_to_rspec_node sliver \
                        %s \r\nsliver_allocations %s" % (sliver,
                            sliver_allocations))
        rspec_sliver = Sliver({'sliver_id': sliver['urn'],
                         'name': sliver['slice_id'],
                         'type': 'iotlab-exclusive',
                         'tags': []})
        rspec_node['sliver_id'] = rspec_sliver['sliver_id']

        if sliver['urn'] in sliver_allocations:
            rspec_node['client_id'] = sliver_allocations[
                                                    sliver['urn']].client_id
            if sliver_allocations[sliver['urn']].component_id:
                rspec_node['component_id'] = sliver_allocations[
                                                    sliver['urn']].component_id
        rspec_node['slivers'] = [rspec_sliver]

        # slivers always provide the ssh service
        login = Login({'authentication': 'ssh-keys',
                       'hostname': sliver['hostname'],
                       'port':'22',
                       'username': sliver['slice_name'],
                       'login': sliver['slice_name']
                      })
        return rspec_node
开发者ID:nfvproject,项目名称:SFA,代码行数:46,代码来源:iotlabaggregate.py



注:本文中的sfa.util.sfatime.utcparse函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python xrn.get_authority函数代码示例发布时间:2022-05-27
下一篇:
Python logger.log_exc函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap