Skip to Content
Hybrid Cloud for Developers
book

Hybrid Cloud for Developers

by Manoj Hirway
April 2018
Intermediate to advanced content levelIntermediate to advanced
280 pages
8h 37m
English
Packt Publishing
Content preview from Hybrid Cloud for Developers

Creating a network/subnet

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

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hybrid Cloud for Architects

Hybrid Cloud for Architects

Alok Shrivastwa
OpenStack: Building a Cloud Environment

OpenStack: Building a Cloud Environment

Alok Shrivastwa, Sunil Sarat, Kevin Jackson, Cody Bunch, Egle Sigler, Tony Campbell

Publisher Resources

ISBN: 9781788830874Supplemental Content