Custom Search

Friday, June 26, 2015

How To Fix Celery ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 104] Connection reset by peer

How To Fix Celery ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 104] Connection reset by peer

1)
$ sudo rabbitmqctl add_user myuser mypassword
Creating user "myuser" ...
...done.

$ sudo rabbitmqctl add_vhost myvhost
Creating vhost "myvhost" ...
...done.

$ sudo rabbitmqctl set_permissions -p myvhost myuser ".*" ".*" ".*"
Setting permissions for user "myuser" in vhost "myvhost" ...
...done.

2)
$vim tasks.py

from celery import Celery

app = Celery('tasks', broker='amqp://myuser:mypassword@localhost/myvhost')

@app.task
def add(x, y):
    return x + y

3)
$ celery -A tasks worker --loglevel=info
[2015-06-26 23:49:25,809: WARNING/MainProcess] /home/saju/thrineshwara/myenv/local/lib/python2.7/site-packages/celery/apps/worker.py:161: CDeprecationWarning:
Starting from version 3.2 Celery will refuse to accept pickle by default.

The pickle serializer is a security concern as it may give attackers
the ability to execute any command.  It's important to secure
your broker from unauthorized access when using pickle, so we think
that enabling pickle should require a deliberate action and not be
the default choice.

If you depend on pickle then you should set a setting to disable this
warning and to be sure that everything will continue working
when you upgrade to Celery 3.2::

    CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml']

You must only enable the serializers that you will actually use.


  warnings.warn(CDeprecationWarning(W_PICKLE_DEPRECATED))

 -------------- celery@saju-Inspiron-5521 v3.1.18 (Cipater)
---- **** -----
--- * ***  * -- Linux-3.11.0-26-generic-x86_64-with-Ubuntu-14.04-trusty
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app:         tasks:0x7f6e3f1e71d0
- ** ---------- .> transport:   amqp://myuser:**@localhost:5672/myvhost
- ** ---------- .> results:     disabled
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ----
--- ***** ----- [queues]
 -------------- .> celery           exchange=celery(direct) key=celery
               

[tasks]
  . tasks.add

[2015-06-26 23:49:25,824: INFO/MainProcess] Connected to amqp://myuser:**@127.0.0.1:5672/myvhost
[2015-06-26 23:49:25,890: INFO/MainProcess] mingle: searching for neighbors
[2015-06-26 23:49:26,914: INFO/MainProcess] mingle: all alone
[2015-06-26 23:49:27,088: WARNING/MainProcess] celery@saju-Inspiron-5521 ready.


Thursday, June 25, 2015

How to juniper vSRX add new License Key

root@% cli
root> show system license

1)
My license

https://download.juniper.net/cust-svc/srx/E419777401.txt
E419777401 aeaqic apaeor 4altdy arwhqb impacr i6bmed
           embrgu ydgmbz bqihmu 2slawu u5lonf ygk4sf
           ozqwyb ziukrz o4t4tq 73ypay 2pgysd icl7im
           u5x4l3 4pgvmf cggson fslbu7 atr27n sh6zqe
           s2rq
          

root> request system license add my-license-file.txt

root> show system license
       









Installing Juniper Firefly Perimeter (vSRX) in VirtualBox

1)
Download junos-vsrx

junos-vsrx-12.1X47-D20.7-domestic.ova

http://www.juniper.net/us/en/products-services/security/srx-series/vsrx/#sw

2)
Untar

#tar -xvf junos-vsrx-12.1X47-D20.7-domestic.ova

3)
Convert to vdi

#vboxmanage clonehd -format VDI junos-vsrx-12.1X47-D20.7-domestic-disk1.vmdk junos-vsrx-12.1X47-D20.7-domestic-disk1-1.vdi

4)
Create a Virtualbox VM with vdi disk

5)
Login as root, no password

Thursday, June 18, 2015

Git How to search in diff and commit message and find commit id

1)
Dump all commits of file src/config/schema-transformer/to_bgp.py

#git log -p src/config/schema-transformer/to_bgp.py > output.txt

2)
Open the dump filed output.txt and search.
#vim output.txt




Wednesday, June 10, 2015

How to contrail stop and start supervisor-webui and supervisor-analytics services

How to opencontrail stop and start supervisor-webui and supervisor-analytics services

a)
List all supervisord services

#ps -aux | grep /usr/bin/supervisord

b)
Stop supervisor-webui service

#sudo service supervisor-webui status
#sudo service supervisor-webui stop


c)
Stop supervisor-analytics service

#sudo service supervisor-analytics status
#sudo service supervisor-analytics stop


https://github.com/Juniper/contrail-fabric-utils/blob/master/fabfile/tasks/services.py


Wednesday, June 3, 2015

How to test puppet code : Test Spec error and Compilation error

1)
#sudo apt-get install ruby
#sudo apt-get install ruby-dev


2)
http://bundler.io/
#sudo gem install bundler

3)
Clone puppet project from github and goto cloned folder and run.


#bundle install
OR
#bundle install --gemfile=Gemfile


