We recently added another little utilities RPM for Oracle Linux 7 to our collection:
oci-utils is an Oracle Linux RPM that contains a set of scripts to make managing an OCI instance easier, from within the instance.
The current version provides tools that help with managing block volumes (attach, remove, automatic discovery), secondary vnic configuration, a script to query the public IP of an instances and a script that lets you query instance metadata key/value pairs without having to parse or read json.
Binaries:
/usr/bin/oci-iscsi-config /usr/bin/oci-metadata /usr/bin/oci-network-config /usr/bin/oci-public-ip System service
/etc/systemd/ocid.service /usr/libexec/ocid MAN pages
oci-iscsi-config(1) oci-metadata(1) oci-network-config(1) oci-public-ip(1) ocid(8)
Ideally you start the ocid service, it will monitor for any changes in block devices or vnic's attached or removed. Today, when you add a block device, you have to run a number of iscsiadm commands to actually discover it and attach it to your instance. When ocid is running, it will, on a regular basis, probe to see if these devices have been created through the OCI web console, cli or SDK. It will then automatically disover them for you.
oci-iscsi-config is a simple wrapper around iscsiadm that provides you with a single command to list and attach/detach devices without having to know the iscsiadm command syntax.
ex:
# oci-iscsi-config -s For full functionality of this utility the ocid service must be running The administrator can start it using this command: sudo systemctl start ocid.service ocid already running. Currently attached iSCSI devices: Target iqn.2015-02.oracle.boot:uefi Persistent portal: 169.254.0.2:3260 Current portal: 169.254.0.2:3260 State: running Attached device: sda Size: 46.6G Partitions: Device Size Filesystem Mountpoint sda1 544M vfat /boot/efi sda2 8G swap [SWAP] sda3 38G xfs /
<attach a 50G block volume in the OCI webconsole>
# oci-iscsi-config -s Currently attached iSCSI devices: Target iqn.2015-12.com.oracleiaas:31b78e27-0c73-43ff-98b9-0ced1722a08c Persistent portal: 169.254.2.2:3260 Current portal: 169.254.2.2:3260 State: running Attached device: sdb Size: 50G File system type: Unknown Mountpoint: Not mounted Target iqn.2015-02.oracle.boot:uefi Persistent portal: 169.254.0.2:3260 Current portal: 169.254.0.2:3260 State: running Attached device: sda Size: 46.6G Partitions: Device Size Filesystem Mountpoint sda1 544M vfat /boot/efi sda2 8G swap [SWAP] sda3 38G xfs /
You can see /dev/sdb now show up after a few seconds, without having to run any commands.
oci-network-config is similar
oci-network-config is similar
# oci-network-config -s
CONFIG ADDR SPREFIX SBITS VIRTRT NS IND IFACE VLTAG VLAN STATE MAC VNIC
- 10.0.0.2 10.0.0.0 24 10.0.0.1 - 0 ens3 - - UP 02:00:17:01:ed:6b ocid1.vnic.oc1.iad.abuwcljs4ik52qrq7itbb32rwajjqddt7utla64t47fkkq7tebw5gknt5csa
<add a secondary interface>
# oci-network-config -s
CONFIG ADDR SPREFIX SBITS VIRTRT NS IND IFACE VLTAG VLAN STATE MAC VNIC
- 10.0.0.2 10.0.0.0 24 10.0.0.1 - 0 ens3 - - UP 02:00:17:01:ed:6b ocid1.vnic.oc1.iad.abuwcljs4ik52qrq7itbb32rwajjqddt7utla64t47fkkq7tebw5gknt5csa
ADD 10.0.0.3 10.0.0.0 24 10.0.0.1 - 1 ens4 - - UP 02:00:17:01:eb:53 ocid1.vnic.oc1.iad.abuwcljsxek2mqaotafcohdmvghzrzx3jiiwq3zo45fh65dvlkpinndfjvma
oci-public-ip just contacts an internet facing server to return your public IP of your instance.
# oci-public-ip
Public IP address: 129.213.44.98
oci-medata let's you pretty-print the instance metadata and query for a given key
# oci-metadata -g region
Instance details:
Region: iad (Ashburn, VA, USA)
# oci-metadata -g state
Instance details:
Instance state: Running
An updated version in the near future will also use the SDK (if installed along with your pem key) to go and create a block device and attach it from within your instance and/or create a secondary vnic and automatically create and attach it.
One roadmap item is the ability to use dynamic groups and principals to allow for an instance with the right privileges to do the block volume create/secondary vnic create without a pem key.
give it a try.