April 2018
Intermediate to advanced
280 pages
8h 37m
English
A new virtual network can be created by invoking the create_network() function call and specifying the name of the network. Once a network is created, we must create a subnet that defines the IP version (IPv4 or IPv6), the subnet CIDR, the gateway, and the name of the subnet.
The following code snippet demonstrates the creation of a virtual network called packtpub-network and then creates a subnet called packtpub-subnet:
def create_network(conn): network = conn.network.create_network(name='packtpub-network') print(network) subnet = conn.network.create_subnet( name='packtpub-subnet', network_id=network.id, ip_version='4', cidr='192.168.0.0/24', gateway_ip='192.168.0.1') print(subnet)
Once a network is created, you ...