Custom Search

Friday, March 20, 2015

python why List and Dictionaries are automatically global?


  
>>> #changing a list entry is like calling a member function on the list.
... #For example a[3]=100 is Equal to a.__setitem__(3,100)
...
>>> #Without global, an assignment creates a new local.
...
>>> #In Python, if you do not assign to a variable inside a function it
... #will look for that variable in more global scopes until it finds it.
...
>>> a = range(5)
>>> def mutate(a):
...     a[3] = 100

...
>>> mutate(a)
>>> print a[3]
100
>>>
>>>
>>>
>>> a = range(5)
>>> def mutate(b):
...     a[3] = 100

...     #Equal to a.__setitem__(3,100) 
...
>>> mutate(a)
>>> print a[3]
100
>>>
>>>
>>>
>>> a = range(5)
>>> def mutate(b):
...     b[3] = 100
...
>>> mutate(a)
>>> print a[3]
100



Wednesday, March 18, 2015

how to cassandra Convert hex byte values into a human readable format

1)
Open cassandra cli

#cassandra-cli

[..] help;
[..] show keyspaces;
[..] use config_db_uuid; <== select a keyspace/database
[..] List obj_uuid_table; <== Reading Rows and Columns of a table



* Cassandra stores all data internally as hex byte arrays by default. If you do not specify a default row key validation class, column comparator and column validation class when you define the column family, Cassandra CLI will expect input data for row keys, column names, and column values to be in hex format (and data will be returned in hex format).
http://www.datastax.com/docs/1.1/dml/using_cli


ASSUME obj_uuid_table KEYS AS utf8;
ASSUME obj_uuid_table COMPARATOR AS utf8;
ASSUME obj_uuid_table VALIDATOR AS utf8;


OR

ASSUME obj_uuid_table KEYS AS ascii;
ASSUME obj_uuid_table COMPARATOR AS ascii;
ASSUME obj_uuid_table VALIDATOR AS ascii;


[..]List obj_uuid_table <== Reading Rows and Columns of a table

2)
Reset

ASSUME obj_uuid_table KEYS AS bytes;
ASSUME obj_uuid_table COMPARATOR AS bytes;
ASSUME obj_uuid_table VALIDATOR AS bytes;



Getting Started Using the Cassandra CLI

1)
Open cassandra cli

#cassandra-cli

[..] help;
[..] show keyspaces;
[..] show schema
[..] use config_db_uuid: <== select a keyspace/database
[..]List obj_uuid_table <== Reading Rows and Columns of a table



* Cassandra stores all data internally as hex byte arrays by default. If you do not specify a default row key validation class, column comparator and column validation class when you define the column family, Cassandra CLI will expect input data for row keys, column names, and column values to be in hex format (and data will be returned in hex format).
http://www.datastax.com/docs/1.1/dml/using_cli

2)
Query from table with id


[..] get obj_uuid_table[utf8('d123ad89-f047-40ee-8878-4b9b05dfa513')];
<=== passing id of ipam in utf8()
=> (name=66715f6e616d65, value=["default-domain", "admin", "ipam34"], timestamp=1426111375529317)
=> (name=706172656e743a70726f6a6563743a35663037653331622d643961382d346539392d613963642d663039643161663164623231, value=null, timestamp=1426111375529098)
=> (name=706172656e745f74797065, value="project", timestamp=1426111375529317)
=> (name=70726f703a646973706c61795f6e616d65, value="ipam34", timestamp=1426111375529289)
=> (name=70726f703a69645f7065726d73, value={"enable": true, "uuid": {"uuid_mslong": 15070079586065137902, "uuid_lslong": 9833692915554034963}, "creator": null, "created": "2015-03-11T22:02:55.529187", "user_visible": true, "last_modified": "2015-03-11T22:02:55.529187", "permissions": {"owner": "cloud-admin", "owner_access": 7, "other_access": 7, "group": "admin", "group_access": 7}, "description": null}, timestamp=1426111375529239)
=> (name=70726f703a6e6574776f726b5f6970616d5f6d676d74, value={"ipam_dns_method": "default-dns-server", "ipam_dns_server": {"tenant_dns_server_address": {}, "virtual_dns_server_name": null}}, timestamp=1426111375529153)
=> (name=74797065, value="network_ipam", timestamp=1426111375529317)
Returned 7 results.
Elapsed time: 20 msec(s).
[..]

