cURL : Créer et connecter un réseau virtuel privé à internet

Créer un réseau privé et un sous-réseau associé

On commence par créer un réseau privé :

$ curl -i -k -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H "X-Auth-Token:<token>" -d '{"network":{"name": "reseau_interne1", "admin_state_up": true}}' https://network.fr1.cloudwatt.com/v2.0/networks
HTTP/1.1 201 Created
Date: Fri, 11 Jul 2014 09:01:27 GMT
Content-Type: application/json; charset=UTF-8
Content-Length: 237
X-Openstack-Request-Id: req-41d47179-2c5a-4dc6-a3f8-4ab27d2aaf5f

{
   "network":{
      "status":"ACTIVE",
      "subnets":[

      ],
      "name":"reseau_interne1",
      "router:external":false,
      "tenant_id":"xx000000000000000000000000000000",
      "admin_state_up":true,
      "shared":false,
      "id":"f0a6a0dd-d516-45bd-8adc-9d423cc6de74"
   }
}

Créez un sous-réseau interne, nommez-le et le rattacher au réseau privé ” reseau_interne1 “ :

$ curl -i -k -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H "X-Auth-Token:<token>" -d '{"subnet":{"network_id":"f0a6a0dd-d516-45bd-8adc-9d423cc6de74","ip_version":4,"cidr":"192.168.0.0/24"}}' https://network.fr1.cloudwatt.com/v2.0/subnets
HTTP/1.1 201 Created
Date: Fri, 11 Jul 2014 09:09:57 GMT
Content-Type: application/json; charset=UTF-8
Content-Length: 380
X-Openstack-Request-Id: req-4998026b-5345-46df-9bec-c8b43b9ff8d6

{
   "subnet":{
      "name":"",
      "enable_dhcp":true,
      "network_id":"f0a6a0dd-d516-45bd-8adc-9d423cc6de74",
      "tenant_id":"xx000000000000000000000000000000",
      "dns_nameservers":[

      ],
      "allocation_pools":[
         {
            "start":"192.168.0.2",
            "end":"192.168.0.254"
         }
      ],
      "host_routes":[

      ],
      "ip_version":4,
      "gateway_ip":"192.168.0.1",
      "cidr":"192.168.0.0/24",
      "id":"4873af17-7a81-4fbd-846f-6c0bd51a39af"
   }
}