* This will install all the dependencies defined in the "Gemfile"
* Use `bundle show [gemname]` to see where a bundled gem is installed.
* https://puppetlabs.com/blog/the-next-generation-of-puppet-module-testing

4)
Run spec tests in a clean fixtures directory

#rake spec
OR
#bundle exec rake spec

* Run "#rake" to get help page

5)
Check that your Puppet manifest conform to the style guide
#bundle exec rake lint
#bundle exec rake lint | grep ERROR

6)
To check for compilation errors and view a log of events.
#puppet apply --noop --debug manifests/init.pp



Monday, June 1, 2015

python Permanently add a directory to PYTHONPATH sys.path

1)
Print all paths

#python -c "import sys; print sys.path"

2)
Find easy-install.pth

#find /usr -name *.pth

3)
Edit easy-install.pth and add your paths

#sudo vim /usr/local/lib/python2.7/dist-packages/easy-install.pth

4)
Print all paths again

#python -c "import sys; print sys.path"


AttributeError: 'Module_six_moves_urllib_parse' object has no attribute 'SplitResult'

Fix
====
* Download debian package of python-six_1.9 and install it.
#wget http://ftp.us.debian.org/debian/pool/main/s/six/python-six_1.9.0-3_all.deb
 

#sudo apt-get install gdebi
 

#sudo gdebi python-six_1.9.0-3_all.deb
 

#python -c "import six; print six.__version__"
1.9.0


Error
=====
2015-06-01 16:25:05.536 23761 CRITICAL ec2api [-] AttributeError: 'Module_six_moves_urllib_parse' object has no attribute 'SplitResult'
2015-06-01 16:25:05.536 23761 ERROR ec2api Traceback (most recent call last):
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/usr/local/bin/ec2-api", line 10, in
2015-06-01 16:25:05.536 23761 ERROR ec2api     sys.exit(main())
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/home/saju/ec2-api/ec2api/cmd/api.py", line 34, in main
2015-06-01 16:25:05.536 23761 ERROR ec2api     server = service.WSGIService('ec2api', max_url_len=16384)
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/home/saju/ec2-api/ec2api/service.py", line 78, in __init__
2015-06-01 16:25:05.536 23761 ERROR ec2api     self.app = self.loader.load_app(name)
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/home/saju/ec2-api/ec2api/wsgi.py", line 514, in load_app
2015-06-01 16:25:05.536 23761 ERROR ec2api     return deploy.loadapp("config:%s" % self.config_path, name=name)
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
2015-06-01 16:25:05.536 23761 ERROR ec2api     return loadobj(APP, uri, name=name, **kw)
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
2015-06-01 16:25:05.536 23761 ERROR ec2api     return context.create()
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 710, in create
2015-06-01 16:25:05.536 23761 ERROR ec2api     return self.object_type.invoke(self)
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 144, in invoke
2015-06-01 16:25:05.536 23761 ERROR ec2api     **context.local_conf)
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/usr/local/lib/python2.7/dist-packages/paste/deploy/util.py", line 55, in fix_call
2015-06-01 16:25:05.536 23761 ERROR ec2api     val = callable(*args, **kw)
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/usr/local/lib/python2.7/dist-packages/paste/urlmap.py", line 31, in urlmap_factory
2015-06-01 16:25:05.536 23761 ERROR ec2api     app = loader.get_app(app_name, global_conf=global_conf)
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 350, in get_app
2015-06-01 16:25:05.536 23761 ERROR ec2api     name=name, global_conf=global_conf).create()
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 362, in app_context
2015-06-01 16:25:05.536 23761 ERROR ec2api     APP, name=name, global_conf=global_conf)
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 454, in get_context
2015-06-01 16:25:05.536 23761 ERROR ec2api     section)
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 476, in _context_from_use
2015-06-01 16:25:05.536 23761 ERROR ec2api     object_type, name=use, global_conf=global_conf)
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 406, in get_context
2015-06-01 16:25:05.536 23761 ERROR ec2api     global_conf=global_conf)
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 296, in loadcontext
2015-06-01 16:25:05.536 23761 ERROR ec2api     global_conf=global_conf)
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 337, in _loadfunc
2015-06-01 16:25:05.536 23761 ERROR ec2api     return loader.get_context(object_type, name, global_conf)
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 681, in get_context
2015-06-01 16:25:05.536 23761 ERROR ec2api     obj = lookup_object(self.spec)
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/usr/local/lib/python2.7/dist-packages/paste/deploy/util.py", line 68, in lookup_object
2015-06-01 16:25:05.536 23761 ERROR ec2api     module = __import__(parts)
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/home/saju/ec2-api/ec2api/api/__init__.py", line 31, in
2015-06-01 16:25:05.536 23761 ERROR ec2api     from ec2api.api import apirequest
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/home/saju/ec2-api/ec2api/api/apirequest.py", line 23, in
2015-06-01 16:25:05.536 23761 ERROR ec2api     from ec2api.api import cloud
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/home/saju/ec2-api/ec2api/api/cloud.py", line 28, in
2015-06-01 16:25:05.536 23761 ERROR ec2api     from ec2api.api import address
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/home/saju/ec2-api/ec2api/api/address.py", line 22, in
2015-06-01 16:25:05.536 23761 ERROR ec2api     from ec2api.api import clients
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/home/saju/ec2-api/ec2api/api/clients.py", line 17, in
2015-06-01 16:25:05.536 23761 ERROR ec2api     from novaclient import client as novaclient
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/usr/local/lib/python2.7/dist-packages/novaclient/client.py", line 38, in
2015-06-01 16:25:05.536 23761 ERROR ec2api     from oslo_utils import netutils
2015-06-01 16:25:05.536 23761 ERROR ec2api   File "/usr/local/lib/python2.7/dist-packages/oslo_utils/netutils.py", line 224, in
2015-06-01 16:25:05.536 23761 ERROR ec2api     class _ModifiedSplitResult(parse.SplitResult):
2015-06-01 16:25:05.536 23761 ERROR ec2api AttributeError: 'Module_six_moves_urllib_parse' object has no attribute 'SplitResult'
2015-06-01 16:25:05.536 23761 ERROR ec2api