OR

[..]ASSUME obj_uuid_table KEYS AS utf8
[..]get obj_uuid_table['d123ad89-f047-40ee-8878-4b9b05dfa513'];



3)

Convert hex values into a human-readable format

ASSUME obj_uuid_table KEYS AS utf8;
ASSUME obj_uuid_table COMPARATOR AS utf8;
ASSUME obj_uuid_table VALIDATOR AS utf8;


OR

ASSUME obj_uuid_table KEYS AS ascii;
ASSUME obj_uuid_table COMPARATOR AS ascii;
ASSUME obj_uuid_table VALIDATOR AS ascii;


[..]List obj_uuid_table <== Reading Rows and Columns of a table


Tuesday, March 17, 2015

python StringIO usages


http://www.dotnetperls.com/stringio

http://stackoverflow.com/questions/7996479/what-is-stringio-in-python-used-for-in-reality


1)
* To unit-test a script that does a lot of printing, by redirecting sys.stdout to a StringIO instance for easy analysis;
* To create a guaranteed well-formed XML document (a custom API request) using ElementTree and then write it for sending via a HTTP connection.
* Not that you need StringIO often, but sometimes it's pretty useful.

2)
* StringIO gives you file-like access to strings, so you can use an existing module that deals with a file and change almost nothing and make it work with strings.

* For example, say you have a logger that writes things to a file and you want to instead send the log output over the network. You can read the file and write its contents to the network, or you can write the log to a StringIO object and ship it off to its network destination without touching the filesystem. StringIO makes it easy to do it the first way then switch to the second way.

3)
In cases where you want a file-like object that ACTS like a file, but is writing to an in-memory string buffer: StringIO is the tool. If you're building large strings, such as plain-text documents, and doing a lot of string concatenation, you might find it easier to just use StringIO instead of a bunch of mystr += 'more stuff\n' type of operations.




How to Apache zookeeper configure session timeout

1)
Find location of zkServer.sh script
#find / -name zkServer.sh
OR
#locate zkServer.sh

2)
#cd cd /opt/stack/contrail/third_party/zookeeper-3.4.6/bin/

saju@ubuntu:/opt/stack/contrail/third_party/zookeeper-3.4.6/bin$ ls
README.txt  zkCleanup.sh  zkCli.cmd  zkCli.sh  zkEnv.cmd  zkEnv.sh  zkServer.cmd  zkServer.sh

3)
Find zoo.cfg

saju@ubuntu:/opt/stack/contrail/third_party/zookeeper-3.4.6/bin$ ./zkServer.sh --help
JMX enabled by default
Using config: /opt/stack/contrail/third_party/zookeeper-3.4.6/bin/../conf/zoo.cfg
Usage: ./zkServer.sh {start|start-foreground|stop|restart|status|upgrade|print-cmd}

4)
Edit "zoo.cfg" and change session timeout
saju@ubuntu:/opt/stack/contrail/third_party/zookeeper-3.4.6/bin$ sudo vim ../conf/zoo.cfg

# The number of milliseconds of each tick
tickTime=20000000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/tmp/zookeeper
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

5)
Stop zookeeper
#cd /opt/stack/contrail/third_party/zookeeper-3.4.6; ./bin/zkServer.sh stop & echo $! >/home/saju/contrail-installer/status/contrail/zk.pid; fg || echo "zk failed to start" | tee "/home/saju/contrail-installer/status/contrail/zk.failure

6)
Start zookeeper
#cd /opt/stack/contrail/third_party/zookeeper-3.4.6; ./bin/zkServer.sh start & echo $! >/home/saju/contrail-installer/status/contrail/zk.pid; fg || echo "zk failed to start" | tee "/home/saju/contrail-installer/status/contrail/zk.failure



Monday, March 16, 2015

How to increment a numeric string '0000000001' in python?

