Saturday, 16 May 2020

Manage OIC Instance Services Using REST APIs


OIC REST APIs 

APIs

Oracle provide a number of API which can be use to manage the OIC (Oracle Integration Cloud) instance itself.  These API provide details about everything about the OIC integrations there connections and also current status.

These API as an Administrator allow you to manage your OIC instance very much from outside.




Prerequisite : 


1. OIC Instance 

Must have an OIC instance with  at lest developer level access.

Please sign in to your instance and see the url  it should be something like this.  Just keep this domain name handy as we need this in all our APIs.

https://<Domain Name>/ic/integration/home/faces/link


2. Postman: 

I am using this tool to fire REST APIs and getting the response back, but SOAPUI can also be used. Postman is more user friendly and have more options compare to SOAPUI for REST API. But again if you are good with SOAPUI then no compulsion to install Postman.



APIs


1.   Integrations :  

   If you want to know all your integrations in your OIC instance just use this API.  It give the full response about all the OIC integration in your OIC instance.  This require basic authentication in postman you can give same same as given below.



Now use this GET API to get information about all integrations

GET https://<Domain Name>/ic/api/integration/v1/integrations


Response:

 Response here will be detailed, It give connection been used for each of the integration and there end point details and status, package, pattern etc.


2. Connections 

This API provides all the connection which is available in OIC instance. It again require simple authentication which is been provided in point 1.

GET https://<Domain Name>/ic/api/integration/v1/connections


It provide details about each connection been created in OIC instance, its status and everything including end point. Using this end point which is again a REST API can drive details specific about this connection.


3.   Integration Details.

 
   Integration API in point 1 provide and end point for each and every integration you can use same of can built it yourself to get the details about the individual integration.

GET https://<Domain Name>/ic/api/integration/v1/integrations/<your integration ID>%<CurrentVersion of integration>


Details here are very much same as given for all integration in point 1. But here details are specific for single integration.



4. Integration Status 

 If you want to check integration status of any specific integration then use this API to know the current status of the integration

GET https://<DomainName>/ic/api/integration/v1/integrations/<Integration%Version>/activationStatus

Again if you get any difficulty in creating this API use URL from point 1 and add activationStatus to it.

Response will be :

 {   "activationStatus""ACTIVATED"}

Its shows that activation status ACTIVATED mean integration process is already activated.



5. Changing Activation Status.

 This rest API provide integration status to change to activate or configure back.

POST https://<DomainName>/ic/api/integration/v1/integrations/<Integration%Version>/

BODY {   "activationStatus""ACTIVATED"}


If there is no issue in your integration then it will activate the version given in the URL.  You can again check the status by using the API given in point 4.


There are further more REST APIs, we will check them in our next blog.  Please don't hesitate to provide your feedback good or bad. I am thankful for both.





    

Saturday, 2 May 2020

Linux Adventure - Configure Apache2 server for Python3 Flask


This post is step by step process to enable python flask  on a VPS or your Linux server. This article is written for Ubuntu server. But you can install on any other Linux flavor by changing commands  as per your Linux flavor. Please follow step by step, if any issue inbox me.


Prerequisite

Your should have sudo or root access on your Linux system and system should be connected to internet.


1) Run following command to install python3  and apache2 on your system. It will ask for input multiple times, please press 'Y' when ever it ask. In the end python3 and apache2 both will be installed in
sudo apt-get update
sudo apt-get install apache2sudo apt-get install python3

2) If you already have python2 installed on your machine. python command will still point to old python interpreter, using below commands you can make your system understand python3 is your default interprator.
python3 -V
1. run this command and add this in your ~/.bashrc file or use option 2.
alias python=python3.5 source ~/.bashrc
2. cp /usr/bin/python3 /usr/bin/python
python -- Version
>>Python 3.6.9

3) Now install wsgi and enable it using following commands.
sudo apt-get install libapache2-mod-wsgi-py3sudo a2enmod wsgi

4) Now start apache2 server, a default page will be displayed to ensure server is been started. Check page on your server ip like http://your server ip/
sudo systemctl start apache2




5) Install pip3. pip is an important command line tool to install python packages. It can search and install any python package available in repository. Now make pip3 as your, default pip for your machine, its important because all the flask related api will be installed using pip.
sudo apt-get update
sudo apt-get -y install python3-pipcp /usr/bin/pip3 /usr/bin/pip

pip --version
>> pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)


6. Now install virtual environment which is a virtual environment for python,  which will be used to execute python and related libraries.
sudo apt-get install virtualenvpip list --format=columns| grep virtualenv>>virtualenv          20.0.18
sudo pip install flask

7. Now create your Flask test application folders.  Also create the virtual environment for python flask.
mkdir /var/www/FlaskApp
virtualenv -p python3 venv
source venv/bin/activate

8) Now create folders and files given below. __init__.py is any empty file.
/var/www/FlaskApp/ /FlaskApps/__init__.py /FlaskApps/FlaskApp.py /FlaskApp.wsgi

