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

Python timeutils.strtime函数代码示例

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

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



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

示例1: _register_ml2_agents

 def _register_ml2_agents(self):
     callback = agents_db.AgentExtRpcCallback()
     callback.report_state(self.adminContext,
                           agent_state={'agent_state': L2_AGENT},
                           time=timeutils.strtime())
     callback.report_state(self.adminContext,
                           agent_state={'agent_state': L2_AGENT_2},
                           time=timeutils.strtime())
     callback.report_state(self.adminContext,
                           agent_state={'agent_state': L2_AGENT_3},
                           time=timeutils.strtime())
开发者ID:cnesa,项目名称:neutron,代码行数:11,代码来源:test_l2population.py


示例2: _register_l3_agents

    def _register_l3_agents(self):
        callback = agents_db.AgentExtRpcCallback()
        callback.report_state(self.adminContext,
                              agent_state={'agent_state': FIRST_L3_AGENT},
                              time=timeutils.strtime())
        agent_db = self.plugin.get_agents_db(self.adminContext,
                                             filters={'host': [HOST]})
        self.agent_id1 = agent_db[0].id

        callback.report_state(self.adminContext,
                              agent_state={'agent_state': SECOND_L3_AGENT},
                              time=timeutils.strtime())
        agent_db = self.plugin.get_agents_db(self.adminContext,
                                             filters={'host': [HOST]})
        self.agent_id2 = agent_db[0].id
开发者ID:CingHu,项目名称:neutron-1,代码行数:15,代码来源:test_l3_schedulers.py


示例3: _register_l3_dvr_agents

    def _register_l3_dvr_agents(self):
        callback = agents_db.AgentExtRpcCallback()
        callback.report_state(self.adminContext,
                              agent_state={'agent_state': DVR_L3_AGENT},
                              time=timeutils.strtime())
        agent_db = self.plugin.get_agents_db(self.adminContext,
                                             filters={'host': [HOST_DVR]})
        self.l3_dvr_agent = agent_db[0]

        callback.report_state(self.adminContext,
                              agent_state={'agent_state': DVR_SNAT_L3_AGENT},
                              time=timeutils.strtime())
        agent_db = self.plugin.get_agents_db(self.adminContext,
                                             filters={'host': [HOST_DVR_SNAT]})
        self.l3_dvr_snat_id = agent_db[0].id
        self.l3_dvr_snat_agent = agent_db[0]
开发者ID:hichihara,项目名称:neutron,代码行数:16,代码来源:test_l3_schedulers.py


示例4: report_state

 def report_state(self, context, agent_state, use_call=False):
     cctxt = self.client.prepare()
     kwargs = {
         'agent_state': {'agent_state': agent_state},
         'time': timeutils.strtime(),
     }
     method = cctxt.call if use_call else cctxt.cast
     return method(context, 'report_state', **kwargs)
开发者ID:fortara,项目名称:neutron,代码行数:8,代码来源:rpc.py


示例5: report_state

 def report_state(self, context, agent_state, use_call=False):
     msg = self.make_msg('report_state',
                         agent_state={'agent_state':
                                      agent_state},
                         time=timeutils.strtime())
     if use_call:
         return self.call(context, msg, topic=self.topic)
     else:
         return self.cast(context, msg, topic=self.topic)
开发者ID:TrevorV,项目名称:neutron,代码行数:9,代码来源:rpc.py


