9.2. Creating virtual networks¶
POST /v2.0/networks
Create a network.
The next step is to create a subnet for the network ID, as described in Creating virtual subnets.
Source: https://docs.openstack.org/api-ref/network/v2/index.html#create-network
9.2.1. Request¶
Name | In | Type | Description |
---|---|---|---|
network |
body | object | A network object. |
admin_state_up (Optional) |
body | boolean | The administrative state of the network, which is
up (true ) or down (false ). |
dns_domain (Optional) |
body | string | A valid DNS domain. |
mtu (Optional) |
body | integer | The maximum transmission unit (MTU) value to address fragmentation. Minimum value is 68 for IPv4, and 1280 for IPv6. |
name (Optional) |
body | string | Human-readable name of the network. |
port_security_enabled (Optional) |
body | boolean | The port security status of the network. Valid values are
enabled (true ) and disabled (false ).
This value is used as the default value of port_security_enabled
field of a newly created port. |
project_id (Optional) |
body | string | The ID of the project that owns the resource. Only administrative and users with advsvc role can specify a project ID other than their own. You cannot change this value through authorization policies. |
provider:network_type (Optional) |
body | string | The type of physical network that this network should be mapped to.
For example, flat , vlan , vxlan , or gre .
Valid values depend on a networking back-end. |
provider:physical_network (Optional) |
body | string | The physical network where this network should be implemented. The Networking API v2.0 does not provide a way to list available physical networks. For example, the Open vSwitch plug-in configuration file defines a symbolic name that maps to specific bridges on each compute host. |
provider:segmentation_id (Optional) |
body | integer | The ID of the isolated segment on the physical network.
The network_type attribute defines the segmentation model.
For example, if the network_type value is vlan, this ID is a vlan
identifier. If the network_type value is gre, this ID is a gre key. |
qos_policy_id (Optional) |
body | string | The ID of the QoS policy associated with the network. |
router:external (Optional) |
body | boolean | Indicates whether the network has an external routing facility that’s not managed by the networking service. |
segments (Optional) |
body | array | A list of provider segment objects. |
shared (Optional) |
body | boolean | Indicates whether this resource is shared across all projects. By default, only administrative users can change this value. |
tenant_id (Optional) |
body | string | The ID of the project that owns the resource. Only administrative and users with advsvc role can specify a project ID other than their own. You cannot change this value through authorization policies. |
vlan_transparent (Optional) |
body | boolean | Indicates the VLAN transparency mode of the network, which is
VLAN transparent (true ) or not VLAN transparent (false ). |
description (Optional) |
body | string | A human-readable description for the resource. Default is an empty string. |
is_default (Optional) |
body | boolean | The network is default or not. |
availability_zone_hints (Optional) |
body | array | The availability zone candidate for the network. |
9.2.1.1. Examples¶
Create a private virtual network:
# curl -ks -H 'Content-Type: application/json' -H 'X-Auth-Token: gAAAAA<...>' -d '
{
"network": {
"name": "privnet1",
"port_security_enabled": true
}
}' https://<node_IP_addr>:9696/v2.0/networks
Create a public virtual network bound to a physical network:
# curl -ks -H 'Content-Type: application/json' -H 'X-Auth-Token: gAAAAA<...>' -d '
{
"network": {
"name": "net2",
"port_security_enabled": true,
"provider:physical_network": "Public",
"provider:network_type": "flat",
"shared": true
}
}' https://<node_IP_addr>:9696/v2.0/networks
You can find out the physical network name from /etc/kolla/neutron-openvswitch-agent/ml2_conf.ini
. For example:
# cat /etc/kolla/neutron-openvswitch-agent/ml2_conf.ini | grep bridge_mappings
bridge_mappings = Public:br-eth0
9.2.2. Response¶
Name | In | Type | Description |
---|---|---|---|
network |
body | object | A network object. |
admin_state_up |
body | boolean | The administrative state of the network, which is
up (true ) or down (false ). |
availability_zone_hints |
body | array | The availability zone candidate for the network. |
availability_zones |
body | array | The availability zone for the network. |
created_at |
body | string | Time at which the resource has been created (in UTC ISO8601 format). |
dns_domain |
body | string | A valid DNS domain. |
id |
body | string | The ID of the network. |
ipv4_address_scope |
body | string | The ID of the IPv4 address scope that the network is associated with. |
ipv6_address_scope |
body | string | The ID of the IPv6 address scope that the network is associated with. |
l2_adjacency |
body | boolean | Indicates whether L2 connectivity is available throughout
the network . |
mtu |
body | integer | The maximum transmission unit (MTU) value to address fragmentation. Minimum value is 68 for IPv4, and 1280 for IPv6. |
name |
body | string | Human-readable name of the network. |
port_security_enabled |
body | boolean | The port security status of the network. Valid values are
enabled (true ) and disabled (false ).
This value is used as the default value of port_security_enabled
field of a newly created port. |
project_id |
body | string | The ID of the project. |
provider:network_type |
body | string | The type of physical network that this network is mapped to.
For example, flat , vlan , vxlan , or gre .
Valid values depend on a networking back-end. |
provider:physical_network |
body | string | The physical network where this network/segment is implemented. |
provider:segmentation_id |
body | integer | The ID of the isolated segment on the physical network.
The network_type attribute defines the segmentation model.
For example, if the network_type value is vlan, this ID is a vlan
identifier. If the network_type value is gre, this ID is a gre key. |
qos_policy_id |
body | string | The ID of the QoS policy associated with the network. |
revision_number |
body | integer | The revision number of the resource. |
router:external |
body | boolean | Indicates whether the network has an external routing facility that’s not
managed by the networking service. If the network is updated from external
to internal the unused floating IPs of this network are automatically
deleted when extension floatingip-autodelete-internal is present. |
segments |
body | array | A list of provider segment objects. |
shared |
body | boolean | Indicates whether this network is shared across all tenants. By default, only administrative users can change this value. |
status |
body | string | The network status. Values are ACTIVE , DOWN , BUILD or ERROR . |
subnets |
body | array | The associated subnets. |
tenant_id |
body | string | The ID of the project. |
updated_at |
body | string | Time at which the resource has been updated (in UTC ISO8601 format). |
vlan_transparent |
body | boolean | Indicates the VLAN transparency mode of the network, which is
VLAN transparent (true ) or not VLAN transparent (false ). |
description |
body | string | A human-readable description for the resource. |
is_default |
body | boolean | The network is default pool or not. |
tags |
body | array | The list of tags on the resource. |
9.2.2.1. Status codes¶
9.2.2.1.1. Success¶
Code | Reason |
---|---|
201 - Created |
Resource was created and is ready to use. |
9.2.2.1.2. Error¶
Code | Reason |
---|---|
400 - Bad Request |
Some content in the request was invalid. |
401 - Unauthorized |
User must authenticate before making a request. |
9.2.2.2. Examples¶
Create a private virtual network:
{
"network": {
"provider:physical_network": null,
"ipv6_address_scope": null,
"revision_number": 1,
"port_security_enabled": true,
"provider:network_type": "vxlan",
"id": "c5252a20-9206-4b8e-9a0f-45bd22ee7bc8",
"router:external": false,
"availability_zone_hints": [],
"availability_zones": [],
"ipv4_address_scope": null,
"shared": false,
"project_id": "f5d834d636c642c7bfe8af86139c6f26",
"status": "ACTIVE",
"subnets": [],
"description": "",
"tags": [],
"updated_at": "2020-02-14T13:36:11Z",
"is_default": false,
"provider:segmentation_id": 5,
"name": "privnet1",
"admin_state_up": true,
"tenant_id": "f5d834d636c642c7bfe8af86139c6f26",
"created_at": "2020-02-14T13:36:11Z",
"mtu": 1450
}
}
Create a public virtual network:
{
"network": {
"provider:physical_network": "Public",
"ipv6_address_scope": null,
"revision_number": 1,
"port_security_enabled": true,
"provider:network_type": "flat",
"id": "c5a5d68e-55cd-40b8-a272-3768cbb86bd1",
"router:external": false,
"availability_zone_hints": [],
"availability_zones": [],
"ipv4_address_scope": null,
"shared": true,
"project_id": "f5d834d636c642c7bfe8af86139c6f26",
"status": "ACTIVE",
"subnets": [],
"description": "",
"tags": [],
"updated_at": "2020-02-17T11:27:17Z",
"is_default": false,
"provider:segmentation_id": null,
"name": "net2",
"admin_state_up": true,
"tenant_id": "f5d834d636c642c7bfe8af86139c6f26",
"created_at": "2020-02-17T11:27:17Z",
"mtu": 1500
}
}
Version 5.0.0 — Feb 01, 2022