Attach a public network to a running VM
Jump to navigation
Jump to search
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