示例6: _register_agent_states

 def _register_agent_states(self):
     """Register two L3 agents and two DHCP agents."""
     l3_hosta = {
         'binary': 'neutron-l3-agent',
         'host': L3_HOSTA,
         'topic': topics.L3_AGENT,
         'configurations': {'use_namespaces': True,
                            'router_id': None,
                            'handle_internal_only_routers':
                            True,
                            'gateway_external_network_id':
                            None,
                            'interface_driver': 'interface_driver',
                            },
         'agent_type': constants.AGENT_TYPE_L3}
     l3_hostb = copy.deepcopy(l3_hosta)
     l3_hostb['host'] = L3_HOSTB
     dhcp_hosta = {
         'binary': 'neutron-dhcp-agent',
         'host': DHCP_HOSTA,
         'topic': 'DHCP_AGENT',
         'configurations': {'dhcp_driver': 'dhcp_driver',
                            'use_namespaces': True,
                            },
         'agent_type': constants.AGENT_TYPE_DHCP}
     dhcp_hostc = copy.deepcopy(dhcp_hosta)
     dhcp_hostc['host'] = DHCP_HOSTC
     callback = agents_db.AgentExtRpcCallback()
     callback.report_state(self.adminContext,
                           agent_state={'agent_state': l3_hosta},
                           time=timeutils.strtime())
     callback.report_state(self.adminContext,
                           agent_state={'agent_state': l3_hostb},
                           time=timeutils.strtime())
     callback.report_state(self.adminContext,
                           agent_state={'agent_state': dhcp_hosta},
                           time=timeutils.strtime())
     callback.report_state(self.adminContext,
                           agent_state={'agent_state': dhcp_hostc},
                           time=timeutils.strtime())
     return [l3_hosta, l3_hostb, dhcp_hosta, dhcp_hostc]
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Neutron,代码行数:41,代码来源:test_agent_ext_plugin.py


示例7: _report_state

 def _report_state(self):
     if not self.needs_resync:
         agent_state = {
             'ip': self.conf.lbaas_proxy_ip,
             'time': timeutils.strtime(),
             'status': 'ACTIVE' if self.haproxy_active() else 'DOWN',
         }
         try:
             self.agent_rpc.report_state(agent_state)
         except Exception:
             LOG.exception(_("Failed reporting state!"))
             self.needs_resync = True
开发者ID:nkapotoxin,项目名称:fs_spc111t_plus_hc,代码行数:12,代码来源:proxy_manager.py


示例8: _register_l3_agent

 def _register_l3_agent(self, host):
     agent = {
         'binary': 'neutron-l3-agent',
         'host': host,
         'topic': topics.L3_AGENT,
         'configurations': {},
         'agent_type': n_constants.AGENT_TYPE_L3,
         'start_flag': True
     }
     callback = agents_db.AgentExtRpcCallback()
     callback.report_state(self.adminContext,
                           agent_state={'agent_state': agent},
                           time=timeutils.strtime())
开发者ID:ArifovicH,项目名称:neutron,代码行数:13,代码来源:test_metering_plugin.py


示例9: to_dict

 def to_dict(self):
     ret_dict = super(LoadBalancer, self).to_dict()
     if self.provider:
         ret_dict['provider'] = self.provider.to_dict()
     else:
         ret_dict['provider'] = None
     ret_dict['listeners'] = [listener.to_dict()
         for listener in self.listeners]
     ret_dict['listener_ids'] = [listener.id
         for listener in self.listeners]
     ret_dict['created_at'] = timeutils.strtime(ret_dict['created_at'])
     if not self.vip_subnet_id:
         ret_dict.pop('vip_subnet_id', None)
     return ret_dict
开发者ID:CingHu,项目名称:neutron-ustack,代码行数:14,代码来源:data_models.py


示例10: _register_one_dhcp_agent

 def _register_one_dhcp_agent(self):
     """Register one DHCP agent."""
     dhcp_host = {
         'binary': 'neutron-dhcp-agent',
         'host': DHCP_HOST1,
         'topic': 'DHCP_AGENT',
         'configurations': {'dhcp_driver': 'dhcp_driver',
                            'use_namespaces': True,
                            },
         'agent_type': constants.AGENT_TYPE_DHCP}
     callback = agents_db.AgentExtRpcCallback()
     callback.report_state(self.adminContext,
                           agent_state={'agent_state': dhcp_host},
                           time=timeutils.strtime())
     return [dhcp_host]
开发者ID:AsherBond,项目名称:quantum,代码行数:15,代码来源:test_agent_ext_plugin.py


示例11: _register_one_l3_agent

 def _register_one_l3_agent(self, host=L3_HOSTA, internal_only=True,
                            ext_net_id='', ext_bridge=''):
     l3 = {
         'binary': 'neutron-l3-agent',
         'host': host,
         'topic': topics.L3_AGENT,
         'configurations': {'use_namespaces': True,
                            'router_id': None,
                            'handle_internal_only_routers': internal_only,
                            'external_network_bridge': ext_bridge,
                            'gateway_external_network_id': ext_net_id,
                            'interface_driver': 'interface_driver',
                            },
         'agent_type': constants.AGENT_TYPE_L3}
     callback = agents_db.AgentExtRpcCallback()
     callback.report_state(self.adminContext,
                           agent_state={'agent_state': l3},
                           time=timeutils.strtime())
