X

News, tips, partners, and perspectives for the Oracle Solaris operating system

How to Install the OCI CLI on Oracle Solaris

Dave Miner
Sr. Principal Software Engineer

Following on to my previous posts on using Oracle Solaris with Oracle Cloud Infrastructure (OCI)...

All modern clouds provide a fancy browser console that lets you easily manage any of your cloud resources.  For power users, though, the browser console is often the slowest way to get things done.  Plus, if you're trying to leverage the cloud as part of other automation, which has often been written as traditional Unix shell scripts,you may need a command line interface (CLI),

Oracle Cloud Infrastructure (OCI) provides a comprehensive CLI, the oci command, written in Python as is true of many recent system tools.  The CLI and the underlying Python SDK are very portable, but have some dependencies on other Python modules at particular versions, so can be somewhat complex to install on any particular OS platform.  Fortunately, Python has a powerful module known as virtualenv that makes it fairly simple to install and run a Python application and its dependencies in isolation from other Python programs that may have conflicting requirements.  This is especially an issue with modern enterprise operating systems such as Solaris, which use Python for system tools and don't necessarily update all of their modules as quickly as the cloud SDK's require.  OCI makes use of virtualenv to provide an easy installation setup for any Unix-like operating system, including Solaris 11.4.  There are just a couple of extra things we need to do in order for it to work on Solaris, so without further ado, here's a step-by-step guide to installing the OCI CLI on Solaris 11.4

  1. Install Oracle Developer Studio's C compiler - any recent version should do, I've tested 12.4, 12.5 and 12.6.  Once you've obtained credentials for the package repository and configured the solarisstudio publisher, the command is simply pkg install --accept developer/developerstudio-126/cc
  2. Ensure the C compiler command is in your path: PATH=$PATH:/opt/developerstudio12.6/bin
  3. Install the system headers and pkg-config tool. pkg install system/header developer/build/pkg-config
  4. Set the correct include path in your environment: export CFLAGS=$(pkg-config --cflags libffi)
  5. Now follow the installation instructions from the OCI CLI documentation

Once you download and execute the basic install script, you'll have to answer several prompts regarding the installation locations for the OCI CLI components, after that it will download a series of dependencies, build and install them to the specified location, this takes just a couple of minutes. I've included a transcript of a session below so you can see what a successful runof the OCI install script looks like.  Happy CLI-ing!

{cli-114} bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  6283  100  6283    0     0  49472      0 --:--:-- --:--:-- --:--:-- 49472
Downloading Oracle Cloud Infrastructure CLI install script from https://raw.githubusercontent.com/oracle/oci-cli/6dc61e3b5fd2781c5afff2decb532c24969fa6bf/scripts/install/install.py to /tmp/oci_cli_install_tmp__Xfw.
######################################################################### 100.0%
System version of Python must be either a Python 2 version >= 2.7.5 or a Python 3 version >= 3.5.0.
Running install script.
python /tmp/oci_cli_install_tmp__Xfw  < /dev/tty
-- Verifying Python version.
-- Python version 2.7.14 okay.

===> In what directory would you like to place the install? (leave blank to use '/home/dminer/lib/oracle-cli'): /export/oci/lib 
-- Install directory '/export/oci/lib' is not empty and may contain a previous installation.

===> Remove this directory? (y/N): y  
-- Deleted '/export/oci/lib'.
-- Creating directory '/export/oci/lib'.
-- We will install at '/export/oci/lib'.

===> In what directory would you like to place the 'oci' executable? (leave blank to use '/home/dminer/bin'): /export/oci/bin
-- The executable will be in '/export/oci/bin'.

