Monday, 22 August 2016

ADDING A NEW MULE SERVER INTO MMC ON VIRTUALBOX

Download MMC from https://www.mulesoft.com/dl/mmc

Create four VMs on Oracle VirtualBox.
[ Note to be taken here is that if in case facing any issue while ping between VMs then follow my previous blog on "3 node architecture". The communication between VMs is very important part while setting up servers on MMC ]

VMs, better to have Linux Server Distribution.

Transfer the downloaded MMC zip file to each VMs.

Now go to super user mode and unzip the file.
[ Now onward everything will be in super user mode. ]

You will see files depicted as below
[ In Linux terminal view will be different. ]



Note to be taken here is to check "truststore.jks" in


$ mule-enterprise-3.7.0/.mule/.agent/


If "truststore.jks" is present just remove it or remove .mule folder.
As soon Mule server is registered on MMC, MMC creates "truststore.jks" on Mule server for secure communication between them.
The above step has to be happened on all four VMs ]

Here in this demonstration out of four, one VM will have MMC & MULE and other VMs will have MULE running on it.

VM with MMC & MULE has to run startup.sh to start both MMC & MULE.
[ "startup.sh" present in parent directory as show in above pic ]

On other VMs to start the MULE, run following command on terminal

$ ./mule-enterprise-3.7.0/bin/mule

Note : - 
  1. Other VMs (Mule server) should have only Mule and not the MMC running on it.
  2. For proper communication between Mule and MMC, put all VM on HOST ONLY adapter
  3. NAT adapter should not be used.

Following snippet shows how it goes --->








Wednesday, 9 March 2016

KICK START WITH MULE ESB

What is Payload ?


The term 'payload' is used to distinguish between the 'interesting' information in a chunk of data or similar, and the overhead to support it. It is borrowed from transportation, where it refers to the part of the load that 'pays': for example, a tanker truck may carry 20 tons of oil, but the fully loaded vehicle weighs much more than that - there's the vehicle itself, the driver, fuel, the tank, etc. It costs money to move all these, but the customer only cares about (and pays for) the oil, hence, 'pay-load'.

In programming, the most common usage of the term is in the context of message protocols, to differentiate the protocol overhead from the actual data. Take, for example, a JSON web service response that might look like this (formatted for readability):
{
    "status":"OK",
    "data":
        {
            "message":"Hello, world!"
        }
}

In this example, the string Hello, word! is the payload, the part that the recipient is interested in; the rest, while vital information, is protocol overhead.

Another notable use of the term is in malware. Malicious software usually has two objectives: spreading itself, and performing some kind of modification on the target system (delete files, compromise system security, call home, etc.). The spreading part is the overhead, while the code that does the actual evil-doing is the payload.

Sunday, 28 February 2016

HOW TO SETUP SYNTAX HIGHLIGHTER FOR BLOGGER

There are a lot of stuff is available for syntax highlighter on google but this one I find better suited for my requirement so feels like sharing with you.

You can get reference here...

When you get logged in in your blogger account follow this step.

Template ----> Edit HTML

Inside the HTML code just before </b:skin> tag paste the following CSS code.

.code { 
background:#f5f8fa; 
background-image:none; 
background-repeat:no-repeat; 
border: solid #5C7B90; 
border-width: 1px 1px 1px 20px; 
color: #000000; 
font: 13px 'Courier New', Courier, monospace; 
line-height: 16px;
margin: 10px 0 10px 10px; 
max-height: 200px; 
min-height: 16px; 
width: 00px
overflow: scroll; 
padding: 28px 10px 10px; width: 90%; 
} 
.code: hover { 
background: #FAFAFA; background-image:none; 
background-repeat:no-repeat; 
}

You can also change the above properties according to your requirement.
How to use this class...?
<pre class="code">  
   //code goes here
</pre>


To use other highlighter paste the following scripts in your Template right before the end of <head>...
<!-- REQUIRED JAVASCRIPT LIBRARIES --> 
<link href='http://alexgorbatchev.com/pub/sh/2.1.382/styles/shCore.css' rel='stylesheet' type='text/css'/> 
<link href='http://alexgorbatchev.com/pub/sh/2.1.382/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shCore.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushCpp.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushCSharp.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushCss.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushJScript.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushPhp.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushPython.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushRuby.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushSql.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushVb.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushXml.js' type='text/javascript'/> 
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushPerl.js' type='text/javascript'/> 
<script language='javascript'>
  SyntaxHighlighter.config.bloggerMode = true; 
  SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.1.382/scripts/clipboard.swf'; 
  SyntaxHighlighter.all(); 
</script>


Here is code to show this highlighter...

Wednesday, 14 October 2015

INTEGRATING HUBOT WITH HIPCHAT


Creating Hipchat account for one admin and two users

FOR ADMIN

1. Goto www.hipchat.com

  • sign-up (Full Name, Working Email)
  • Create new team
  • Click on “No thanks, I’ll send invites later”
  • Click on Hipchat logo on top left corner
  • Group admin Users Add

The above step will add users and send invitation to their mail.

FOR USERS

2. Check your mail and join the invitation

  • Fill in details with working mail id
  • Click on Launch the web app“

3. Installing node.js and npm

4. Installing hubot yeoman generator

5. Installing the Heroku Toolbelt

6. Clone the repository

7. Configure it