开发者ID:AsherBond,项目名称:quantum,代码行数:18,代码来源:test_agent_ext_plugin.py


示例12: to_primitive

def to_primitive(value, convert_instances=False, convert_datetime=True,
                 level=0, max_depth=3):
    """Convert a complex object into primitives.

    Handy for JSON serialization. We can optionally handle instances,
    but since this is a recursive function, we could have cyclical
    data structures.

    To handle cyclical data structures we could track the actual objects
    visited in a set, but not all objects are hashable. Instead we just
    track the depth of the object inspections and don't go too deep.

    Therefore, convert_instances=True is lossy ... be aware.

    """
    # handle obvious types first - order of basic types determined by running
    # full tests on nova project, resulting in the following counts:
    # 572754 <type 'NoneType'>
    # 460353 <type 'int'>
    # 379632 <type 'unicode'>
    # 274610 <type 'str'>
    # 199918 <type 'dict'>
    # 114200 <type 'datetime.datetime'>
    #  51817 <type 'bool'>
    #  26164 <type 'list'>
    #   6491 <type 'float'>
    #    283 <type 'tuple'>
    #     19 <type 'long'>
    if isinstance(value, _simple_types):
        return value

    if isinstance(value, datetime.datetime):
        if convert_datetime:
            return timeutils.strtime(value)
        else:
            return value

    # value of itertools.count doesn't get caught by nasty_type_tests
    # and results in infinite loop when list(value) is called.
    if type(value) == itertools.count:
        return six.text_type(value)

    # FIXME(vish): Workaround for LP bug 852095. Without this workaround,
    #              tests that raise an exception in a mocked method that
    #              has a @wrap_exception with a notifier will fail. If
    #              we up the dependency to 0.5.4 (when it is released) we
    #              can remove this workaround.
    if getattr(value, '__module__', None) == 'mox':
        return 'mock'

    if level > max_depth:
        return '?'

    # The try block may not be necessary after the class check above,
    # but just in case ...
    try:
        recursive = functools.partial(to_primitive,
                                      convert_instances=convert_instances,
                                      convert_datetime=convert_datetime,
                                      level=level,
                                      max_depth=max_depth)
        if isinstance(value, dict):
            return dict((k, recursive(v)) for k, v in six.iteritems(value))
        elif isinstance(value, (list, tuple)):
            return [recursive(lv) for lv in value]

        # It's not clear why xmlrpclib created their own DateTime type, but
        # for our purposes, make it a datetime type which is explicitly
        # handled
        if isinstance(value, xmlrpclib.DateTime):
            value = datetime.datetime(*tuple(value.timetuple())[:6])

        if convert_datetime and isinstance(value, datetime.datetime):
            return timeutils.strtime(value)
        elif isinstance(value, gettextutils.Message):
            return value.data
        elif hasattr(value, 'iteritems'):
            return recursive(dict(value.iteritems()), level=level + 1)
        elif hasattr(value, '__iter__'):
            return recursive(list(value))
        elif convert_instances and hasattr(value, '__dict__'):
            # Likely an instance of something. Watch for cycles.
            # Ignore class member vars.
            return recursive(value.__dict__, level=level + 1)
        elif netaddr and isinstance(value, netaddr.IPAddress):
            return six.text_type(value)
        else:
            if any(test(value) for test in _nasty_type_tests):
                return six.text_type(value)
            return value
    except TypeError:
        # Class objects are tricky since they may define something like
        # __iter__ defined but it isn't callable as list().
        return six.text_type(value)
开发者ID:50infivedays,项目名称:neutron,代码行数:94,代码来源:jsonutils.py


示例13: _uos_extend_timestamp

def _uos_extend_timestamp(res, db):
    res['created_at'] = timeutils.strtime(db['created_at'])
开发者ID:CingHu,项目名称:neutron-ustack,代码行数:2,代码来源:uos_db.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python timeutils.utcnow函数代码示例发布时间:2022-05-27
下一篇:
Python service.launch函数代码示例发布时间: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