api-site/firstapp/source/appendix.rst
Marcela Bonell ef14eaaf5e [MyFirstApp] Gophercloud library migration
Migrating from rackspace/gophercloud to gophercloud/gophercloud library.

Change-Id: Ia72a4c548e23b4225b788520d924be8e04ce5c6f
2017-01-10 14:49:35 -06:00

1.5 KiB

Appendix

Bootstrap your network

Most cloud providers provision all network objects that are required to boot an instance. To determine whether these objects were created for you, access the Network Topology section of the OpenStack dashboard.

Specify a network during instance build

code for creating a networking using code

shade

Add the parameter network and send its name or id to attach the instance to:

testing_instance = conn.create_server(wait=True, auto_ip=True,
    name=instance_name,
    image=image_id,
    flavor=flavor_id,
    network=network_id)

gophercloud

Add the option Networks and send its id to attach the instance to:

opts := servers.CreateOpts {
    Name: instanceName,
    ImageRef: image.ID,
    FlavorRef: flavor.ID,
    SecurityGroups: []string{securityGroupName},
    UserData: []byte(userData),
    Networks: []servers.Network{servers.Network{UUID: networkID}},

}

testingInstance, _ = servers.Create(client, keypairs.CreateOptsExt {
    CreateOptsBuilder: opts,
    KeyName: keyPairName,
}).Extract()