当前位置: 首页>>代码示例>>Python>>正文


Python attributes.convert_to_boolean函数代码示例

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


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

示例1: get_agents

 def get_agents(self, context, filters=None, fields=None):
     agents = self._get_collection(context, Agent, self._make_agent_dict, filters=filters, fields=fields)
     alive = filters and filters.get("alive", None)
     if alive:
         # alive filter will be a list
         alive = attributes.convert_to_boolean(alive[0])
         agents = [agent for agent in agents if agent["alive"] == alive]
     return agents
开发者ID:yizhongyin,项目名称:OpenstackLiberty,代码行数:8,代码来源:agents_db.py

示例2: test_convert_to_boolean_str

 def test_convert_to_boolean_str(self):
     self.assertIs(attributes.convert_to_boolean("True"), True)
     self.assertIs(attributes.convert_to_boolean("true"), True)
     self.assertIs(attributes.convert_to_boolean("False"), False)
     self.assertIs(attributes.convert_to_boolean("false"), False)
     self.assertIs(attributes.convert_to_boolean("0"), False)
     self.assertIs(attributes.convert_to_boolean("1"), True)
     self.assertRaises(n_exc.InvalidInput, attributes.convert_to_boolean, "7")
开发者ID:manjeetbhatia,项目名称:test_l3,代码行数:8,代码来源:test_attributes.py

示例3: test_convert_to_boolean_str

 def test_convert_to_boolean_str(self):
     self.assertIs(attributes.convert_to_boolean('True'), True)
     self.assertIs(attributes.convert_to_boolean('true'), True)
     self.assertIs(attributes.convert_to_boolean('False'), False)
     self.assertIs(attributes.convert_to_boolean('false'), False)
     self.assertIs(attributes.convert_to_boolean('0'), False)
     self.assertIs(attributes.convert_to_boolean('1'), True)
     self.assertRaises(n_exc.InvalidInput,
                       attributes.convert_to_boolean,
                       '7')
开发者ID:glove747,项目名称:liberty-neutron,代码行数:10,代码来源:test_attributes.py

示例4: test_convert_to_boolean_int

 def test_convert_to_boolean_int(self):
     self.assertIs(attributes.convert_to_boolean(0), False)
     self.assertIs(attributes.convert_to_boolean(1), True)
     self.assertRaises(n_exc.InvalidInput,
                       attributes.convert_to_boolean,
                       7)
开发者ID:glove747,项目名称:liberty-neutron,代码行数:6,代码来源:test_attributes.py

示例5: test_convert_to_boolean_bool

 def test_convert_to_boolean_bool(self):
     self.assertIs(attributes.convert_to_boolean(True), True)
     self.assertIs(attributes.convert_to_boolean(False), False)
开发者ID:glove747,项目名称:liberty-neutron,代码行数:3,代码来源:test_attributes.py

示例6: convert_to_boolean_if_not_none

def convert_to_boolean_if_not_none(data):
    if data is not None:
        return attributes.convert_to_boolean(data)
    return data
开发者ID:yuhui7red,项目名称:neutron,代码行数:4,代码来源:distributedrouter.py

示例7: update

 def update(self, request, id, **kwargs):
     context = request.context
     self._check_admin(context)
     body = validators.validate_request(request)
     key_list = ['access_protocol', 'access_parameters',
                 'enable', 'rediscover']
     validators.validate_attributes(body.keys(), key_list)
     validate_snmp_creds = False
     phys_switch = db.get_bnp_phys_switch(context, id)
     if not phys_switch:
         raise webob.exc.HTTPNotFound(
             _("Switch %s does not exist") % id)
     if body.get('access_parameters'):
         validate_snmp_creds = True
         access_parameters = body.pop("access_parameters")
         for key, value in access_parameters.iteritems():
             body[key] = value
     else:
         access_parameters = {
             'write_community': phys_switch['write_community'],
             'security_name': phys_switch['security_name'],
             'auth_protocol': phys_switch['auth_protocol'],
             'priv_protocol': phys_switch['priv_protocol'],
             'auth_key': phys_switch['auth_key'],
             'priv_key': phys_switch['priv_key'],
             'security_level': phys_switch['security_level']}
     if body.get('access_protocol'):
         validate_snmp_creds = True
         protocol = body['access_protocol']
         if protocol.lower() not in const.SUPPORTED_PROTOCOLS:
             raise webob.exc.HTTPBadRequest(
                 _("access protocol %s is not supported") % body[
                     'access_protocol'])
     else:
         protocol = phys_switch['access_protocol']
     switch_dict = self._update_dict(body, dict(phys_switch))
     switch_to_show = self._switch_to_show(switch_dict)
     switch = switch_to_show[0]
     if validate_snmp_creds:
         if protocol.lower() == const.SNMP_V3:
             validators.validate_snmpv3_parameters(access_parameters)
         else:
             validators.validate_snmp_parameters(access_parameters)
         try:
             snmp_driver = discovery_driver.SNMPDiscoveryDriver(switch_dict)
             snmp_driver.get_sys_name()
             db.update_bnp_phys_switch_access_params(context,
                                                     id, switch_dict)
         except Exception as e:
             LOG.error(_LE("Exception in validating credentials '%s' "), e)
             raise webob.exc.HTTPBadRequest(
                 _("Validation of credentials failed"))
     if body.get('enable'):
         enable = attributes.convert_to_boolean(body['enable'])
         if not enable:
             switch_status = const.SWITCH_STATUS['disable']
             db.update_bnp_phys_switch_status(context, id, switch_status)
         else:
             switch_status = const.SWITCH_STATUS['enable']
             db.update_bnp_phys_switch_status(context, id, switch_status)
         switch['status'] = switch_status
     if body.get('rediscover'):
         bnp_switch = self._discover_switch(switch_dict)
         db_switch_ports = db.get_bnp_phys_switch_ports_by_switch_id(
             context, id)
         self._update_switch_ports(context, id,
                                   bnp_switch.get('ports'),
                                   db_switch_ports)
     return switch
开发者ID:neethi209,项目名称:baremetal-network-provisioning,代码行数:69,代码来源:bnp_switch.py


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