9) Add  below content to your python file FlaskApp.py
from flask import Flaskapp = Flask(__name__)

@app.route("/")
def hello():
    return "Hello world Flask!"
if __name__ == "__main__":
    app.run()

10) Now add following content to FlaskApp.wsgi file. This file basic configuration file where apache2 configuration meet with flask project.
#! /usr/bin/python3.6

import logging
import sys
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0, '/var/www/FlaskApp/')
from FlaskApps.FlaskApp import app as application
application.secret_key = 'XXXX109001ddlo' 


11) Now go to directory /etc/apache2/sites-available and create the file FlaskApp.conf. This is basic configuration which apache2 read to run the flask configuration. Please modify this file to add your server ip address, If you are doing testing then use localhost or 127.0.0.1

<VirtualHost *:80>
     # Add machine's IP address (use ifconfig command)
     ServerName <your server ip>
     # Give an alias to to start your website url with
     WSGIScriptAlias /testFlask /var/www/FlaskApp/FlaskApp.wsgi
     <Directory /var/www/FlaskApp/>
                # set permissions as per apache2.conf file
            Options FollowSymLinks
            AllowOverride None
            Require all granted
     </Directory>
     ErrorLog ${APACHE_LOG_DIR}/error.log
     LogLevel warn
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
 

12) Now reload apache2 configuration, make the site available using following commands.
cd /etc/apache2/sites-availablesudo a2ensite FlaskApp.confsystemctl reload apache2


13) Now go to your browser, and browser using the following url http://<your server>/testFlask/ . It should appear like this.





Friday, 1 May 2020

Linux Adventure - Fixing Mysql Startup Issues

A strange issue stuck on my VPS when I was trying to restart by MySql server, its out of a sudden stop working and start throwing errors. I used certain commands to identify and want to share.


[....] Restarting mysql (via systemctl): mysql.serviceJob for mysql.service fail                                                                     ed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
 failed!

 By using the command>> status mysql.service, system shows the errors given.
mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en 
   Active: failed (Result: exit-code) since Sat 2020-05-02 03:18:01 UTC; 4s ago 
  Process: 1810 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exit 

May 02 03:18:01 vipin systemd[1]: mysql.service: Control process exited, code=ex 
May 02 03:18:01 vipin systemd[1]: mysql.service: Failed with result 'exit-code'.  
May 02 03:18:01 vipin systemd[1]: Failed to start MySQL Community Server.  
May 02 03:18:01 vipin systemd[1]: mysql.service: Service hold-off time over, sch 
May 02 03:18:01 vipin systemd[1]: mysql.service: Scheduled restart job, restart 
May 02 03:18:01 vipin systemd[1]: Stopped MySQL Community Server.
May 02 03:18:01 vipin systemd[1]: mysql.service: Start request repeated too quic  
May 02 03:18:01 vipin systemd[1]: mysql.service: Failed with result 'exit-code'. 
May 02 03:18:01 vipin systemd[1]: Failed to start MySQL Community Server. 
lines 1-14/14 (END)...skipping... 
● mysql.service - MySQL Community Server 
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) 
   Active: failed (Result: exit-code) since Sat 2020-05-02 03:18:01 UTC; 4s ago 
  Process: 1810 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
 Commend journalctl -xe has given the actual cause of errors. 
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mysql.service has begun starting up.
May 02 03:55:22 vipin mysql-systemd-start[3490]: my_print_defaults: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at
May 02 03:55:22 vipin mysql-systemd-start[3490]: my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
May 02 03:55:22 vipin mysql-systemd-start[3490]: ERROR: Unable to start MySQL server:
May 02 03:55:22 vipin mysql-systemd-start[3490]: mysqld: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 23!
May 02 03:55:22 vipin mysql-systemd-start[3490]: mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
May 02 03:55:22 vipin mysql-systemd-start[3490]: Please take a look at https://wiki.debian.org/Teams/MySQL/FAQ for tips on fixing common upgrade issu
May 02 03:55:22 vipin mysql-systemd-start[3490]: Once the problem is resolved, restart the service.
May 02 03:55:22 vipin systemd[1]: mysql.service: Control process exited, code=exited status=1
May 02 03:55:22 vipin systemd[1]: mysql.service: Failed with result 'exit-code'.
May 02 03:55:22 vipin systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mysql.service has failed.
--
-- The result is RESULT.
May 02 03:55:22 vipin systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
May 02 03:55:22 vipin systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
-- Subject: Automatic restarting of a unit has been scheduled
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
 Now its give a clear indidcation the show how file is missing with the group information added back in the file. 

vim /etc/mysql/my.cnf                                                                                                                                                       add                                                                                                                                                                           [mysqld]                                                                                                                                                                default-time-zone = "+05:30"




its started successfully now. 

Feature Selection in AI

In artifical intelegance/machine learning, everything start and end with data and in current world everyday by using facebook, insta we all ...