>>>
>>> for x in range(1, 20):
...     "%(#)010d" % {'#': x}

...
'0000000001'
'0000000002'
'0000000003'
'0000000004'
'0000000005'
'0000000006'
'0000000007'
'0000000008'
'0000000009'
'0000000010'
'0000000011'
'0000000012'
'0000000013'
'0000000014'
'0000000015'
'0000000016'
'0000000017'
'0000000018'
'0000000019'
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> for x in range(1, 20):
...     "%(replace)010d" % {'replace': x}

...
'0000000001'
'0000000002'
'0000000003'
'0000000004'
'0000000005'
'0000000006'
'0000000007'
'0000000008'
'0000000009'
'0000000010'
'0000000011'
'0000000012'
'0000000013'
'0000000014'
'0000000015'
'0000000016'
'0000000017'
'0000000018'
'0000000019'
>>>
>>>

http://stackoverflow.com/questions/23270503/how-to-increment-a-numeric-string-0000000001-in-python


Sunday, March 15, 2015

Tutorial Cassandra Query Language (CQL) commands using cqlsh utility

The Cassandra installation includes the cqlsh utility, a python-based command line client for executing Cassandra Query Language (CQL) commands. The cqlsh command is used on the Linux or Windows command line to start the cqlsh utility.

You can use cqlsh to execute CQL commands interactively. cqlsh supports tab completion. http://www.datastax.com/documentation/cql/3.1/cql/cql_reference/cqlsh.html



#cqlsh

cqlsh> help

cqlsh> help DESCRIBE

cqlsh> DESCRIBE KEYSPACES;

cqlsh> DESCRIBE KEYSPACE [mykeyspce];

cqlsh> DESCRIBE TABLES <== Show all the tables in all keyspaces

cqlsh> help USE

cqlsh> USE [name]; <== Goto keyspace/database

cqlsh:> DESCRIBE TABLES <== Show all the tables in selected keyspace

cqlsh:> DESCRIBE TABLE  [tablename]; <== Describe the table in the selected keyspace.

cqlsh:> help SELECT


1)
Delete  Keyspace
cqlsh> DROP KEYSPACE config_db_uuid;

2)
a)
cqlsh> DESCRIBE TABLES
Keyspace "DISCOVERY_SERVER"
---------------------------
discovery

b)
cqlsh> DESCRIBE table DISCOVERY_SERVER.discovery

CREATE TABLE discovery (
  key blob,
  column1 ascii,
  column2 text,
  column3 text,
  value ascii,
  PRIMARY KEY (key, column1, column2, column3)
) WITH COMPACT STORAGE AND
  bloom_filter_fp_chance=0.010000 AND
  caching='KEYS_ONLY' AND
  comment='' AND
  dclocal_read_repair_chance=0.000000 AND
  gc_grace_seconds=0 AND
  read_repair_chance=0.100000 AND
  replicate_on_write='true' AND
  populate_io_cache_on_flush='false' AND
  compaction={'class': 'SizeTieredCompactionStrategy'} AND
  compression={'sstable_compression': 'SnappyCompressor'};

cqlsh>

c)
cqlsh> use "DISCOVERY_SERVER";
cqlsh:DISCOVERY_SERVER>

* Imp, use double quotes

d)
cqlsh:DISCOVERY_SERVER> select * from discovery limit 1;

 key                | column1 | column2                | column3        | value
--------------------+---------+------------------------+----------------+--------------------------------------------------------------------------------
 0x4f70536572766572 |  client | vpc-cfg1:ContrailWebUI | $client-entry$ | {"instances": 20, "client_type": "ContrailWebUI", "remote": "192.168.100.185"}

e)
Get all services/publisher
cqlsh:DISCOVERY_SERVER> select * from discovery where column1 = 'service' ALLOW FILTERING;

f)
Get all clients
cqlsh:DISCOVERY_SERVER> select * from discovery where column1 = 'client' ALLOW FILTERING;

g)
Get all subscribers
cqlsh:DISCOVERY_SERVER> select * from discovery where column1 = 'subscriber' ALLOW FILTERING;








OpenContrail Uses of ZooKeeper