===> In what directory would you like to place the OCI scripts? (leave blank to use '/home/dminer/bin/oci-cli-scripts'): /export/oci/bin/oci-cli-scripts
-- Creating directory '/export/oci/bin/oci-cli-scripts'.
-- The scripts will be in '/export/oci/bin/oci-cli-scripts'.
-- Downloading virtualenv package from https://github.com/pypa/virtualenv/archive/15.0.0.tar.gz.
-- Downloaded virtualenv package to /tmp/tmpGBgVu5/15.0.0.tar.gz.
-- Checksum of /tmp/tmpGBgVu5/15.0.0.tar.gz OK.
-- Extracting '/tmp/tmpGBgVu5/15.0.0.tar.gz' to '/tmp/tmpGBgVu5'.
-- Executing: ['/usr/bin/python', 'virtualenv.py', '--python', '/usr/bin/python', '/export/oci/lib']
Already using interpreter /usr/bin/python
New python executable in /export/oci/lib/bin/python
Installing setuptools, pip, wheel...done.
-- Executing: ['/export/oci/lib/bin/pip', 'install', '--cache-dir', '/tmp/tmpGBgVu5', 'oci_cli', '--upgrade']
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting oci_cli
  Downloading https://files.pythonhosted.org/packages/3b/8e/dd495ec5eff6bbe8e97cb84db9a1f1407fe5ee0e901f5f2833bb47920ae3/oci_cli-2.5.4-py2.py3-none-any.whl (3.7MB)
    100% |████████████████████████████████| 3.7MB 3.3MB/s 
Collecting PyYAML==3.13 (from oci_cli)
  Downloading https://files.pythonhosted.org/packages/9e/a3/1d13970c3f36777c583f136c136f804d70f500168edc1edea6daa7200769/PyYAML-3.13.tar.gz (270kB)
    100% |████████████████████████████████| 276kB 21.1MB/s 
Collecting configparser==3.5.0 (from oci_cli)
  Downloading https://files.pythonhosted.org/packages/7c/69/c2ce7e91c89dc073eb1aa74c0621c3eefbffe8216b3f9af9d3885265c01c/configparser-3.5.0.tar.gz
Collecting python-dateutil==2.7.3 (from oci_cli)
  Downloading https://files.pythonhosted.org/packages/cf/f5/af2b09c957ace60dcfac112b669c45c8c97e32f94aa8b56da4c6d1682825/python_dateutil-2.7.3-py2.py3-none-any.whl (211kB)
    100% |████████████████████████████████| 215kB 4.0MB/s 
Collecting pytz==2016.10 (from oci_cli)
  Downloading https://files.pythonhosted.org/packages/f5/fa/4a9aefc206aa49a4b5e0a72f013df1f471b4714cdbe6d78f0134feeeecdb/pytz-2016.10-py2.py3-none-any.whl (483kB)
    100% |████████████████████████████████| 491kB 14.4MB/s 
Collecting cryptography==2.4.2 (from oci_cli)
  Downloading https://files.pythonhosted.org/packages/f3/39/d3904df7c56f8654691c4ae1bdb270c1c9220d6da79bd3b1fbad91afd0e1/cryptography-2.4.2.tar.gz (468kB)
    100% |████████████████████████████████| 471kB 5.1MB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting click==6.7 (from oci_cli)
  Downloading https://files.pythonhosted.org/packages/34/c1/8806f99713ddb993c5366c362b2f908f18269f8d792aff1abfd700775a77/click-6.7-py2.py3-none-any.whl (71kB)
    100% |████████████████████████████████| 71kB 1.6MB/s 
Collecting cx-Oracle==7.0 (from oci_cli)
  Downloading https://files.pythonhosted.org/packages/b7/70/03dbb0f055ee97f7ddb6c6f11668f23a97b5884fdf4826a006ef91c5085c/cx_Oracle-7.0.0.tar.gz (281kB)
    100% |████████████████████████████████| 286kB 19.0MB/s 
Collecting retrying==1.3.3 (from oci_cli)
  Downloading https://files.pythonhosted.org/packages/44/ef/beae4b4ef80902f22e3af073397f079c96969c69b2c7d52a57ea9ae61c9d/retrying-1.3.3.tar.gz
Collecting six==1.11.0 (from oci_cli)
  Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting arrow==0.10.0 (from oci_cli)
  Downloading https://files.pythonhosted.org/packages/54/db/76459c4dd3561bbe682619a5c576ff30c42e37c2e01900ed30a501957150/arrow-0.10.0.tar.gz (86kB)
    100% |████████████████████████████████| 92kB 2.1MB/s 
