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的更多相关文章

  1. Neutron 理解 (8): Neutron 是如何实现虚机防火墙的 [How Neutron Implements Security Group]

    学习 Neutron 系列文章: (1)Neutron 所实现的虚拟化网络 (2)Neutron OpenvSwitch + VLAN 虚拟网络 (3)Neutron OpenvSwitch + GR ...

  2. 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 ...

  3. Openstack python api 学习文档 api创建虚拟机

    Openstack python api 学习文档 转载请注明http://www.cnblogs.com/juandx/p/4953191.html 因为需要学习使用api接口调用openstack ...

  4. Python API:openstack

    OpenStack 是一个越来越流行的.用于部署基础架构即服务 (IaaS) 云的开源解决方案.OpenStack 附带了一个仪表板 Web 应用程序,非常适合执行手动任务,比如启动单个虚拟机 (VM ...

  5. 在OpenStack中绕过或停用security group (iptables)

    眼下.OpenStack中默认採用了security group的方式.用系统的iptables来过滤进入vm的流量.这个本意是为了安全,可是往往给调试和开发带来一些困扰. 因此,暂时性的禁用它能够排 ...

  6. 如何在 Apache Flink 中使用 Python API?

    本文根据 Apache Flink 系列直播课程整理而成,由 Apache Flink PMC,阿里巴巴高级技术专家 孙金城 分享.重点为大家介绍 Flink Python API 的现状及未来规划, ...

  7. Appium python API 总结

    Appium python api 根据testerhome的文章,再补充一些文章里面没有提及的API [TOC] [1]find element driver 的方法 注意:这几个方法只能通过sel ...

  8. The novaclient Python API

    The novaclient Python API Usage First create a client instance with your credentials: >>> f ...

  9. BotVS开发基础—Python API

    代码 import json def main(): # python API列表 https://www.botvs.com/bbs-topic/443 #状态信息 LogStatus(" ...

随机推荐

  1. c++控制台程序实现定时器

    #include "stdafx.h" #include <iostream> #include <Windows.h> using namespace s ...

  2. C#编程总结(三)线程同步

    C#编程总结(三)线程同步 在应用程序中使用多个线程的一个好处是每个线程都可以异步执行.对于 Windows 应用程序,耗时的任务可以在后台执行,而使应用程序窗口和控件保持响应.对于服务器应用程序,多 ...

  3. SqlServer中的自增的ID的最后的值:

    SqlServer中的自增的ID的最后的值: SELECT SCOPE_IDENTITY() --返回插入到同一作用域中的 IDENTITY 列内的最后一个 IDENTITY 值.SELECT @@I ...

  4. 速战速决 (3) - PHP: 函数基础, 函数参数, 函数返回值, 可变函数, 匿名函数, 闭包函数, 回调函数

    [源码下载] 速战速决 (3) - PHP: 函数基础, 函数参数, 函数返回值, 可变函数, 匿名函数, 闭包函数, 回调函数 作者:webabcd 介绍速战速决 之 PHP 函数基础 函数参数 函 ...

  5. 通过python将图片生成字符画

    基础知识: 1.python基础知识   快速学习链接:https://www.shiyanlou.com/courses/214 2.linux命令行操作   快速学习链接:https://www. ...

  6. collection中的retainAll()方法

    public class ArraylistDemo { public static void main(String[] args) { Collection list1 = new ArrayLi ...

  7. java集合-LinkedList

    一.概述 LinkedList 与 ArrayList 一样实现 List 接口,只是 ArrayList 是 List 接口的大小可变数组的实现,LinkedList 是 List 接口链表的实现. ...

  8. BeforeProperties/AfterProperties in Event Receivers

    Sharepoint List List BeforeProperties AfterProperties properties.ListItem ItemAdding No Value No Val ...

  9. jQuery+turn.js翻书、文档和杂志3种特效演示

    很好用的一款插件jQuery+turn.js翻书.文档和杂志3种特效演示 在线预览 下载地址 实例代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML ...

  10. Oracle EBS Form Builder使用Java beans创建窗体

    最近有个项目,需要研究一下Oracle的E-Business Sutie(EBS),对于以前没接触此套件的我来说,简直太痛苦了.在网上找了一堆资料,试着进行Form二次开发,也遇到各类奇葩问题.目前遇 ...