In OpenContrail ZooKeeper is currently used for

1) master-election

* For schema-transformer: https://github.com/Juniper/contrail-controller/blob/master/src/config/schema-transformer/to_bgp.py#L3713

* For device-manager: https://github.com/Juniper/contrail-controller/blob/master/src/config/device-manager/device_manager/device_manager.py#L469

2) index-allocation

*IndexAllocator: https://github.com/Juniper/contrail-controller/blob/master/src/config/common/zkclient.py#L22

* In schema-transformer: https://github.com/Juniper/contrail-controller/blob/master/src/config/schema-transformer/to_bgp.py#L2526


* index-allocation is used for things like (virtual-network id for every VN, security-group id for every SG).There is a vn-id for every VN. this vn-id is sent across in bgp messages between control-node.

3) Arbitration reasons

* To convert fq-name to uuid when uuid not specified in requests.
* If there is 2 concurrent requests, api-server allocates/reserves a uuid in zk, that way only one create will succeed.

* create_fq_name_to_uuid_mapping: https://github.com/Juniper/contrail-controller/blob/master/src/config/api-server/vnc_cfg_ifmap.py#L1129

* ZookeeperClient: https://github.com/Juniper/contrail-controller/blob/master/src/config/common/zkclient.py#L181



How to use Apache ZooKeeper zkCli Command Line Interface

a)
Find zookeeper Cli

#locate zkCli

b)
Find process ID of zookeeper

#sudo ps -aux | grep zoo

 

c)
Find port of zookeeper using process ID

#sudo netstat -tuplen | grep 3876
tcp6       0      0 :::2181                 :::*                    LISTEN      1000       14046       3876/java      
tcp6       0      0 :::33040                :::*                    LISTEN      1000       13626       3876/java

* Two instance (port 2181 and 33040) of zookeeper service are running

d)
Connect to zookeeper server

#cd /opt/stack/contrail/third_party/zookeeper-3.4.6/bin/
#./zkCli.sh -server 192.168.56.102:2181


* http://zookeeper.apache.org/doc/r3.3.3/zookeeperStarted.html

e)
Get zookeeper Cli commands

[zk: 192.168.56.102:2181(CONNECTED) 0] help

f)
List path

[zk: 192.168.56.102:2181(CONNECTED) 13] ls /[svc-monitor, id, schema-transformer, fq-name-to-uuid, api-server, zookeeper]

* schema-transformer creates "/id"

[zk: 192.168.56.102:2181(CONNECTED) 13] ls /fq-name-to-uuid

[zk: 192.168.56.102:2181(CONNECTED) 13] ls /id

[zk: 192.168.56.102:2181(CONNECTED) 13] ls /schema-transformer

[zk: 192.168.56.102:2181(CONNECTED) 13] ls /svc-monitor

g)
Get data from path


* Get ID of default IPAM "default-network-ipam" in the "default-project" project.
[zk: 192.168.56.102:2181(CONNECTED) 36] get /fq-name-to-uuid/network_ipam:default-domain:default-project:default-network-ipam
0bee2fa4-766d-438f-9991-0fe4b34577b8

* Get ID of IPAM "ipam333" in the "admin" project.
[zk: 192.168.56.102:2181(CONNECTED) 37] get /fq-name-to-uuid/network_ipam:default-domain:admin:ipam333
1d54fc41-8697-4747-ab1f-f85ad53ac59d

h)
Set data


* Set ID of IPAM "ipam333" in the "admin" project.
[zk: 192.168.56.102:2181(CONNECTED) 44] set /fq-name-to-uuid/network_ipam:default-domain:admin:ipam333 1d54fc41-8697-4747-ab1f-f85ad53ac599

i)
Delete Path

i1)
[zk: localhost:2181(CONNECTED) 12] get /fq-name-to-uuid/global_system_config:default-global-system-config
a9f53855-477f-4509-bd40-9297470b7a0b
cZxid = 0xa
ctime = Thu Oct 15 05:42:46 UTC 2015
mZxid = 0xa
mtime = Thu Oct 15 05:42:46 UTC 2015
pZxid = 0xa
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 36
numChildren = 0