Collecting jmespath==0.9.3 (from oci_cli)
  Downloading https://files.pythonhosted.org/packages/b7/31/05c8d001f7f87f0f07289a5fc0fc3832e9a57f2dbd4d3b0fee70e0d51365/jmespath-0.9.3-py2.py3-none-any.whl
Collecting certifi (from oci_cli)
  Downloading https://files.pythonhosted.org/packages/60/75/f692a584e85b7eaba0e03827b3d51f45f571c2e793dd731e598828d380aa/certifi-2019.3.9-py2.py3-none-any.whl (158kB)
    100% |████████████████████████████████| 163kB 4.5MB/s 
Collecting httpsig-cffi==15.0.0 (from oci_cli)
  Downloading https://files.pythonhosted.org/packages/93/f5/c9a213c0f906654c933f1192148d8aded2022678ad6bce8803d3300501c6/httpsig_cffi-15.0.0-py2.py3-none-any.whl
Collecting pyOpenSSL==18.0.0 (from oci_cli)
  Downloading https://files.pythonhosted.org/packages/96/af/9d29e6bd40823061aea2e0574ccb2fcf72bfd6130ce53d32773ec375458c/pyOpenSSL-18.0.0-py2.py3-none-any.whl (53kB)
    100% |████████████████████████████████| 61kB 14.1MB/s 
Collecting oci==2.2.3 (from oci_cli)
  Downloading https://files.pythonhosted.org/packages/d9/e1/1301df1b5ae84aa01188e5c42b41c1ad44739449ff3af2ab81790a952bb3/oci-2.2.3-py2.py3-none-any.whl (2.0MB)
    100% |████████████████████████████████| 2.0MB 4.0MB/s 
Collecting terminaltables==3.1.0 (from oci_cli)
  Downloading https://files.pythonhosted.org/packages/9b/c4/4a21174f32f8a7e1104798c445dacdc1d4df86f2f26722767034e4de4bff/terminaltables-3.1.0.tar.gz
Collecting idna<2.7,>=2.5 (from oci_cli)
  Downloading https://files.pythonhosted.org/packages/27/cc/6dd9a3869f15c2edfab863b992838277279ce92663d334df9ecf5106f5c6/idna-2.6-py2.py3-none-any.whl (56kB)
    100% |████████████████████████████████| 61kB 12.6MB/s 
Collecting enum34; python_version < "3" (from cryptography==2.4.2->oci_cli)
  Downloading https://files.pythonhosted.org/packages/c5/db/e56e6b4bbac7c4a06de1c50de6fe1ef3810018ae11732a50f15f62c7d050/enum34-1.1.6-py2-none-any.whl
Collecting cffi!=1.11.3,>=1.7 (from cryptography==2.4.2->oci_cli)
  Downloading https://files.pythonhosted.org/packages/64/7c/27367b38e6cc3e1f49f193deb761fe75cda9f95da37b67b422e62281fcac/cffi-1.12.2.tar.gz (453kB)
    100% |████████████████████████████████| 460kB 5.1MB/s 
Collecting asn1crypto>=0.21.0 (from cryptography==2.4.2->oci_cli)
  Downloading https://files.pythonhosted.org/packages/ea/cd/35485615f45f30a510576f1a56d1e0a7ad7bd8ab5ed7cdc600ef7cd06222/asn1crypto-0.24.0-py2.py3-none-any.whl (101kB)
    100% |████████████████████████████████| 102kB 1.6MB/s 
Collecting ipaddress; python_version < "3" (from cryptography==2.4.2->oci_cli)
  Downloading https://files.pythonhosted.org/packages/fc/d0/7fc3a811e011d4b388be48a0e381db8d990042df54aa4ef4599a31d39853/ipaddress-1.0.22-py2.py3-none-any.whl
Collecting pycparser (from cffi!=1.11.3,>=1.7->cryptography==2.4.2->oci_cli)
  Downloading https://files.pythonhosted.org/packages/68/9e/49196946aee219aead1290e00d1e7fdeab8567783e83e1b9ab5585e6206a/pycparser-2.19.tar.gz (158kB)
    100% |████████████████████████████████| 163kB 4.7MB/s 
Building wheels for collected packages: cryptography
  Building wheel for cryptography (PEP 517) ... done
  Stored in directory: /tmp/tmpGBgVu5/wheels/13/ad/1b/94b787de6776646c28a03dc2f4a6387e3ab375533028c58195
Successfully built cryptography
Building wheels for collected packages: PyYAML, configparser, cx-Oracle, retrying, arrow, terminaltables, cffi, pycparser
  Building wheel for PyYAML (setup.py) ... done
  Stored in directory: /tmp/tmpGBgVu5/wheels/ad/da/0c/74eb680767247273e2cf2723482cb9c924fe70af57c334513f
  Building wheel for configparser (setup.py) ... done
  Stored in directory: /tmp/tmpGBgVu5/wheels/a3/61/79/424ef897a2f3b14684a7de5d89e8600b460b89663e6ce9d17c
  Building wheel for cx-Oracle (setup.py) ... done
  Stored in directory: /tmp/tmpGBgVu5/wheels/31/db/58/a89e912df33e3545643a49cd8bcfe0f513d101b9d115cbeae4
  Building wheel for retrying (setup.py) ... done
  Stored in directory: /tmp/tmpGBgVu5/wheels/d7/a9/33/acc7b709e2a35caa7d4cae442f6fe6fbf2c43f80823d46460c
  Building wheel for arrow (setup.py) ... done
  Stored in directory: /tmp/tmpGBgVu5/wheels/ce/4f/95/64541c7466fd88ffe72fda5164f8323c91d695c9a77072c574
  Building wheel for terminaltables (setup.py) ... done
  Stored in directory: /tmp/tmpGBgVu5/wheels/30/6b/50/6c75775b681fb36cdfac7f19799888ef9d8813aff9e379663e
  Building wheel for cffi (setup.py) ... done
  Stored in directory: /tmp/tmpGBgVu5/wheels/bb/f8/22/e3e8d9dd87e0cc6df8201325bd0ae815e701d1ef2b95571cf2
  Building wheel for pycparser (setup.py) ... done
  Stored in directory: /tmp/tmpGBgVu5/wheels/f2/9a/90/de94f8556265ddc9d9c8b271b0f63e57b26fb1d67a45564511
Successfully built PyYAML configparser cx-Oracle retrying arrow terminaltables cffi pycparser
Installing collected packages: PyYAML, configparser, six, python-dateutil, pytz, enum34, idna, pycparser, cffi, asn1crypto, ipaddress, cryptography, click, cx-Oracle, retrying, arrow, jmespath, certifi, httpsig-cffi, pyOpenSSL, oci, terminaltables, oci-cli
Successfully installed PyYAML-3.13 arrow-0.10.0 asn1crypto-0.24.0 certifi-2019.3.9 cffi-1.12.2 click-6.7 configparser-3.5.0 cryptography-2.4.2 cx-Oracle-7.0.0 enum34-1.1.6 httpsig-cffi-15.0.0 idna-2.6 ipaddress-1.0.22 jmespath-0.9.3 oci-2.2.3 oci-cli-2.5.4 pyOpenSSL-18.0.0 pycparser-2.19 python-dateutil-2.7.3 pytz-2016.10 retrying-1.3.3 six-1.11.0 terminaltables-3.1.0

===> Modify profile to update your $PATH and enable shell/tab completion now? (Y/n): n
-- If you change your mind, add 'source /export/oci/lib/lib/python2.7/site-packages/oci_cli/bin/oci_autocomplete.sh' to your rc file and restart your shell to enable tab completion.
-- You can run the CLI with '/export/oci/bin/oci'.
-- Installation successful.
-- Run the CLI with /export/oci/bin/oci --help

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha