novaclient.utils module¶
- novaclient.utils.add_arg(func, *args, **kwargs)¶
将 CLI 参数绑定到 shell.py 的 do_foo 函数。
- novaclient.utils.arg(*args, **kwargs)¶
CLI 参数的装饰器。
示例
>>> @arg("name", help="Name of the new entity") ... def entity_create(args): ... pass
- novaclient.utils.do_action_on_many(action, resources, success_msg, error_msg)¶
用于对多个资源执行操作的辅助函数。
- novaclient.utils.env(*args, **kwargs)¶
返回设置的第一个环境变量。
如果都为空,则默认为 ‘’ 或关键字参数 default。
- novaclient.utils.find_resource(manager, name_or_id, wrap_exception=True, **find_args)¶
用于 _find_* 方法的辅助函数。
- novaclient.utils.flatten_dict(data)¶
返回一个新的字典,其子字典已合并到原始字典中。每个父键都将附加到子键的前面,以防止冲突。任何字符串元素在展平之前都将进行 JSON 解析。
>>> flatten_dict({'service': {'host':'cloud9@compute-068', 'id': 143}}) {'service_host': colud9@compute-068', 'service_id': 143}
- novaclient.utils.format_security_groups(groups)¶
- novaclient.utils.format_servers_list_networks(server)¶
- novaclient.utils.get_service_type(f)¶
从函数中检索服务类型。
- novaclient.utils.get_url_with_filter(url, filters)¶
- novaclient.utils.is_integer_like(val)¶
返回一个值是否为整数的验证。
- novaclient.utils.isunauthenticated(func)¶
检查函数是否不需要身份验证。
使用 @unauthenticated 装饰器标记此类函数。
- 返回值:
bool
- novaclient.utils.make_field_formatter(attr, filters=None)¶
给定对象属性,返回格式化的字段名称和格式化程序,适合传递给 print_list。
可选地传递一个将属性名称映射到函数的字典。该函数将传递属性的值,并应返回要显示的字符串。
- novaclient.utils.prepare_query_string(params)¶
将字典参数转换为查询字符串
- novaclient.utils.pretty_choice_dict(values)¶
返回格式化的字典,格式为 ‘key=value’。
- novaclient.utils.pretty_choice_list(values)¶
- novaclient.utils.print_dict(d, dict_property='属性', dict_value='值', wrap=0)¶
- novaclient.utils.print_list(objs, fields, formatters={}, sortby_index=None)¶
- novaclient.utils.record_time(times, enabled, *args)¶
记录特定操作的时间。
- 参数:
times – 一个列表,保存时间数据。
enabled – 是否启用计时。
args – 除了时间数据之外要存储的其他数据,这些参数将连接成一个字符串。
- novaclient.utils.safe_issubclass(*args)¶
类似于 issubclass,但如果不是类,则只返回 False。
- novaclient.utils.service_type(stype)¶
将 ‘service_type’ 属性添加到装饰的函数中。
用法
@service_type('volume') def mymethod(f): ...
- novaclient.utils.unauthenticated(func)¶
将 ‘unauthenticated’ 属性添加到装饰的函数中。
用法
>>> @unauthenticated ... def mymethod(f): ... pass
- novaclient.utils.validate_flavor_metadata_keys(keys)¶