i2)
[zk: localhost:2181(CONNECTED) 12] rmr /fq-name-to-uuid/global_system_config:default-global-system-config

i3)
[zk: localhost:2181(CONNECTED) 13] get /fq-name-to-uuid/global_system_config:default-global-system-config
Node does not exist: /fq-name-to-uuid/global_system_config:default-global-system-config

Thursday, March 12, 2015

IF-MAP Visualize the content of a MAP Server

How to IF-MAP Visualize the content of a MAP Server

1)
Install Java


#sudo apt-add-repository ppa:webupd8team/java
#sudo apt-get update
#sudo apt-get install oracle-java8-installer

#sudo apt-get install oracle-java8-set-default
#java -version


2)
Download irongui

https://github.com/trustathsh/irongui/releases
#wget https://github.com/trustathsh/irongui/releases/download/v0.4.5/irongui-0.4.5-bundle.zip


3)
Unizip

#unzip irongui-0.4.5-bundle.zip
#cd irongui-0.4.5


4)
Run

#./start.sh

5)
a)

Click on "Manage IF-MAP connections" icon and open "Manage IF-MAP connections" Window.

b)
Create duplicate of "default-irond-basicauth" connection and change following settings and Click on "Test connection" button.

Endpoint: https://192.168.56.102:8443/ <== Endpoint of MAP Server
Username: api-server
PAssword: api-server
Dump: Select it <=== Required


6)
Close "Manage IF-MAP connections" Window.
Select the new connection from left navigation and click on "Start session with current selection" button.
...Done...



Wednesday, March 11, 2015

Ubuntu Install OpenSSH Server and Enable SSH from Remote Machine

1)
Check whether SSH Server running or not
#sudo netstat -tuplen | grep 22
#sudo dpkg -L ssh



2)
Install OpenSSH Server and SSH
#sudo apt-get update
#sudo apt-get install ssh

3)
Try to SSH from remote machine
#ssh username@ip-of-machine



Tuesday, March 10, 2015

How to Django Debug TransactionManagementError: Transaction managed block ended with pending COMMIT/ROLLBACK

from django.db import transaction
from saju.core.models import Agent

1)
Error Case-1
===============

@transaction.commit_manually
def f1():
    print 1
    try:
        a=Agent.objects.filter(id=454200).all()[0]
        a.contact_email="bla@blabla.com"
        a.save()   
        raise Exception("dummy exception")
    except Exception as e:
        raise e
        transaction.rollback()   
    transaction.commit()

2)
Error Case-2
===============

@transaction.commit_manually
def f1():

    print 1
    try:
        a=Agent.objects.filter(id=454200).all()[0]
        a.contact_email="bla@blabla.com"
        a.save()
    except Exception as e:
        transaction.rollback()
    raise Exception("dummy exception")   
    transaction.commit()

3)
Solution-1
===============

###How to see the Actual error ?
###Add a "try..final" block with "transaction.rollback()" to see the Actual error

@transaction.commit_manually
def f1():

    try:
        print 1
        try:
            a=Agent.objects.filter(id=454200).all()[0]
            a.contact_email="bla@blabla.com"
            a.save()   
            raise Exception("dummy exception")
        except Exception as e:
            raise e
            transaction.rollback()   
        transaction.commit()
    finally:
        transaction.rollback()



4)
Solution-2
===============

###How to see the Actual error ?
###Add a "try..final" block with "transaction.rollback()" to see the Actual error
@transaction.commit_manually
def f1():

    try:
        print 1
        try:
            a=Agent.objects.filter(id=454200).all()[0]
            a.contact_email="bla@blabla.com"
            a.save()
        except Exception as e:
            transaction.rollback()
        raise Exception("dummy exception")   
        transaction.commit()
    finally:
        transaction.rollback()





How to Django Aggregate with Distinct

1)
Open Django shell
#python manage.py shell

2)
>>>
>>>
>>> from django.db.models import Count
>>> from bla.core.models import Building
>>>
>>> Building.objects.filter(agent=454200).aggregate(count=Count('user'))
{'count': 29}
>>>

