Module for handling OpenStack Neutron calls
neutronclient Python module
This module is not usable until the user, password, tenant, and auth URL are specified either in a pillar or in the minion's config file. For example:
keystone.user: 'admin'
keystone.password: 'password'
keystone.tenant: 'admin'
keystone.auth_url: 'http://127.0.0.1:5000/v2.0/'
keystone.region_name: 'RegionOne'
keystone.service_type: 'network'
If configuration for multiple OpenStack accounts is required, they can be set up as different configuration profiles: For example:
openstack1:
keystone.user: 'admin'
keystone.password: 'password'
keystone.tenant: 'admin'
keystone.auth_url: 'http://127.0.0.1:5000/v2.0/'
keystone.region_name: 'RegionOne'
keystone.service_type: 'network'
openstack2:
keystone.user: 'admin'
keystone.password: 'password'
keystone.tenant: 'admin'
keystone.auth_url: 'http://127.0.0.2:5000/v2.0/'
keystone.region_name: 'RegionOne'
keystone.service_type: 'network'
With this configuration in place, any of the neutron functions can make use of a configuration profile by declaring it explicitly. For example:
salt '*' neutron.network_list profile=openstack1
To use keystoneauth1 instead of keystoneclient, include the use_keystoneauth option in the pillar or minion config.
Note
this is required to use keystone v3 as for authentication.
keystone.user: admin
keystone.password: verybadpass
keystone.tenant: admin
keystone.auth_url: 'http://127.0.0.1:5000/v3/'
keystone.region_name: 'RegionOne'
keystone.service_type: 'network'
keystone.use_keystoneauth: true
keystone.verify: '/path/to/custom/certs/ca-bundle.crt'
Note: by default the neutron module will attempt to verify its connection utilizing the system certificates. If you need to verify against another bundle of CA certificates or want to skip verification altogether you will need to specify the verify option. You can specify True or False to verify (or not) against system certificates, a path to a bundle or CA certs to check against, or None to allow keystoneauth to search for the certificates on its own.(defaults to True)
Adds an external network gateway to the specified router
CLI Example:
salt '*' neutron.add_gateway_router router-name ext-network-name
router -- ID or name of the router
ext_network -- ID or name of the external network the gateway
profile -- Profile to build on (Optional)
Added Gateway router information
Adds an internal network interface to the specified router
CLI Example:
salt '*' neutron.add_interface_router router-name subnet-name
router -- ID or name of the router
subnet -- ID or name of the subnet
profile -- Profile to build on (Optional)
Added interface information
Creates a new firewall rule
CLI Example:
salt '*' neutron.create_firewall_rule protocol action
tenant_id=TENANT_ID name=NAME description=DESCRIPTION ip_version=IP_VERSION
source_ip_address=SOURCE_IP_ADDRESS destination_ip_address=DESTINATION_IP_ADDRESS source_port=SOURCE_PORT
destination_port=DESTINATION_PORT shared=SHARED enabled=ENABLED
protocol -- Protocol for the firewall rule, choose "tcp","udp","icmp" or "None".
action -- Action for the firewall rule, choose "allow" or "deny".
tenant_id -- The owner tenant ID. (Optional)
name -- Name for the firewall rule. (Optional)
description -- Description for the firewall rule. (Optional)
ip_version -- IP protocol version, default: 4. (Optional)
source_ip_address -- Source IP address or subnet. (Optional)
destination_ip_address -- Destination IP address or subnet. (Optional)
source_port -- Source port (integer in [1, 65535] or range in a:b). (Optional)
destination_port -- Destination port (integer in [1, 65535] or range in a:b). (Optional)
shared -- Set shared to True, default: False. (Optional)
enabled -- To enable this rule, default: True. (Optional)
Creates a new floatingIP
CLI Example:
salt '*' neutron.create_floatingip network-name port-name
floating_network -- Network name or ID to allocate floatingIP from
port -- Of the port to be associated with the floatingIP (Optional)
profile -- Profile to build on (Optional)
Created floatingIP information
Creates a new IKEPolicy
CLI Example:
salt '*' neutron.create_ikepolicy ikepolicy-name
phase1_negotiation_mode=main auth_algorithm=sha1
encryption_algorithm=aes-128 pfs=group5
name -- Name of the IKE policy
phase1_negotiation_mode -- IKE Phase1 negotiation mode in lowercase, default: main (Optional)
auth_algorithm -- Authentication algorithm in lowercase, default: sha1 (Optional)
encryption_algorithm -- Encryption algorithm in lowercase. default:aes-128 (Optional)
pfs -- Prefect Forward Security in lowercase, default: group5 (Optional)
units -- IKE lifetime attribute. default: seconds (Optional)
value -- IKE lifetime attribute. default: 3600 (Optional)
ike_version -- IKE version in lowercase, default: v1 (Optional)
profile -- Profile to build on (Optional)
kwargs --
Created IKE policy information
Creates a new IPsecSiteConnection
CLI Example:
salt '*' neutron.show_ipsec_site_connection connection-name
ipsec-policy-name ikepolicy-name vpnservice-name
192.168.XXX.XXX/24 192.168.XXX.XXX 192.168.XXX.XXX secret
name -- Set friendly name for the connection
ipsecpolicy -- IPSec policy ID or name associated with this connection
ikepolicy -- IKE policy ID or name associated with this connection
vpnservice -- VPN service instance ID or name associated with this connection
peer_cidrs -- Remote subnet(s) in CIDR format
peer_address -- Peer gateway public IPv4/IPv6 address or FQDN
peer_id -- Peer router identity for authentication Can be IPv4/IPv6 address, e-mail address, key id, or FQDN
psk -- Pre-shared key string
initiator -- Initiator state in lowercase, default:bi-directional
admin_state_up -- Set admin state up to true or false, default: True (Optional)
mtu -- size for the connection, default:1500 (Optional)
dpd_action -- Dead Peer Detection attribute: hold/clear/disabled/ restart/restart-by-peer (Optional)
dpd_interval -- Dead Peer Detection attribute (Optional)
dpd_timeout -- Dead Peer Detection attribute (Optional)
profile -- Profile to build on (Optional)
Created IPSec site connection information
Creates a new IPsecPolicy
CLI Example:
salt '*' neutron.create_ipsecpolicy ipsecpolicy-name
transform_protocol=esp auth_algorithm=sha1
encapsulation_mode=tunnel encryption_algorithm=aes-128
name -- Name of the IPSec policy
transform_protocol -- Transform protocol in lowercase, default: esp (Optional)
auth_algorithm -- Authentication algorithm in lowercase, default: sha1 (Optional)
encapsulation_mode -- Encapsulation mode in lowercase, default: tunnel (Optional)
encryption_algorithm -- Encryption algorithm in lowercase, default:aes-128 (Optional)
pfs -- Prefect Forward Security in lowercase, default: group5 (Optional)
units -- IPSec lifetime attribute. default: seconds (Optional)
value -- IPSec lifetime attribute. default: 3600 (Optional)
profile -- Profile to build on (Optional)
Created IPSec policy information
Creates a new network
CLI Example:
salt '*' neutron.create_network network-name
salt '*' neutron.create_network network-name profile=openstack1
name -- Name of network to create
admin_state_up -- should the state of the network be up? default: True (Optional)
router_ext -- True then if create the external network (Optional)
network_type -- the Type of network that the provider is such as GRE, VXLAN, VLAN, FLAT, or LOCAL (Optional)
physical_network -- the name of the physical network as neutron knows it (Optional)
segmentation_id -- the vlan id or GRE id (Optional)
shared -- is the network shared or not (Optional)
profile -- Profile to build on (Optional)
Created network information
Creates a new port
CLI Example:
salt '*' neutron.create_port network-name port-name
name -- Name of port to create
network -- Network name or ID
device_id -- ID of device (Optional)
admin_state_up -- Set admin state up to true or false, default: true (Optional)
profile -- Profile to build on (Optional)
Created port information
Creates a new router
CLI Example:
salt '*' neutron.create_router new-router-name
name -- Name of router to create (must be first)
ext_network -- ID or name of the external for the gateway (Optional)
admin_state_up -- Set admin state up to true or false, default:true (Optional)
profile -- Profile to build on (Optional)
Created router information
Creates a new security group
CLI Example:
salt '*' neutron.create_security_group security-group-name description='Security group for servers'
name -- Name of security group (Optional)
description -- Description of security group (Optional)
profile -- Profile to build on (Optional)
Created security group information
Creates a new security group rule
CLI Example:
salt '*' neutron.show_security_group_rule security-group-rule-id
security_group -- Security group name or ID to add rule
remote_group_id -- Remote security group name or ID to apply rule (Optional)
direction -- Direction of traffic: ingress/egress, default: ingress (Optional)
protocol -- Protocol of packet: null/icmp/tcp/udp, default: null (Optional)
port_range_min -- Starting port range (Optional)
port_range_max -- Ending port range (Optional)
ethertype -- IPv4/IPv6, default: IPv4 (Optional)
profile -- Profile to build on (Optional)
Created security group rule information
Creates a new subnet
CLI Example:
salt '*' neutron.create_subnet network-name 192.168.1.0/24
network -- Network ID or name this subnet belongs to
cidr -- CIDR of subnet to create (Ex. '192.168.1.0/24')
name -- Name of the subnet to create (Optional)
ip_version -- Version to use, default is 4(IPv4) (Optional)
profile -- Profile to build on (Optional)
Created subnet information
Creates a new VPN service
CLI Example:
salt '*' neutron.create_vpnservice router-name name
subnet -- Subnet unique identifier for the VPN service deployment
router -- Router unique identifier for the VPN service
name -- Set a name for the VPN service
admin_state_up -- Set admin state up to true or false, default:True (Optional)
profile -- Profile to build on (Optional)
Created VPN service information
Deletes the specified firewall_rule
CLI Example:
salt '*' neutron.delete_firewall_rule firewall-rule
firewall_rule -- ID or name of firewall rule to delete
profile -- Profile to build on (Optional)
True(Succeed) or False
Deletes the specified floating IP
CLI Example:
salt '*' neutron.delete_floatingip floatingip-id
floatingip_id -- ID of floatingIP to delete
profile -- Profile to build on (Optional)
True(Succeed) or False
Deletes the specified IKEPolicy
CLI Example:
salt '*' neutron.delete_ikepolicy ikepolicy-name
ikepolicy -- ID or name of IKE policy to delete
profile -- Profile to build on (Optional)
True(Succeed) or False
Deletes the specified IPsecSiteConnection
CLI Example:
salt '*' neutron.delete_ipsec_site_connection connection-name
ipsec_site_connection -- ID or name of ipsec site connection to delete
profile -- Profile to build on (Optional)
True(Succeed) or False
Deletes the specified IPsecPolicy
CLI Example:
salt '*' neutron.delete_ipsecpolicy ipsecpolicy-name
ipsecpolicy -- ID or name of IPSec policy to delete
profile -- Profile to build on (Optional)
True(Succeed) or False
Deletes the specified network
CLI Example:
salt '*' neutron.delete_network network-name
salt '*' neutron.delete_network network-name profile=openstack1
network -- ID or name of network to delete
profile -- Profile to build on (Optional)
True(Succeed) or False
Deletes the specified port
CLI Example:
salt '*' neutron.delete_network port-name
salt '*' neutron.delete_network port-name profile=openstack1
port -- port name or ID
profile -- Profile to build on (Optional)
True(Succeed) or False
Delete the specified tenant's quota value
CLI Example:
salt '*' neutron.update_quota tenant-id
salt '*' neutron.update_quota tenant-id profile=openstack1
tenant_id -- ID of tenant to quota delete
profile -- Profile to build on (Optional)
True(Delete succeed) or False(Delete failed)
Delete the specified router
CLI Example:
salt '*' neutron.delete_router router-name
router -- ID or name of router to delete
profile -- Profile to build on (Optional)
True(Succeed) or False
Deletes the specified security group
CLI Example:
salt '*' neutron.delete_security_group security-group-name
security_group -- ID or name of security group to delete
profile -- Profile to build on (Optional)
True(Succeed) or False
Deletes the specified security group rule
CLI Example:
salt '*' neutron.delete_security_group_rule security-group-rule-id
security_group_rule_id -- ID of security group rule to delete
profile -- Profile to build on (Optional)
True(Succeed) or False
Deletes the specified subnet
CLI Example:
salt '*' neutron.delete_subnet subnet-name
salt '*' neutron.delete_subnet subnet-name profile=openstack1
subnet -- ID or name of subnet to delete
profile -- Profile to build on (Optional)
True(Succeed) or False
Deletes the specified VPN service
CLI Example:
salt '*' neutron.delete_vpnservice vpnservice-name
vpnservice -- ID or name of vpn service to delete
profile -- Profile to build on (Optional)
True(Succeed) or False
Fetches tenant info in server's context for following quota operation
CLI Example:
salt '*' neutron.get_quotas_tenant
salt '*' neutron.get_quotas_tenant profile=openstack1
profile -- Profile to build on (Optional)
Quotas information
List agents.
CLI Example:
salt '*' neutron.list_agents
profile -- Profile to build on (Optional)
agents message.
Fetches a list of all extensions on server side
CLI Example:
salt '*' neutron.list_extensions
salt '*' neutron.list_extensions profile=openstack1
profile -- Profile to build on (Optional)
List of extensions
Fetches a list of all firewall rules for a tenant
CLI Example:
salt '*' neutron.list_firewall_rules
profile -- Profile to build on (Optional)
List of firewall rules
Fetches a list of all firewalls for a tenant
CLI Example:
salt '*' neutron.list_firewalls
profile -- Profile to build on (Optional)
List of firewalls
Fetch a list of all floatingIPs for a tenant
CLI Example:
salt '*' neutron.list_floatingips
salt '*' neutron.list_floatingips profile=openstack1
profile -- Profile to build on (Optional)
List of floatingIP
Fetches a list of all configured IKEPolicies for a tenant
CLI Example:
salt '*' neutron.list_ikepolicies
salt '*' neutron.list_ikepolicies profile=openstack1
profile -- Profile to build on (Optional)
List of IKE policy
Fetches all configured IPsec Site Connections for a tenant
CLI Example:
salt '*' neutron.list_ipsec_site_connections
salt '*' neutron.list_ipsec_site_connections profile=openstack1
profile -- Profile to build on (Optional)
List of IPSec site connection
Fetches a list of all configured IPsecPolicies for a tenant
CLI Example:
salt '*' neutron.list_ipsecpolicies ipsecpolicy-name
salt '*' neutron.list_ipsecpolicies ipsecpolicy-name profile=openstack1
profile -- Profile to build on (Optional)
List of IPSec policy
List L3 agents hosting a router.
CLI Example:
salt '*' neutron.list_l3_agent_hosting_routers router
:param router:router name or ID to query. :param profile: Profile to build on (Optional) :return: L3 agents message.
Fetches a list of all networks for a tenant
CLI Example:
salt '*' neutron.list_networks
salt '*' neutron.list_networks profile=openstack1
profile -- Profile to build on (Optional)
List of network
Fetches a list of all networks for a tenant
CLI Example:
salt '*' neutron.list_ports
salt '*' neutron.list_ports profile=openstack1
profile -- Profile to build on (Optional)
List of port
Fetches all tenants quotas
CLI Example:
salt '*' neutron.list_quotas
salt '*' neutron.list_quotas profile=openstack1
profile -- Profile to build on (Optional)
List of quotas
Fetches a list of all routers for a tenant
CLI Example:
salt '*' neutron.list_routers
salt '*' neutron.list_routers profile=openstack1
profile -- Profile to build on (Optional)
List of router
Fetches a list of all security group rules for a tenant
CLI Example:
salt '*' neutron.list_security_group_rules
salt '*' neutron.list_security_group_rules profile=openstack1
profile -- Profile to build on (Optional)
List of security group rule
Fetches a list of all security groups for a tenant
CLI Example:
salt '*' neutron.list_security_groups
salt '*' neutron.list_security_groups profile=openstack1
profile -- Profile to build on (Optional)
List of security group
Fetches a list of all networks for a tenant
CLI Example:
salt '*' neutron.list_subnets
salt '*' neutron.list_subnets profile=openstack1
profile -- Profile to build on (Optional)
List of subnet
Fetches a list of all configured VPN services for a tenant
CLI Example:
salt '*' neutron.list_vpnservices
retrieve_all -- True or False, default: True (Optional)
profile -- Profile to build on (Optional)
List of VPN service
Removes an external network gateway from the specified router
CLI Example:
salt '*' neutron.remove_gateway_router router-name
router -- ID or name of router
profile -- Profile to build on (Optional)
True(Succeed) or False
Removes an internal network interface from the specified router
CLI Example:
salt '*' neutron.remove_interface_router router-name subnet-name
router -- ID or name of the router
subnet -- ID or name of the subnet
profile -- Profile to build on (Optional)
True(Succeed) or False
Fetches information of a specific firewall rule
CLI Example:
salt '*' neutron.show_firewall firewall
firewall -- ID or name of firewall to look up
profile -- Profile to build on (Optional)
firewall information
Fetches information of a specific firewall rule
CLI Example:
salt '*' neutron.show_firewall_rule firewall-rule-name
ipsecpolicy -- ID or name of firewall rule to look up
profile -- Profile to build on (Optional)
firewall rule information
Fetches information of a certain floatingIP
CLI Example:
salt '*' neutron.show_floatingip floatingip-id
floatingip_id -- ID of floatingIP to look up
profile -- Profile to build on (Optional)
Floating IP information
Fetches information of a specific IKEPolicy
CLI Example:
salt '*' neutron.show_ikepolicy ikepolicy-name
ikepolicy -- ID or name of ikepolicy to look up
profile -- Profile to build on (Optional)
IKE policy information
Fetches information of a specific IPsecSiteConnection
CLI Example:
salt '*' neutron.show_ipsec_site_connection connection-name
ipsec_site_connection -- ID or name of ipsec site connection to look up
profile -- Profile to build on (Optional)
IPSec site connection information
Fetches information of a specific IPsecPolicy
CLI Example:
salt '*' neutron.show_ipsecpolicy ipsecpolicy-name
ipsecpolicy -- ID or name of IPSec policy to look up
profile -- Profile to build on (Optional)
IPSec policy information
Fetches information of a certain network
CLI Example:
salt '*' neutron.show_network network-name
salt '*' neutron.show_network network-name profile=openstack1
network -- ID or name of network to look up
profile -- Profile to build on (Optional)
Network information
Fetches information of a certain port
CLI Example:
salt '*' neutron.show_port port-id
salt '*' neutron.show_port port-id profile=openstack1
port -- ID or name of port to look up
profile -- Profile to build on (Optional)
Port information
Fetches information of a certain tenant's quotas
CLI Example:
salt '*' neutron.show_quota tenant-id
salt '*' neutron.show_quota tenant-id profile=openstack1
tenant_id -- ID of tenant
profile -- Profile to build on (Optional)
Quota information
Fetches information of a certain router
CLI Example:
salt '*' neutron.show_router router-name
router -- ID or name of router to look up
profile -- Profile to build on (Optional)
Router information
Fetches information of a certain security group
CLI Example:
salt '*' neutron.show_security_group security-group-name
security_group -- ID or name of security group to look up
profile -- Profile to build on (Optional)
Security group information
Fetches information of a certain security group rule
CLI Example:
salt '*' neutron.show_security_group_rule security-group-rule-id
security_group_rule_id -- ID of security group rule to look up
profile -- Profile to build on (Optional)
Security group rule information
Fetches information of a certain subnet
CLI Example:
salt '*' neutron.show_subnet subnet-name
subnet -- ID or name of subnet to look up
profile -- Profile to build on (Optional)
Subnet information
Fetches information of a specific VPN service
CLI Example:
salt '*' neutron.show_vpnservice vpnservice-name
vpnservice -- ID or name of vpn service to look up
profile -- Profile to build on (Optional)
VPN service information
Update a firewall rule
CLI Example:
salt '*' neutron.update_firewall_rule firewall_rule protocol=PROTOCOL action=ACTION
name=NAME description=DESCRIPTION ip_version=IP_VERSION
source_ip_address=SOURCE_IP_ADDRESS destination_ip_address=DESTINATION_IP_ADDRESS
source_port=SOURCE_PORT destination_port=DESTINATION_PORT shared=SHARED enabled=ENABLED
firewall_rule -- ID or name of firewall rule to update.
protocol -- Protocol for the firewall rule, choose "tcp","udp","icmp" or "None". (Optional)
action -- Action for the firewall rule, choose "allow" or "deny". (Optional)
name -- Name for the firewall rule. (Optional)
description -- Description for the firewall rule. (Optional)
ip_version -- IP protocol version, default: 4. (Optional)
source_ip_address -- Source IP address or subnet. (Optional)
destination_ip_address -- Destination IP address or subnet. (Optional)
source_port -- Source port (integer in [1, 65535] or range in a:b). (Optional)
destination_port -- Destination port (integer in [1, 65535] or range in a:b). (Optional)
shared -- Set shared to True, default: False. (Optional)
enabled -- To enable this rule, default: True. (Optional)
profile -- Profile to build on (Optional)
Updates a floatingIP
CLI Example:
salt '*' neutron.update_floatingip network-name port-name
floatingip_id -- ID of floatingIP
port -- ID or name of port, to associate floatingip to None or do not specify to disassociate the floatingip (Optional)
profile -- Profile to build on (Optional)
Value of updated floating IP information
Updates a network
CLI Example:
salt '*' neutron.update_network network-name new-network-name
network -- ID or name of network to update
name -- Name of this network
profile -- Profile to build on (Optional)
Value of updated network information
Updates a port
CLI Example:
salt '*' neutron.update_port port-name network-name new-port-name
port -- Port name or ID
name -- Name of this port
admin_state_up -- Set admin state up to true or false, default: true (Optional)
profile -- Profile to build on (Optional)
Value of updated port information
Update a tenant's quota
CLI Example:
salt '*' neutron.update_quota tenant-id subnet=40 router=50
network=10 floatingip=30 port=30
tenant_id -- ID of tenant
subnet -- Value of subnet quota (Optional)
router -- Value of router quota (Optional)
network -- Value of network quota (Optional)
floatingip -- Value of floatingip quota (Optional)
port -- Value of port quota (Optional)
security_group -- Value of security group (Optional)
security_group_rule -- Value of security group rule (Optional)
profile -- Profile to build on (Optional)
Value of updated quota
Updates a router
CLI Example:
salt '*' neutron.update_router router_id name=new-router-name
admin_state_up=True
router -- ID or name of router to update
name -- Name of this router
ext_network -- ID or name of the external for the gateway (Optional)
admin_state_up -- Set admin state up to true or false, default: true (Optional)
profile -- Profile to build on (Optional)
kwargs --
Value of updated router information
Updates a security group
CLI Example:
salt '*' neutron.update_security_group security-group-name new-security-group-name
security_group -- ID or name of security group to update
name -- Name of this security group (Optional)
description -- Description of security group (Optional)
profile -- Profile to build on (Optional)
Value of updated security group information
Updates a subnet
CLI Example:
salt '*' neutron.update_subnet subnet-name new-subnet-name
subnet -- ID or name of subnet to update
name -- Name of this subnet
profile -- Profile to build on (Optional)
Value of updated subnet information
Updates a VPN service
CLI Example:
salt '*' neutron.update_vpnservice vpnservice-name desc='VPN Service1'
vpnservice -- ID or name of vpn service to update
desc -- Set a description for the VPN service
profile -- Profile to build on (Optional)
Value of updated VPN service information