$ heroku config:add HEROKU_URL=http://.herokuapp.com

Go to hipchat home page (not chat page) of one of the user or admin Accoount settings → XMPP/Jabber info

$ heroku config:add HUBOT_HIPCHAT_JID="id from above"
$ heroku config:add HUBOT_HIPCHAT_PASSWORD="password when you created account"


Logout the hipchat account which you have just registered for robot, here in this case we chose admin account for hubot.
Check on both user hipchat account that admin green bubble turned grey ;)  
8. Deploy your changes

9. Running process

AS soon as the above process run, check the hipchat user account, bot’s bubble turned to green and available.

Go to one of the room and check by texting @<your_bot_name> help, it’ll respond with some set of instructions.

[Below are some useful commands]

Stopping process
Current process state
Checking log
Restart heroku

Monday, 12 October 2015

KICK START WITH JENKINS JOB BUILDER(JJB)

What is JJB?

It’s a YAML file that enable us to write jenkins job description in human readable format and store in VCS to manage versioning on them.

Who created JJB?

Openstack Infra team.

Why JJB is created?

Jobs are stored in CI server in XML format which is not best readable format to write jenkins jobs manually so they came with JJB to manage jobs at graphical interface level.


Prerequisite:

All these commands should be run on Jenkins server

$ sudo apt-get install python-yaml
$ sudo apt-get install python-dev python-pip
$ cd jenkins-job-builder
$ sudo pip install --user -e .
$ sudo python setup.py install

Configuration:

$ nano /etc/jenkins_jobs/jenkins_jobs.ini 

[job_builder]
allow_duplicates=True
[jenkins]
user=USERNAME
password=PASSWORD
url=jenkins_url(http://localhost:8080)


Test a YAML job definition:

$ jenkins-jobs test tests/yamlparser/fixtures/templates002.yaml

The above command prints the generated Jenkins XML to the console. If you prefer to send it to a directory use following command.

$ jenkins-jobs test -o output tests/yamlparser/fixtures/templates002.yaml

The output directory will contain files with the XML configurations.

Updating Jenkins Jobs:

$  jenkins-jobs --conf /etc/jenkins_jobs/jenkins_jobs.ini update

tests/yamlparser/fixtures/templates002.yaml

OR

$ jenkins-jobs update tests/yamlparser/fixtures/templates002.yaml

The above command will update your Jenkins master with the generated jobs.

Deleting a job:

$ jenkins-jobs --conf etc/jenkins_jobs.ini delete <job-name>

Reference doc:

http://docs.openstack.org/infra/jenkins-job-builder/quick-start.html


Example: my-job.yaml

 - job:
name: my-first-job-test
description: "Checking system's uptime and polling job every minute"
project-type: freestyle
block-downstream: false
triggers:
- pollscm: '*/1 * * * *'
builders:
           - shell: |
uptime
publishers:
- email:
          recipients: test@test.com


Thursday, 30 July 2015

DIFFERENCE BETWEEN @STATICMETHOD AND @CLASSMETHOD IN PYTHON

@classmethod
To pass class as argument instead of instance(self). We could have achieved this by creating function out of class and passing that class as argument but that could raise mentainance problem in future. So to overcome this Python2.2 came up with @classmethod.

1) Maintainance Problem Causing Senario
def get_no_of_instance(ins_obj):
    return ins_obj.__class__.no_inst

class Test(object):
    no_inst = 0

    def __init__(self):
        Test.no_inst = Test.no_inst + 1

inst1 = Test()
inst2 = Test()

print get_no_of_instance(inst1)  # will output 2

2) Implementation using @classmethod
class Test(object):
    no_inst = 0

    def __init__(self):
        Test.no_inst = Test.no_inst +1

    @classmethod
    def get_no_of_instance(test_class):
        return test_class.no_inst

inst1 = Test()
inst2 = Test()

print inst1.get_no_of_instance() # will output 2
print Test.get_no_of_instance()  # will output 2

So calling @classmethod either by instance or by Class it'll pass the same argument to @classmethod.

@staticmethod
Sometimes we don't need instance method but the normal method, to access those methods we need to decorate them with @staticmethod. It's implementation is same as @classmethod but we don't pass class as argument to method. Without using decorator also we could have achieved this by creating function outside of class but it would have raised maintainance issue in future as code was increased.

1) Maintainance Problem Causing Senario
def checkTOF():
    return true

class Test(object):
    def __init__(self,data):
        self.data = data

    def play1(self):
        if checkTOF():
            print 'play one data is ',self.data

test = Test(10)
test.play1()   

2) Implemenatation using @staticmethod
class Test(object):
    def __init__(self,data):
        self.data = data

    @staticmethod
    def checkTOF():
        return 'true'

    def play1(self):
        if self.checkTOF():
            print 'play one data is ',self.data

test = Test(10)
test.play1()

So this way can bring all related code at one class.

DIFFERENCE BETWEEN BEHAVIOUR AND FUNCTIONALITY...

BEHAVIOUR: How should one act in general. For example Pen behaviour is writting, eraser baviour is erasing and mobile phone behaviour is taking and making call.

FUNCTIONALITY: Rather it is same as behaviour but it marely depend upon state. For example, though PEN's behaviour is writting but its depend upon ink is there or not, I mean Refill is filled-up or not. Though phone"s behaviour is taking and making call but it's state may vary like silent mode, ringing mode, etc.