>>>
>>> Building.objects.filter(agent=454200).aggregate(count=Count('user', distinct=True))
{'count': 7}
>>>

>>>
>>>
>>>
>>> user_tot = 0
>>> for b in Building.objects.filter(agent=454200).all():
...     if b.user:
...         user_tot += 1
...
>>>
>>>

>>> user_tot
29
>>> 

>>>
>>>

Monday, March 9, 2015

How to Get the SQL Query from Django QuerySet

1)
Open django shell
#python manage.py shell

2)
Import the model class
>>> from bla.models import Building

3)
Print the SQL query
>>> print Building.objects.all().query
OR
>>> Building.objects.all().query.__str__()




Friday, March 6, 2015

OpenContrail How to Check the IF-MAP Server Population

1)
Find "ifmap_view.py" script.
#locate ifmap_view.py
/usr/local/lib/python2.7/dist-packages/schema_transformer/ifmap_view.py

2)
Run "ifmap_view.py" script by passing ifmap-server-ip, ifmap-server-port, ifmap-server-username and ifmap-server-password.

#cd /usr/local/lib/python2.7/dist-packages/schema_transformer/
OR
#cd /usr/lib/python2.7/dist-packages/schema_transformer/
 
#sudo python ifmap_view.py 192.168.56.102 8443 api-server api-server

MAP server connection  = 192.168.56.102:8443
MAP server credentials = api-server:api-server
Start node = None
Skip List = ['id-perms']
Verbose = 0

config-root = root
    domain = default-domain
    global-system-config = default-global-system-config
domain = default-domain
    namespace = default-namespace
    project = demo
        security-group = default
            access-control-list = ingress-access-control-list
            access-control-list = egress-access-control-list
    project = admin
        network-ipam = ipam444
        security-group = default
            access-control-list = ingress-access-control-list
            access-control-list = egress-access-control-list
        virtual-network = nw1
            access-control-list = nw1
                route-target = 8000001
            network-ipam = ipam444
            network-policy = default-network-policy
    project = default-project
        interface-route-table = default-interface-route-table
        network-ipam = default-network-ipam
        network-policy = default-network-policy
        route-table = default-route-table
        virtual-network = ip-fabric
            routing-instance = __default__
        virtual-network = default-virtual-network
            routing-instance = default-virtual-network
                route-target = 8000000
        virtual-network = __link_local__
            routing-instance = __link_local__
    service-template = analyzer-template
    service-template = docker-template
    service-template = nat-template
    service-template = netns-snat-template
    service-template = haproxy-loadbalancer-template
global-system-config = default-global-system-config
    global-vrouter-config = default-global-vrouter-config
    physical-router = default-physical-router
        logical-interface = default-logical-interface
        physical-interface = default-physical-interface
            logical-interface = default-logical-interface
    virtual-router = ubuntu
route-target = 8000001
route-target = 8000000


OpenContrail ZooKeeper Client

a)
Find zookeeper Cli

#locate zkCli

b)
Find process ID of zookeeper

#sudo ps -aux | grep zoo

c)
Find port of zookeeper using process ID

#sudo netstat -tuplen | grep 3876
tcp6       0      0 :::2181                 :::*                    LISTEN      1000       14046       3876/java      
tcp6       0      0 :::33040                :::*                    LISTEN      1000       13626       3876/java

* Two instance (port 2181 and 33040) of zookeeper service are running

d)
Connect to zookeeper server

#cd /opt/stack/contrail/third_party/zookeeper-3.4.6/bin/
#./zkCli.sh -server 192.168.56.102:2181


* http://zookeeper.apache.org/doc/r3.3.3/zookeeperStarted.html

e)
Get zookeeper Cli commands

[zk: 192.168.56.102:2181(CONNECTED) 0] help

f)
List path

[zk: 192.168.56.102:2181(CONNECTED) 13] ls /[svc-monitor, id, schema-transformer, fq-name-to-uuid, api-server, zookeeper]

* schema-transformer creates "/id"

[zk: 192.168.56.102:2181(CONNECTED) 13] ls /fq-name-to-uuid

[zk: 192.168.56.102:2181(CONNECTED) 13] ls /id

