Announcing oci-gradle-plugin version 0.1.0

The first release of the OCI Gradle Plugin is out! The plugin lets you interact with the Oracle Cloud Infrastructure Java SDK. The behavior provided by OCI Java SDK is quite extensive, thus for this release the plugin delivers the minimal features required to setup and work with instances. Here’s an example, the following command will setup an Instance in a particular Compartment, while at the same time setting up a new VCN, Subnets, an InternetGateway and an InstanceConsoleConnection, allowing you to SSH to the freshly created instance

$ ./gradlew setupInstance \
  --compartment-id=ocid1.compartment.oc1...noa \
  --instance-name=test \
  --image=Oracle-Linux-7.6-2019.04.18-0 \
  --shape=VM.Standard2.1 \
  --public-key-file=/Users/aalmiray/.oci/oci-key.pub \
  --user-data-file=/Users/aalmiray/oci/examples/basic/cloud-init.sh

> Task :setupInstance
Provisioning Vcn. This may take a while.
Waiting for Vcn to be Available
Vcn 'test-vcn' has been provisioned. id = ocid1.vcn.oc1.eu-frankfurt-1...xca
Waiting for InternetGateway to be Available
InternetGateway 'test-internet-gateway' has been provisioned. id = ocid1.internetgateway.oc1.eu-frankfurt-1...nga
Adding InternetGateway 'test-internet-gateway' to RouteTable. vcnId = ocid1.vcn.oc1.eu-frankfurt-1...xca
Waiting for Subnet to be Available
Subnet 'Subnet ZnoN:EU-FRANKFURT-1-AD-1' has been provisioned. id = ocid1.subnet.oc1.eu-frankfurt-1...57a
Waiting for Subnet to be Available
Subnet 'Subnet ZnoN:EU-FRANKFURT-1-AD-2' has been provisioned. id = ocid1.subnet.oc1.eu-frankfurt-1...ira
Waiting for Subnet to be Available
Subnet 'Subnet ZnoN:EU-FRANKFURT-1-AD-3' has been provisioned. id = ocid1.subnet.oc1.eu-frankfurt-1...mla
Waiting for Instance to be Available
Instance 'test' has been provisioned. id = ocid1.instance.oc1.eu-frankfurt-1...ozq
Ip Addresses:
    130.61.42.188
Provisioning InstanceConsoleConnection. This may take a while.
Waiting for InstanceConsoleConnection to be Active
InstanceConsoleConnection has been provisioned. id = ocid1.instanceconsoleconnection.oc1.eu-frankfurt-1...s4a
Waiting for BootVolume to be Available
BootVolume 'test-boot-volume' has been provisioned. id = ocid1.bootvolume.oc1.eu-frankfurt-1...y4a
Result stored at /Users/aalmiray/oci/examples/basic/build/oci/test.properties

BUILD SUCCESSFUL in 1m 23s
1 actionable task: 1 executed

Ids have been obfuscated for this example. This particular example sets up OpenJDK on the target instance by means of the cloud-init.sh script that’s passed as part of the initialization data, this file looks like this

#!/bin/bash

# install Java
yum install -y yum java-1.8.0-openjdk

# amend firewall rules to allow port 8080
firewall-cmd --permanent --zone=public --add-port=8080/tcp
firewall-cmd --reload

Here’s a list of all currently available tasks

OCI Create tasks
----------------
createCompartment - Creates a Compartment.
createInstance - Creates an Instance.
createInstanceConsoleConnection - Creates an InstanceConsoleConnection.
createInternetGateway - Creates a InternetGateway.
createSubnet - Creates a Subnet.
createVcn - Creates a Vcn.

OCI Delete tasks
----------------
deleteCompartment - Deletes a Compartment.
deleteInstanceConsoleConnection - Deletes an InstanceConsoleConnection.
deleteInternetGateway - Deletes a InternetGateway.
deleteSubnet - Deletes a Subnet.
deleteVcn - Deletes a Vcn.

OCI Get tasks
-------------
getCompartment - Displays information for an specific Compartment.
getInstance - Displays information for an specific Instance.
getInstanceConsoleConnection - Displays information for an specific InstanceConsoleConnection.
getInstancePublicIp - Displays public Ip addresses for a particular Instance.
getInternetGateway - Displays information for an specific InternetGateway.
getRouteTable - Displays information for an specific RouteTable.
getSecurityList - Displays information for an specific SecurityList.
getSubnet - Displays information for an specific Subnet.
getVcn - Displays information for an specific Vcn.

OCI Instance tasks
------------------
addIngressSecurityRule - Adds IngressSecurityRules to a SecurityList.
instanceAction - Performs a given action on an Instance.
setupInstance - Setups an Instance with Vcn, InternetGateway, Subnets, InstanceConsoleConnection, and Volume.
terminateInstance - Terminates an Instance.

OCI List tasks
--------------
listAvailabilityDomains - Lists AvailabilityDomains available on a Compartment.
listCompartments - Lists available Compartments.
listImages - Lists Images available on a Compartment.
listInstanceConsoleConnections - Lists available InstanceConsoleConnection on an Instance.
listInstances - Lists available Instances.
listInternetGateways - Lists InternetGateways available on a Vcn.
listRegions - Lists available Regions.
listRouteTables - Lists RouteTables available on a Vcn.
listSecurityLists - Lists SecurityLists available on a Vcn.
listShapes - Lists Shapes available on a Compartment.
listSubnets - Lists Subnets available on a Vcn.
listUsers - Lists available Users.
listVcns - Lists Vcns available on a Compartment.

OCI Query tasks
---------------
searchResources - Lists information on resource types.

The plugin is readily available from the Gradle Plugin Portal. A big shout out to Todd Sharp for helping me figure out the configuration for the cloud init script and a few other things I missed during the development of this first release.

Keep on coding!

Trackbacks/Pingbacks

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

ˆ Back To Top