本文整理汇总了Python中qingcloud.misc.utils.filter_out_none函数的典型用法代码示例。如果您正苦于以下问题:Python filter_out_none函数的具体用法?Python filter_out_none怎么用?Python filter_out_none使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了filter_out_none函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: modify_loadbalancer_backend_attributes
def modify_loadbalancer_backend_attributes(self, loadbalancer_backend,
loadbalancer_backend_name=None,
port=None,
weight=None,
disabled=None,
**ignore):
""" Modify load balancer backend attributes.
@param loadbalancer_backend: the ID of backend.
@param loadbalancer_backend_name: the name of the backend.
@param port: backend server listen port.
@param weight: backend server weight, valid range is from 1 to 100.
"""
action = const.ACTION_MODIFY_LOADBALANCER_BACKEND_ATTRIBUTES
valid_keys = ['loadbalancer_backend', 'loadbalancer_backend_name',
'port', 'weight', 'disabled']
body = filter_out_none(locals(), valid_keys)
if not self.conn.req_checker.check_params(body,
required_params=[
'loadbalancer_backend'],
integer_params=[
'port', 'weight', 'disabled'],
list_params=[]
):
return None
if 'port' in body:
self.conn.req_checker.check_lb_backend_port(body['port'])
if 'weight' in body:
self.conn.req_checker.check_lb_backend_weight(body['weight'])
return self.conn.send_request(action, body)
示例2: describe_clusters
def describe_clusters(self, clusters=None,
role=None,
status=None,
verbose=1,
search_word=None,
owner=None,
offset=None,
limit=None,
tags=None,
**ignore):
""" Describe clusters filtered by condition.
@param clusters: the array of cluster IDs.
@param status: pending, active, stopped, deleted, suspended, ceased
@param verbose: the number to specify the verbose level, larger the number, the more detailed information will be returned.
@param search_word: search word column.
@param offset: the starting offset of the returning results.
@param limit: specify the number of the returning results.
@param tags : the array of IDs of tags.
"""
action = const.ACTION_DESCRIBE_CLUSTERS
valid_keys = ['clusters', 'status', 'verbose', 'search_word',
'owner', 'offset', 'limit', 'tags', 'role']
body = filter_out_none(locals(), valid_keys)
if not self.conn.req_checker.check_params(body,
required_params=[],
integer_params=[
'offset', 'limit'],
list_params=[
'clusters', 'status', 'tags']
):
return None
return self.conn.send_request(action, body)
示例3: modify_alarm_policy_rule_attributes
def modify_alarm_policy_rule_attributes(self, alarm_policy_rule,
condition_type,
thresholds=None,
alarm_policy_rule_name=None,
data_processor=None,
consecutive_periods=None,
**ignore):
""" Modify alarm policy rule attributes.
@param alarm_policy_rule: the ID of the alarm policy rule whose content you
want to update.
@param condition_type: gt for greater than, lt for less than.
@param thresholds: the thresholds of alarm.
@param alarm_policy_rule_name: the name of the alarm policy rule.
@param data_processor: raw for use the monitoring data raw value, percent only for IP bandwidth monitoring.
@param consecutive_periods: during several consecutive inspection periods, the monitoring data reaches the alarm threshold,
then will trigger the alarm behavior.
"""
action = const.ACTION_MODIFY_ALARM_POLICY_RULE_ATTRIBUTES
valid_keys = ['alarm_policy_rule', 'condition_type', 'thresholds',
'alarm_policy_rule_name', 'data_processor', 'consecutive_periods']
body = filter_out_none(locals(), valid_keys)
if not self.req_checker.check_params(body,
required_params=['alarm_policy_rule', 'condition_type']
):
return None
return self.send_request(action, body)
示例4: describe_vxnets
def describe_vxnets(self, vxnets=None,
search_word=None,
verbose=0,
owner=None,
limit=None,
offset=None,
tags=None,
vxnet_type=None,
mode=None,
**ignore):
""" Describe vxnets filtered by condition.
@param vxnets: the IDs of vxnets you want to describe.
@param verbose: the number to specify the verbose level, larger the number, the more detailed information will be returned.
@param offset: the starting offset of the returning results.
@param limit: specify the number of the returning results.
@param tags : the array of IDs of tags.
@param vxnet_type: the vxnet of type you want to describe.
@param mode: the vxnet mode. 0: gre+ovs, 1: vxlan+bridge.
"""
action = const.ACTION_DESCRIBE_VXNETS
valid_keys = ['vxnets', 'search_word', 'verbose', 'limit', 'offset',
'tags', 'vxnet_type', 'owner', 'mode']
body = filter_out_none(locals(), valid_keys)
if not self.conn.req_checker.check_params(body,
required_params=[],
integer_params=[
'limit', 'offset', 'verbose',
'vxnet_type', 'mode',
],
list_params=['vxnets', 'tags']
):
return None
return self.conn.send_request(action, body)
示例5: resize_instances
def resize_instances(self, instances,
instance_type=None,
cpu=None,
memory=None,
os_disk_size=None,
**ignore):
""" Resize one or more instances
@param instances: the IDs of the instances you want to resize.
@param instance_type: defined by qingcloud.
See: https://docs.qingcloud.com/api/common/includes/instance_type.html
@param cpu: cpu core number.
@param memory: memory size in MB.
@param os_disk_size: operation system disk size in GB.
"""
action = const.ACTION_RESIZE_INSTANCES
valid_keys = ['instances', 'instance_type', 'cpu', 'memory', 'os_disk_size']
body = filter_out_none(locals(), valid_keys)
if not self.conn.req_checker.check_params(body,
required_params=['instances'],
integer_params=['cpu', 'memory', 'os_disk_size'],
list_params=['instances']
):
return None
return self.conn.send_request(action, body)
示例6: describe_security_group_ipsets
def describe_security_group_ipsets(self,
security_group_ipsets=None,
ipset_type=None,
security_group_ipset_name=None,
offset=None,
limit=None,
**ignore):
""" Describe security group ipsets filtered by condition.
@param security_group_ipsets: the ID of the security group ipsets.
@param ipset_type: 0 for ip; 1 for port
@param security_group_ipset_name: filter by name
@param offset: the starting offset of the returning results.
@param limit: specify the number of the returning results.
"""
action = const.ACTION_DESCRIBE_SECURITY_GROUP_IPSETS
valid_keys = ['security_group_ipsets', 'ipset_type',
'security_group_ipset_name',
'offset', 'limit']
body = filter_out_none(locals(), valid_keys)
if not self.conn.req_checker.check_params(body,
required_params=[],
integer_params=[
'ipset_type', 'offset', 'limit'],
list_params=[
'security_group_rules']
):
return None
return self.conn.send_request(action, body)
示例7: modify_security_group_attributes
def modify_security_group_attributes(self, security_group,
security_group_name=None,
description=None,
**ignore):
""" Modify security group attributes.
@param security_group: the ID of the security group whose content you
want to update.
@param security_group_name: the new group name you want to update.
@param description: The detailed description of the resource.
"""
action = const.ACTION_MODIFY_SECURITY_GROUP_ATTRIBUTES
valid_keys = ['security_group', 'security_group_name', 'description']
body = filter_out_none(locals(), valid_keys)
body['security_group'] = security_group
if not self.conn.req_checker.check_params(body,
required_params=[
'security_group'],
integer_params=[],
list_params=[]
):
return None
if not self.conn.req_checker.check_sg_rules(body.get('rules', [])):
return None
return self.conn.send_request(action, body)
示例8: modify_s2_shared_target_attributes
def modify_s2_shared_target_attributes(self,
shared_target,
operation,
parameters=None,
initiator_names=None,
s2_group=None,
export_name=None,
**ignore):
""" Modify S2 shared target attributes
:param shared_target: the ID of shared target.
:param operation: valid values includes add, modify, delete, set.
:param parameters: please refer https://docs.qingcloud.com/api/s2/describle_s2_default_parameters.html
:param initiator_names: client IQN.
:param s2_group: the ID of permission group.
:param export_name: the name of shared target, available in vnas.
"""
action = const.ACTION_MODIFY_S2_SHARED_TARGET
valid_keys = [
'shared_target', 'operation', 'parameters',
'initiator_names', 's2_group', 'export_name',
]
body = filter_out_none(locals(), valid_keys)
if not self.conn.req_checker.check_params(
body,
list_params=["initiator_names", "parameters"],
):
return None
return self.conn.send_request(action, body)
示例9: describe_s2_default_parameters
def describe_s2_default_parameters(self,
service_type=None,
target_type=None,
offset=None,
limit=None,
**ignore):
""" Describe S2 default parameters
:param service_type: valid values is vsan or vnas.
:param target_type: valid values is ISCSI, FCoE, NFS or SMB.
:param offset: the starting offset of the returning results.
:param limit: specify the number of the returning results.
"""
action = const.ACTION_DESCRIBE_S2_DEFAULT_PARAMETERS
valid_keys = [
'service_type', 'target_type', 'offset', 'limit',
]
body = filter_out_none(locals(), valid_keys)
if not self.conn.req_checker.check_params(
body,
integer_params=['offset', 'limit'],
):
return None
return self.conn.send_request(action, body)
示例10: create_s2_server
def create_s2_server(self,
vxnet,
service_type,
s2_server_name=None,
s2_server_type=None,
private_ip=None,
description=None,
s2_class=None,
**ignore):
""" Create S2 server
:param vxnet: the ID of vxnet.
:param service_type: valid values is vsan or vnas.
:param s2_server_name: the name of s2 server.
:param s2_server_type: valid values includes 0, 1, 2, 3.
:param private_ip: you may specify the ip address of this server.
:param description: the detailed description of the resource.
:param s2_class: valid values includes 0, 1.
"""
action = const.ACTION_CREATE_S2_SERVER
valid_keys = [
'vxnet', 'service_type', 's2_server_name', 's2_server_type',
'private_ip', 'description', 's2_class',
]
body = filter_out_none(locals(), valid_keys)
if not self.conn.req_checker.check_params(
body,
integer_params=["s2_server_type", "s2_class"],
):
return None
return self.conn.send_request(action, body)
示例11: describe_s2_shared_targets
def describe_s2_shared_targets(self,
shared_targets=None,
target_types=None,
s2_server_id=None,
export_name=None,
search_word=None,
verbose=None,
offset=None,
limit=None,
**ignore):
""" Describe S2 servers
:param shared_targets: the IDs of shared targets.
:param target_types: valid values includes 'ISCSI', 'FCoE','NFS' and 'SMB'.
:param s2_server_id: the ID of s2 server.
:param export_name: the name of shared target.
:param search_word: you may use this field to search from export_name or description.
:param verbose: the number to specify the verbose level, larger the number, the more detailed information will be returned.
:param offset: the starting offset of the returning results.
:param limit: specify the number of the returning results.
"""
action = const.ACTION_DESCRIBE_S2_SHARED_TARGETS
valid_keys = [
'shared_targets', 'target_types', 's2_server_id', 'export_name',
'search_word', 'verbose', 'offset', 'limit',
]
body = filter_out_none(locals(), valid_keys)
if not self.conn.req_checker.check_params(
body,
integer_params=["limit", "offset", "verbose"],
list_params=["shared_targets", "target_types"],
):
return None
return self.conn.send_request(action, body)
示例12: create_s2_shared_target
def create_s2_shared_target(self,
s2_server_id,
export_name,
target_type,
description=None,
volumes=None,
initiator_names=None,
**ignore):
""" Create S2 shared target
:param s2_server_id: the ID of s2 server.
:param export_name: the name of shared target.
:param target_type: valid values includes 'ISCSI', 'FCoE','NFS' and 'SMB'.
:param description: the detailed description of the resource.
:param volumes: the IDs of volumes will be attached as backstore.
:param initiator_names: specify client IQN, available in vsan.
"""
action = const.ACTION_CREATE_S2_SHARED_TARGET
valid_keys = [
's2_server_id', 'export_name', 'target_type',
'description', 'volumes', 'initiator_names',
]
body = filter_out_none(locals(), valid_keys)
if not self.conn.req_checker.check_params(
body,
list_params=['volumes', 'initiator_names'],
):
return None
return self.conn.send_request(action, body)
示例13: create_loadbalancer
def create_loadbalancer(self,
eips=None,
loadbalancer_name=None,
security_group=None,
node_count=None,
loadbalancer_type=const.LB_TYPE_MAXCONN_5k,
vxnet=None,
private_ip=None,
target_user=None,
**ignore):
""" Create new load balancer.
@param eips: the IDs of the eips that will be associated to load balancer.
@param loadbalancer_name: the name of the loadbalancer.
@param security_group: the id of the security_group you want to apply to loadbalancer,
use `default security` group as default.
@param target_user: ID of user who will own this resource, should be one of your sub-accounts
"""
action = const.ACTION_CREATE_LOADBALANCER
valid_keys = ['eips', 'loadbalancer_name', 'loadbalancer_type',
'security_group', 'node_count', 'vxnet', 'private_ip',
'target_user',
]
body = filter_out_none(locals(), valid_keys)
if not self.conn.req_checker.check_params(body,
required_params=[],
integer_params=['node_count'],
list_params=['eips']
):
return None
return self.conn.send_request(action, body)
示例14: describe_loadbalancer_policies
def describe_loadbalancer_policies(self, loadbalancer_policies=None,
verbose=0,
offset=None,
limit=None,
**ignore):
""" Describe load balancer policies.
@param loadbalancer_policies: filter by load balancer policy ID.
@param verbose: the number to specify the verbose level, larger the number, the more detailed information will be returned.
@param offset: the starting offset of the returning results.
@param limit: specify the number of the returning results.
"""
action = const.ACTION_DESCRIBE_LOADBALANCER_POLICIES
valid_keys = ['loadbalancer_policies',
'verbose', 'offset', 'limit']
body = filter_out_none(locals(), valid_keys)
if not self.conn.req_checker.check_params(body,
required_params=[],
integer_params=['offset', 'limit'],
list_params=['loadbalancer_policies']
):
return None
return self.conn.send_request(action, body)
示例15: add_security_group_rules
def add_security_group_rules(self, security_group,
rules,
target_user=None,
**ignore):
""" Add rules to security group.
@param security_group: the ID of the security group whose rules you
want to add.
@param rules: a list of rules you want to add,
can be created by SecurityGroupRuleFactory.
@param target_user: ID of user who will own this resource, should be one of your sub-accounts
"""
action = const.ACTION_ADD_SECURITY_GROUP_RULES
valid_keys = ['security_group', 'rules', 'target_user']
body = filter_out_none(locals(), valid_keys)
if not self.conn.req_checker.check_params(body,
required_params=[
'security_group', 'rules'],
integer_params=[],
list_params=['rules']
):
return None
if not self.conn.req_checker.check_sg_rules(body.get('rules', [])):
return None
return self.conn.send_request(action, body)