Difference between revisions of "Attach a public network to a running VM"
Line 1: | Line 1: | ||
{{Fedcloud_Menu}} {{TOC_right}} | {{Fedcloud_Menu}} {{TOC_right}} | ||
= Attach a public network to a running VM = | |||
=== Objective === | === Objective === | ||
In this exercise we will show how to use jOCCI APIs to look for network resources and attach them to computing resource. | In this exercise we will show how to use jOCCI APIs to look for network resources and attach them to computing resource. |
Revision as of 10:13, 8 October 2016
Overview | For users | For resource providers | Infrastructure status | Site-specific configuration | Architecture |
Attach a public network to a running VM
Objective
In this exercise we will show how to use jOCCI APIs to look for network resources and attach them to computing resource.
Introduction
Let's suppose to have a running Jyputer Notebook at BIFI with the following VM ID: http://server4-eupt.unizar.es:8787/compute/d380e2a1-0f69-4cf7-8781-1b784a403eed
If you check the VM metadata with the jOCCI-describe-resource, you will find out that this VM has a private network IP address (192.168.68.19). This mean that the server is running behind a NAT server and we need to attach a public network before to access it.
To check the public network interface published by the given cloud provider, please consider the jOCCI-list-resource project:
Listing network resources
Usage
- Access the maven project
]$ cd di4r-traning/jOCCI-list-resources/
- Edit your settings in the src/main/java/it/infn/ct/Exercise2.java source code to list network resources:
String OCCI_ENDPOINT_HOST = "http://server4-eupt.unizar.es:8787/"; // Possible resources are = os_tpl, resource_tpl, compute, storage and network List<String> RESOURCE = Arrays.asList("network");
- Compile and package with maven:
]$ mvn compile && mvn package [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building jocci-list-resource 1.0 [INFO] ------------------------------------------------------------------------ [..] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 06.10s [INFO] Finished at: Mon Oct 03 16:57:52 CEST 2016 [INFO] Final Memory: 10M/30M [INFO] ------------------------------------------------------------------------
- Listing network resources available (you may redirect the output to a file):
]$ java -jar target/jocci-list-resources-1.0-jar-with-dependencies.jar [ACTION] = list AUTH = x509 OCCI_ENDPOINT_HOST = http://server4-eupt.unizar.es:8787/ RESOURCE = [network] TRUSTED_CERT_REPOSITORY_PATH = /etc/grid-security/certificates PROXY_PATH = /tmp/x509up_u1000 Verbose = ON [+] Listing *network* resources http://server4-eupt.unizar.es:8787/network/admin http://server4-eupt.unizar.es:8787/network/public
Attach a public network resources
Usage
- Access the maven project
]$ cd di4r-traning/jOCCI-attach-resources/
- Edit your settings in the src/main/java/it/infn/ct/Exercise6.java source code:
List<String> RESOURCE = Arrays.asList("compute", "http://server4-eupt.unizar.es:8787/compute/d380e2a1-0f69-4cf7-8781-1b784a403eed"); String LINK_RESOURCE = ("/network/public");
- Compile and package with maven:
]$ mvn compile && mvn package [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building jocci-attach-resource 1.0 [INFO] ------------------------------------------------------------------------ [..] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 05.05s [INFO] Finished at: Mon Oct 03 17:05:12 CEST 2016 [INFO] Final Memory: 10M/30M [INFO] ------------------------------------------------------------------------
- Listing network resources available (you may redirect the output to a file):
[ACTION] = link AUTH = x509 OCCI_ENDPOINT_HOST = http://server4-eupt.unizar.es:8787 RESOURCE = [compute, http://server4-eupt.unizar.es:8787/compute/d380e2a1-0f69-4cf7-8781-1b784a403eed] TRUSTED_CERT_REPOSITORY_PATH = /etc/grid-security/certificates PROXY_PATH = /tmp/x509up_u1000 LINK_RESOURCE = /network/public Verbose = True [+] Link a public network interface to the VA http://server4-eupt.unizar.es:8787/compute/d380e2a1-0f69-4cf7-8781-1b784a403eed Public Network = http://server4-eupt.unizar.es:8787/network/public http://server4-eupt.unizar.es:8787/network/interface/d380e2a1-0f69-4cf7-8781-1b784a403eed_155.210.71.158
Now the Jupyter Notebook has a public IP (155.210.71.158) and can be accessed via SSH.