本文整理汇总了Python中cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider.delete_secgroup_rule方法的典型用法代码示例。如果您正苦于以下问题:Python CloudProvider.delete_secgroup_rule方法的具体用法?Python CloudProvider.delete_secgroup_rule怎么用?Python CloudProvider.delete_secgroup_rule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider
的用法示例。
在下文中一共展示了CloudProvider.delete_secgroup_rule方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_rule
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import delete_secgroup_rule [as 别名]
def delete_rule(cls, cloud, secgroup, from_port, to_port, protocol, cidr):
try:
args = {
"group": secgroup["uuid"],
"fromPort": from_port,
"toPort": to_port,
"protocol": protocol,
"cidr": cidr
}
rule = cls.cm.find(kind="secgrouprule",
output="object",
scope="first",
**args)
if rule is not None:
# get the nova client for cloud
cloud_provider = CloudProvider(cloud).provider
# delete the rule from the cloud
cloud_provider.delete_secgroup_rule(rule.uuid)
# delete the local db record
cls.cm.delete(rule)
return "Rule [{fromPort} | {toPort} | {protocol} | {cidr}] deleted" \
.format(**args)
else:
return None
except Exception as ex:
Console.error("delete rule")
return
示例2: delete_rule
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import delete_secgroup_rule [as 别名]
def delete_rule(cls, cloud, secgroup, from_port, to_port, protocol, cidr):
try:
args = {
"groupid": secgroup.uuid,
"fromPort": from_port,
"toPort": to_port,
"protocol": protocol,
"cidr": cidr
}
rule = cls.cm_db.find("secgrouprule", output="object",
**args).first()
if rule is not None:
# get the nova client for cloud
cloud_provider = CloudProvider(cloud).provider
# delete the rule from the cloud
cloud_provider.delete_secgroup_rule(rule.uuid)
# delete the local db record
cls.cm_db.delete(rule)
return "Rule [{} | {} | {} | {}] deleted" \
.format(from_port, to_port, protocol, cidr)
else:
return None
except Exception as ex:
Console.error(ex.message, ex)
return
示例3: delete_all_rules_cloud
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import delete_secgroup_rule [as 别名]
def delete_all_rules_cloud(cls, cloud, groupname):
rules = cls.list_rules_cloud(cloud, groupname)
provider = CloudProvider(cloud).provider
if rules:
for rule in rules:
ruleid = rule['id']
provider.delete_secgroup_rule(ruleid)
return
示例4: delete_all_rules_cloud
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import delete_secgroup_rule [as 别名]
def delete_all_rules_cloud(cls, cloud, groupname):
rules = cls.list_rules_cloud(cloud, groupname)
provider = CloudProvider(cloud).provider
if rules:
for rule in rules:
ruleid = rule['id']
# only refresh those defined with a protocol
# This leaves the default rule defined by
# allowing the same secgroup untouched
if rule['ip_protocol']:
provider.delete_secgroup_rule(ruleid)
return
示例5: delete_rule_cloud
# 需要导入模块: from cloudmesh_client.cloud.iaas.CloudProvider import CloudProvider [as 别名]
# 或者: from cloudmesh_client.cloud.iaas.CloudProvider.CloudProvider import delete_secgroup_rule [as 别名]
def delete_rule_cloud(cls, cloud, groupname, rulename):
ret = None
provider = CloudProvider(cloud).provider
ruleid = cls.get_rule_cloud(cloud, groupname, rulename)
if ruleid:
ret = provider.delete_secgroup_rule(ruleid)
#else:
# Console.error("Rule does not exist - Rule:{}, Group:{}"\
# .format(rulename, groupname), traceflag=False)
return ret