3.5.12.2 Python

Creating a Network

The SOAP object expected by the API for a new network consists of the network name, and optionally a description. The following Python code illustrates this:

net=client.factory.create('network')
net.name="MyNetwork"
net.description="A network set up to test the SOAP API"
job=client.service.networkCreate(net)
net_id=wait_for_job(client,job.id)
Creating a Local Network for a Server

To create a local network for a specific server, you need the server ID. If you do not have the server ID available for use in your code already, refer to Obtaining the server ID. to obtain an ID object for a specific server. Here, we assume the server ID object is already populated:

lo_net=client.factory.create('network')
lo_net.name="MyLocalNetwork"
lo_net.description="A local network set up to test the SOAP API"
job=client.service.serverCreateNetwork(sid,lo_net)
lo_net_id=wait_for_job(client,job.id)

Notice that the serverCreateNetwork method defined in the API helps to distinguish this network type from other network types, and expects the server ID object required to flag it as a local network.