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


Python Client.show_security_group方法代码示例

本文整理汇总了Python中neutronclient.v2_0.client.Client.show_security_group方法的典型用法代码示例。如果您正苦于以下问题:Python Client.show_security_group方法的具体用法?Python Client.show_security_group怎么用?Python Client.show_security_group使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在neutronclient.v2_0.client.Client的用法示例。


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

示例1: NetworkSecurityGroup

# 需要导入模块: from neutronclient.v2_0.client import Client [as 别名]
# 或者: from neutronclient.v2_0.client.Client import show_security_group [as 别名]

#.........这里部分代码省略.........
			time.sleep(5)
			if timeout < time.time():
				raise Exception("Timeout!")
			status = self.novacl.servers.get(self.server_id).status
		if status != "ACTIVE":
			raise Exception("Failed to boot honeypot. Status is " + status + ". Please look at Openstack logs for more info.")
		print("Honeypot ready")
		return inputData


	def createFloatingIp(self,inputData):
		self.floating_ip = self.novacl.floating_ips.create(pool=self.testinstances['DeployHoneypot']['FloatingIPPool'])
		print("Created floating ip")
		return inputData

	def deleteFloatingIp(self,inputData):
		self.novacl.floating_ips.delete(self.floating_ip)
		print("Deleted floating ip")
		return inputData


	def attachFloatingIp(self,inputData):
		time.sleep(5)
		self.novacl.servers.get(self.server_id).add_floating_ip(self.floating_ip)
		return inputData
	def deattachFloatingIp(self,inputData):
		self.novacl.servers.get(self.server_id).remove_floating_ip(self.floating_ip)
		return inputData

	def parseSecurityGroup(self,inputData):
		allSecurityGroups = self.novacl.servers.get(self.server_id).list_security_group()
		allSecurityGroups_details = []
		for sg in allSecurityGroups:
			allSecurityGroups_details.append(self.neucl.show_security_group(str(sg)))
		print(allSecurityGroups_details)
		dict_tcp = {}
		dict_udp = {}
		list_tcp = []
		list_udp = []
		icmp = 0
		for sg in allSecurityGroups_details:
			for rule in sg['security_group']['security_group_rules']:
				if rule["direction"] == "ingress":
					if rule["protocol"] == "icmp":
						icmp = 1 if icmp == 0 else icmp

					elif rule["port_range_min"] and rule["port_range_max"]:
						for i in range(rule["port_range_min"],rule["port_range_max"]+1):
							if self.testinstances["Configuration"]["CheckTCP"] and rule["protocol"] == "tcp" and i >= int(self.testinstances["Configuration"]["TCPMinPort"]) and i <= int(self.testinstances["Configuration"]["TCPMaxPort"]):
								dict_tcp[i] = 1
							if self.testinstances["Configuration"]["CheckUDP"] and rule["protocol"] == "udp" and i >= int(self.testinstances["Configuration"]["UDPMinPort"]) and i <= int(self.testinstances["Configuration"]["UDPMaxPort"]):
								dict_udp[i] = 1
		if self.testinstances["Configuration"]["CheckTCP"]:
			print("Parsed TCP:")
			print(dict_tcp)
		if self.testinstances["Configuration"]["CheckUDP"]:
			print("Parsed UDP:")
			print dict_udp

		return icmp, dict_tcp, dict_udp

	def doRealScan(self,inputData):
		time.sleep(120)
		icmp_flag, dict_tcp, dict_udp = inputData
		def do_scan(target,options):
			command = ["/usr/bin/nmap", "-oX", "-"] + options + [str(target)]
开发者ID:SESARLab,项目名称:mooncloud_probe_OSsg,代码行数:70,代码来源:network_security_group.py


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