[zk: 192.168.56.102:2181(CONNECTED) 13] ls /schema-transformer

[zk: 192.168.56.102:2181(CONNECTED) 13] ls /svc-monitor

g)
Get data from path


* Get ID of default IPAM "default-network-ipam" in the "default-project" project.
[zk: 192.168.56.102:2181(CONNECTED) 36] get /fq-name-to-uuid/network_ipam:default-domain:default-project:default-network-ipam
0bee2fa4-766d-438f-9991-0fe4b34577b8

* Get ID of IPAM "ipam333" in the "admin" project.
[zk: 192.168.56.102:2181(CONNECTED) 37] get /fq-name-to-uuid/network_ipam:default-domain:admin:ipam333
1d54fc41-8697-4747-ab1f-f85ad53ac59d

h)
Set data


* Set ID of IPAM "ipam333" in the "admin" project.
[zk: 192.168.56.102:2181(CONNECTED) 44] set /fq-name-to-uuid/network_ipam:default-domain:admin:ipam333 1d54fc41-8697-4747-ab1f-f85ad53ac599




How to Ubuntu Install SimpleScreenRecorder and Start Recording with Audio

1)
Install Simple Screen Recorder

http://www.maartenbaert.be/simplescreenrecorder/#download

#sudo add-apt-repository ppa:maarten-baert/simplescreenrecorder
#sudo apt-get update
#sudo apt-get install simplescreenrecorder


2)
Load module-loopback to record Audio

#pactl load-module module-loopback

3)
UnLoad module-loopback After Recording

#pactl unload-module module-loopback

4)
How to Start Recording


4a)
Minimize the simplescreenrecorder window

4b)
Press "Ctrl + r" to Start the Recording
Press "Ctrl + r" again to Pause the Recording

5)
How to Stop Recording and Save it.


5a)
Press "Ctrl + r" to Pause the Recording

5b)
Open simplescreenrecorder window and click on "Save recoding" button.


Thursday, March 5, 2015

Python How to find all submodules of a module

How to find all submodules of module kazoo

>>> import kazoo
>>> import pkgutil

>>>
>>>
>>>
>>> dir(kazoo)
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__']
>>>
>>>
>>>
>>>#List all submodules of module kazoo
>>> for x in pkgutil.iter_modules(kazoo.__path__):
...     x

...
(, 'client', False)
(, 'exceptions', False)
(, 'handlers', True)
(, 'hosts', False)
(, 'interfaces', False)
(, 'loggingsupport', False)
(, 'protocol', True)
(, 'recipe', True)
(, 'retry', False)
(, 'security', False)
(, 'testing', True)
(, 'tests', True)
>>>
>>>
>>>
>>> kazoo.client
Traceback (most recent call last):
  File "", line 1, in
AttributeError: 'module' object has no attribute 'client'
>>>
>>>
>>>
>>> import kazoo.client
>>> import kazoo.exceptions
>>> import kazoo.handlers

>>>
>>>

OR



>>>#List all submodules of module kazoo
>>> for x in pkgutil.walk_packages(kazoo.__path__):
...     x

...
(, 'client', False)
(, 'exceptions', False)
(, 'handlers', True)
(, 'hosts', False)
(, 'interfaces', False)
(, 'loggingsupport', False)
(, 'protocol', True)
(, 'recipe', True)
(, 'retry', False)
(, 'security', False)
(, 'testing', True)
(, 'tests', True)
>>>
>>>
>>>

How to Install Python SimpleGUI SimpleGUICS2Pygame for your CodeSkulptor Programs

1)
Install
#pip install SimpleGUICS2Pygame

2)
#python
>>> import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
>>>
>>> #Event handler
... def tick():
...     print "tick!"
...
>>> #Register handler
... timer = simplegui.create_timer(1000,tick)
>>>
>>>
>>> #Start timer
... timer.start()
>>> tick!
tick!
tick!
tick!
tick!
tick!

How to install simplegui in Ubuntu Linux

1)
Install Tkinter
#sudo apt-get install python-tk

2)

Install simplegui
#pip install simplegui
OR
#easy_install simplegu
i