Skip to content

Instantly share code, notes, and snippets.

@vinzent
Created September 4, 2016 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinzent/799563b21f205e41f947dc05d036356b to your computer and use it in GitHub Desktop.
Save vinzent/799563b21f205e41f947dc05d036356b to your computer and use it in GitHub Desktop.
nova keypair-add --pub-key ~/.ssh/id_rsa.pub tmueller
get_floating_ip() {
openstack ip floating list -f value -c "Floating IP Address" -c Port | grep 'None' | head -1 | cut -f1 -d" "
}
neutron net-create --port_security_enabled=False NetA
neutron subnet-create --name NetA_Sub1 --no-gateway --disable-dhcp NetA 192.168.0.0/24
neutron net-create --port_security_enabled=False NetB
neutron subnet-create --name NetB_Sub1 --no-gateway --disable-dhcp NetB 192.168.1.0/24
neutron net-create --port_security_enabled=False NetC
neutron subnet-create --name NetC_Sub1 --no-gateway --disable-dhcp NetC 192.168.2.0/24
neutron net-create --port_security_enabled=False NetD
neutron subnet-create --name NetD_Sub1 --no-gateway --disable-dhcp NetD 192.168.3.0/24
neutron port-create --name NetA_Port1 NetA
neutron port-create --name NetB_Port1 NetB
neutron port-create --name NetB_Port2 NetB
neutron port-create --name NetC_Port1 NetC
neutron port-create --name NetD_Port1 NetD
nova boot --flavor c1.micro --image "Debian Jessie 8.1 (SWITCHengines)" \
--key-name=tmueller --nic net-name=private --poll r1 &
nova boot --flavor c1.micro --image "Debian Jessie 8.1 (SWITCHengines)" \
--key-name=tmueller --nic net-name=private --poll r2 &
wait
nova interface-attach --port-id $(neutron port-show -F id -f value NetA_Port1) r1
nova interface-attach --port-id $(neutron port-show -F id -f value NetB_Port1) r1
nova interface-attach --port-id $(neutron port-show -F id -f value NetB_Port2) r2
nova interface-attach --port-id $(neutron port-show -F id -f value NetC_Port1) r2
nova interface-attach --port-id $(neutron port-show -F id -f value NetD_Port1) r2
openstack ip floating add $(get_floating_ip) r1
openstack ip floating add $(get_floating_ip) r2
@vinzent
Copy link
Author

vinzent commented Sep 4, 2016

Delete all!

openstack server list -f value -c ID | xargs -n1 nova delete 
for i in $(neutron port-list -F name -f value | grep Net); do neutron port-delete $i; done
for i in $(neutron subnet-list -F name -f value | grep Net); do neutron subnet-delete $i; done
for i in $(neutron net-list -F name -f value | grep Net); do neutron net-delete $i; done

@vinzent
Copy link
Author

vinzent commented Sep 6, 2016

Funktioniert nicht:

nova boot --flavor c1.micro --image "Debian Jessie 8.1 (SWITCHengines)" \
  --key-name=tmueller --nic net-name=private --nic port-id=6be7a11d-cd4d-42c7-b0df-45ea775a2381 --poll r1 

Output:

(venv) [tmueller@tmueller-notebook python]$ nova boot --flavor c1.micro --image "Debian Jessie 8.1 (SWITCHengines)" \
>   --key-name=tmueller --nic net-name=private --nic port-id=6be7a11d-cd4d-42c7-b0df-45ea775a2381 --poll r1 
+--------------------------------------+--------------------------------------------------------------------------+
| Property                             | Value                                                                    |
+--------------------------------------+--------------------------------------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                                                   |
| OS-EXT-AZ:availability_zone          | nova                                                                     |
| OS-EXT-STS:power_state               | 0                                                                        |
| OS-EXT-STS:task_state                | scheduling                                                               |
| OS-EXT-STS:vm_state                  | building                                                                 |
| OS-SRV-USG:launched_at               | -                                                                        |
| OS-SRV-USG:terminated_at             | -                                                                        |
| accessIPv4                           |                                                                          |
| accessIPv6                           |                                                                          |
| adminPass                            | vUwYNevcbT28                                                             |
| config_drive                         |                                                                          |
| created                              | 2016-09-06T14:57:19Z                                                     |
| flavor                               | c1.micro (baaba9ad-9ee5-4f1d-a7a1-dd4b55c18b63)                          |
| hostId                               |                                                                          |
| id                                   | 423cfe15-a504-4ce3-a61d-61a0c0293438                                     |
| image                                | Debian Jessie 8.1 (SWITCHengines) (f59d75e1-a648-44be-8495-1d57541f16e8) |
| key_name                             | tmueller                                                                 |
| metadata                             | {}                                                                       |
| name                                 | r1                                                                       |
| os-extended-volumes:volumes_attached | []                                                                       |
| progress                             | 0                                                                        |
| security_groups                      | default                                                                  |
| status                               | BUILD                                                                    |
| tenant_id                            | b296d585336a466ea080f2465600e2e1                                         |
| updated                              | 2016-09-06T14:57:19Z                                                     |
| user_id                              | 6418adaa33c2444bafcf22ff0a967f37                                         |
+--------------------------------------+--------------------------------------------------------------------------+

Server building... 0% complete
Error building server
ERROR (ResourceInErrorState): <Server: r1>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment