Step 1- Configure Yum and install dependencies
I am using Red Hat Enterprise Linux Server release 6.8 (Santiago)
# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.8 (Santiago)
Need to be root to install below packages.
#sudo su
Set proxy server:
#bash
#export http_proxy=proxy_host_name_here:port_here
#export https_proxy=proxy_host_name_here:port_here
Make sure yum is configured:
# yum repolist
Now install packages:
#sudo yum install gcc libffi-devel python-devel openssl-devel
Download EPEL(Extra Packages for Enterprise Linux). And then install python-pip.
Download RPM :
Install RPM manually:
#rpm -Uvh epel-release-6-8.noarch.rpm
Make sure 'yum repolist' is showing epel:
#yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security, ulninfo
Loading mirror speeds from cached hostfile
epel/metalink | 18 kB 00:00
* epel: fedora-epel.mirror.lstn.net
epel | 4.7 kB 00:00
epel/primary_db | 6.0 MB 00:02
repo id repo name status
APOVM34 OracleVM APOVM34 x86_64 556
UEK4 OracleVM OVM34_UEK x86_64 1,374+2
*epel Extra Packages for Enterprise Linux 6 - x86_64 12,517
ol6_UEK_latest Latest Unbreakable Enterprise Kernel for Oracle Linux 6Server (x86_64) 723+125
ol6_latest Oracle Linux 6Server Latest (x86_64) 9,143+2,605
repolist: 24,313
|
Now install pip using 'sudo yum install python-pip':
# sudo yum install python-pip
Loaded plugins: fastestmirror, refresh-packagekit, security, ulninfo
Setting up Install Process
Loading mirror speeds from cached hostfile
* epel: fedora-epel.mirror.lstn.net
Resolving Dependencies
--> Running transaction check
---> Package python-pip.noarch 0:7.1.0-1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================
Installing:
python-pip noarch 7.1.0-1.el6 epel 1.5 M
Transaction Summary
==================================================================================================================================
Install 1 Package(s)
Total download size: 1.5 M
Installed size: 6.6 M
Is this ok [y/N]: y
Downloading Packages:
python-pip-7.1.0-1.el6.noarch.rpm | 1.5 MB 00:00
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Importing GPG key 0x0608B895:
Userid : EPEL (6)
Package: epel-release-6-8.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
libvirt-client-1.2.14-19.1.el6.x86_64 is a duplicate with libvirt-client-0.10.2-62.0.1.el6_9.1.x86_64
Installing : python-pip-7.1.0-1.el6.noarch 1/1
Verifying : python-pip-7.1.0-1.el6.noarch 1/1
Installed:
python-pip.noarch 0:7.1.0-1.el6
Complete!
|
I have installed oci cli and dependencies in to /scratch/rajiv/oci.
mkdir -p /scratch/rajiv/oci
cd /scratch/rajiv/oci
Download Python 3.6 manually.
#tar -xvzf Python-3.6.0.tgz
#cd Python-3.6.0
Need to specify the path to install python. If we don't specify, it will try to install under /usr/local. And since /usr is mounted as read only in hosted Linux boxes, it will fail.
I have installed python under /scratch/rajiv/oci/python-3.6.0
#mkdir -p /scratch/rajiv/oci/python-3.6.0
Its important to specify the --prefix. Point it to the folder where you plan to install python. Otherwise it will try to install under /usr/local. And since /usr is mounted as read only in hosted Linux boxes, it will fail.
#./configure --prefix=/scratch/rajiv/oci/python-3.6.0
Now do 'make':
#make
And then do 'make install':
#sudo make install
Step 2: Installing and Configuring virtualenv
This is to create a Python virtual environment. This helps to avoid dependency hell.
#pip3 install virtualenv - didn't work
# find . -name pip3
./python-3.6.0/bin/pip3
/scratch/rajiv/oci/python-3.6.0/bin/pip3 install virtualenv
Collecting virtualenv
Downloading https://files.pythonhosted.org/packages/33/5d/314c760d4204f64e4a968275182b7751bd5c3249094757b39ba987dcfb5a/virtualenv-16.4.3-py2.py3-none-any.whl (2.0MB)
100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 2.0MB 473kB/s
Installing collected packages: virtualenv
Successfully installed virtualenv-16.4.3
You are using pip version 9.0.1, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
|
Now virtualenv installed under python 3.6 folder.
# find . -name virtualenv
./python-3.6.0/bin/virtualenv
To create a directory for storing your virtual environments, run the following command.
#mkdir -p /scratch/rajiv/oci/myvirtualspaces/virtualenvs
To create a new virtual environment without any packages, run the following command.
/scratch/rajiv/oci/python-3.6.0/bin/virtualenv myvirtualspaces/virtualenvs/cli-testing --no-site-packages
Using base prefix '/scratch/rajiv/oci/python-3.6.0'
New python executable in /scratch/rajiv/oci/myvirtualspaces/virtualenvs/cli-testing/bin/python3.6
Also creating executable in /scratch/rajiv/oci/myvirtualspaces/virtualenvs/cli-testing/bin/python
Installing setuptools, pip, wheel...
done.
|
To reference the new version of Python, run the following command with the -p parameter.
/scratch/rajiv/oci/python-3.6.0/bin/virtualenv -p /scratch/rajiv/oci/python-3.6.0 cli-testing
The path /scratch/rajiv/oci/python-3.6.0 (from --python=/scratch/rajiv/oci/python-3.6.0) is not an executable file
Step 3: Installing the Command Line Interface
#unzip oci-cli-2.5.5.zip
#cd /scratch/rajiv/oci/oci-cli
# /scratch/rajiv/oci/python-3.6.0/bin/pip3 install oci_cli-*-py2.py3-none-any.whl
This will install oci cli under /scratch/rajiv/oci/python-3.6.0/bin/oci
Token-based Authentication for the CLI
Find the location of oci cli
find . -name oci
./Python-3.6.0/build/temp.linux-x86_64-3.6/scratch/rajiv/oci
./python-3.6.0/lib/python3.6/site-packages/oci
./python-3.6.0/bin/oci
Starting a Token-based CLI Session
Need to run below step from VNC session as non root user. Otherwise it won't open the browser window.
All the steps till this point, are run as ROOT user. So need to change the file ownership of oci and all folders under that to rajiv.
'/scratch/rajiv/oci'
change ownership of oci and all folders under it:
#sudo chown -R rajiv:groups_name_here oci
Now authenticate session:
#/scratch/rajiv/oci/python-3.6.0/bin/oci session authenticate
This step ill open a browser window. Need to provide OCI tenant name and user credentials. Once auth is successful, close the browser window.
And go back to command line.
Now try below command to make sure oci cli is working: ( Try out your newly created session credentials with the following example command:)
/scratch/rajiv/oci/python-3.6.0/bin/oci iam region list --config-file /home/rajiv/.oci/config --profile DEFAULT --auth security_token
It worked!
#./python-3.6.0/bin/oci --version
2.5.5
setenv PATH $PATH\:/scratch/rajiv/oci/python-3.6.0/bin
#oci --version
2.5.5