OpenStack security group and rules Python API use

Source: Internet
Author: User

Nova and neutron are OK, but still feel good with 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 breakif s2!= ': Neutron.crea                        Te_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 '} })

  

The document feels very low, go to binding Python document to see Neutron's simply want to die http://docs.openstack.org/developer/python-neutronclient/... Only to see the source code

To see the parameters or to see the native API http://developer.openstack.org/api-ref-networking-v2-ext.html

OpenStack security group and rules Python API use

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.