How to import a module installed in /usr/local/lib/python2.7/dist-packages using pip

I am using ubuntu 14.04 and can see six in following locations.

/usr/lib/python2.7/dist-packages/six.py --- 1.5.2

/usr/local/lib/python2.7/dist-packages/six.py --- 1.9.0 (installed via #sudo pip install six)

I can't import six 1.9.0 which installed via pip
#python -c "import six; print six.__version__"
1.5.2
How to import a module installed in /usr/local/lib/python2.7/dist-packages using pip

Ans:
sounds like you installed it both from the platform's package manager and with pip. I recommend not doing that. (Dont' install with pip system-wide. Install in a virtualenv or with --user.)
There is no good way. Don't install packages system-wide except through your package manager.

Solution:

* Download debian package of python-six_1.9 and install it.
#wget http://ftp.us.debian.org/debian/pool/main/s/six/python-six_1.9.0-3_all.deb
 

#sudo apt-get install gdebi
 

#sudo gdebi python-six_1.9.0-3_all.deb
 

#python -c "import six; print six.__version__"
1.9.0












python /usr/bin/ld: cannot find -lz

Fix:
====
sudo apt-get install libz-dev

Error:
======

Running setup.py install for lxml
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
    Building lxml version 3.4.4.
    Building without Cython.
    Using build configuration of libxslt 1.1.28
    building 'lxml.etree' extension
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -I/tmp/pip_build_root/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.linux-x86_64-2.7/lxml/etree.so
    /usr/bin/ld: cannot find -lz
    collect2: error: ld returned 1 exit status
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-NhXXr1-record/install-record.txt --single-version-externally-managed --compile:
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'

/usr/bin/ld: cannot find -lz

collect2: error: ld returned 1 exit status

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

ERROR: /bin/sh: 1: xslt-config: not found

Fix
=====
sudo apt-get install libxml2-dev
sudo apt-get install libxslt1-dev
sudo apt-get install python-dev

  
Error
=====
Running setup.py install for lxml
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
    Building lxml version 3.4.4.
    Building without Cython.
    ERROR: /bin/sh: 1: xslt-config: not found
   
    ** make sure the development packages of libxml2 and libxslt are installed **
   

    Using build configuration of libxslt
    building 'lxml.etree' extension
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip_build_root/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w
    In file included from src/lxml/lxml.etree.c:239:0:
    /tmp/pip_build_root/lxml/src/lxml/includes/etree_defs.h:14:31: fatal error: libxml/xmlversion.h: No such file or directory
     #include "libxml/xmlversion.h"
                                   ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-MD0kwd-record/install-record.txt --single-version-externally-managed --compile:
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'

  warnings.warn(msg)

Building lxml version 3.4.4.

Building without Cython.

ERROR: /bin/sh: 1: xslt-config: not found

** make sure the development packages of libxml2 and libxslt are installed **


In file included from src/lxml/lxml.etree.c:239:0:

/tmp/pip_build_root/lxml/src/lxml/includes/etree_defs.h:14:31: fatal error: libxml/xmlversion.h: No such file or directory

 #include "libxml/xmlversion.h"

compilation terminated.


error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

greenlet.h:8:20: fatal error: Python.h: No such file or directory

Fix:
#sudo apt-get install python-dev


 Error:
 ========
 Running setup.py install for greenlet
    building 'greenlet' extension
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c greenlet.c -o build/temp.linux-x86_64-2.7/greenlet.o
    In file included from greenlet.c:5:0:
    greenlet.h:8:20: fatal error: Python.h: No such file or directory
     #include
                        ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/greenlet/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-pd1And-record/install-record.txt --single-version-externally-managed --compile:
    running install

running build

running build_ext

building 'greenlet' extension

creating build

creating build/temp.linux-x86_64-2.7

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c greenlet.c -o build/temp.linux-x86_64-2.7/greenlet.o

In file included from greenlet.c:5:0:

greenlet.h:8:20: fatal error: Python.h: No such file or directory

 #include

                    ^

compilation terminated.

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1