openstack security group and rules python api use
nova和neutron都可以,但是感觉还是用neutron好。
import neutronclient.v2_0.client as neclient
neutron = neclient.Client(username='admin',password='password',tenant_name='admin',auth_url='http://ip:5000/v2.0')
s1 = neutron.create_security_group(body={'security_group':{'name':'block'}})
for r in s1['security_group']['security_group_rules']:
neutron.delete_security_group_rule(security_group_rule=r['id'])
sgs = neutron.list_security_groups()['security_groups']
s2 = ''
for sg in sgs:
if sg['name']=='block':
s2 = sg
break
if s2!='':
neutron.create_security_group_rule(body={"security_group_rule": {
"direction": "ingress",
"ethertype": "IPv4",
"protocol": None,
"remote_ip_prefix":"192.168.0.0/16",
"security_group_id":s2['id'] }
})
neutron.create_security_group_rule(body={"security_group_rule": {
"direction": "egress",
"ethertype": "IPv4",
"protocol": None,
"remote_ip_prefix":"192.168.0.0/16",
"security_group_id":s2['id'] }
})
文档感觉很low,去binding python的文档看neutron的简直想死 http://docs.openstack.org/developer/python-neutronclient/ 。。。只能去看源码
看参数还是得去看原生api http://developer.openstack.org/api-ref-networking-v2-ext.html
openstack security group and rules python api use的更多相关文章
- Neutron 理解 (8): Neutron 是如何实现虚机防火墙的 [How Neutron Implements Security Group]
学习 Neutron 系列文章: (1)Neutron 所实现的虚拟化网络 (2)Neutron OpenvSwitch + VLAN 虚拟网络 (3)Neutron OpenvSwitch + GR ...
- Neutron 理解 (9): OpenStack 是如何实现 Neutron 网络 和 Nova虚机 防火墙的 [How Nova Implements Security Group and How Neutron Implements Virtual Firewall]
学习 Neutron 系列文章: (1)Neutron 所实现的虚拟化网络 (2)Neutron OpenvSwitch + VLAN 虚拟网络 (3)Neutron OpenvSwitch + GR ...
- Openstack python api 学习文档 api创建虚拟机
Openstack python api 学习文档 转载请注明http://www.cnblogs.com/juandx/p/4953191.html 因为需要学习使用api接口调用openstack ...
- Python API:openstack
OpenStack 是一个越来越流行的.用于部署基础架构即服务 (IaaS) 云的开源解决方案.OpenStack 附带了一个仪表板 Web 应用程序,非常适合执行手动任务,比如启动单个虚拟机 (VM ...
- 在OpenStack中绕过或停用security group (iptables)
眼下.OpenStack中默认採用了security group的方式.用系统的iptables来过滤进入vm的流量.这个本意是为了安全,可是往往给调试和开发带来一些困扰. 因此,暂时性的禁用它能够排 ...
- 如何在 Apache Flink 中使用 Python API?
本文根据 Apache Flink 系列直播课程整理而成,由 Apache Flink PMC,阿里巴巴高级技术专家 孙金城 分享.重点为大家介绍 Flink Python API 的现状及未来规划, ...
- Appium python API 总结
Appium python api 根据testerhome的文章,再补充一些文章里面没有提及的API [TOC] [1]find element driver 的方法 注意:这几个方法只能通过sel ...
- The novaclient Python API
The novaclient Python API Usage First create a client instance with your credentials: >>> f ...
- BotVS开发基础—Python API
代码 import json def main(): # python API列表 https://www.botvs.com/bbs-topic/443 #状态信息 LogStatus(" ...
随机推荐
- 关于.net页面提交后css样式不生效的发现
一直以来没有解决的问题,今天在老师的提示下终于得到解决. 问题:asp.net页面,提交后,或者举例最简单的例子通俗的说,当登陆页面,某一项输入错误,并且使用Response.Write(" ...
- SQL如何增删修改字段
1: 新增字段: ) NULL EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'土地手续办理情况' , @level ...
- Expression<Func<TObject, bool>>与Func<TObject, bool>的区别
Func<TObject, bool>是委托(delegate) Expression<Func<TObject, bool>>是表达式 Expression编译后 ...
- Android一个ListView列表之中插入两种不同的数据
http://www.cnblogs.com/roucheng/ Android一个ListView列表之中插入两种不同的数据 代码如下: public class ViewHolder{ Butto ...
- asp.net(c#)将彩色图片变灰阶图片
代码如下: using System; using System.Collections; using System.Configuration; using System.Data; using S ...
- Windows Server 2012中安装Active Directory域服务
1.登陆Windows Server 2012,打开服务器管理器,选择"添加角色和功能" 2.在"开始之前"页面,直接点击"下一步" 3.选 ...
- 暴风冯鑫:去美国香港的99%都亏,互联网公司打死都要回A股
“上市之后,我回答得最多的两句话:一句是运气好:另一句是有好运气要好好地使用它.” 5月18日,暴风科技上市55天后,首享科技大厦办公室里,暴风科技CEO冯鑫这样对我说. 在经历了36个涨停之 ...
- Win10 IoT C#开发 1 - Raspberry安装IoT系统及搭建开发环境
Windows 10 IoT Core 是微软针对物联网市场的一个重要产品,与以往的Windows版本不同,是为物联网设备专门设计的,硬件也不仅仅限于x86架构,同时可以在ARM架构上运行. The ...
- Error Code: 1175.You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column.
在MySQL Workbench里面使用SQL语句: delete from 表名 提示出错: Error Code: 1175.You are using safe update mode and ...
- js中实现中文按字母拼音排序
js中实现中文按字母拼音排序 var Pinyin = (function (){ var Pinyin = function (ops){ this.initialize(ops); }, opti ...