Pages

Wednesday, October 8, 2014

List installed Python Modules.

First install the python-pip package and use "pip freeze" command to display the Modules.

[root@ceph01-server ~]# python --version
Python 2.6.6
[root@ceph01-server ~]# pip freeze
Cheetah==2.4.1
Markdown==2.0.1
PyYAML==3.10
Pygments==1.1.1
argparse==1.2.1
backports.ssl-match-hostname==3.4.0.2
boto==2.32.1
ceph-deploy==1.5.17
chardet==2.0.1
cloud-init==0.7.4
configobj==4.6.0
distribute==0.7.3
heat-cfntools==1.2.6
iniparse==0.3.1
jsonpatch==1.2
jsonpointer==1.0
ordereddict==1.1
policycoreutils-default-encoding==0.1
prettytable==0.7.2
psutil==0.6.1
pycurl==7.19.0
pygpgme==0.1
requests==1.1.0
setools==1.0
six==1.7.3
urlgrabber==3.9.1
urllib3==1.5
yum-metadata-parser==1.1.2
[root@ceph01-server ~]#

Resuming Download in Linux

wget -c Resume Unfinished Downloads

This small command can save your time and money while downloading big files so I found it useful to share with you .I was downloading a file with wget command and it was 98% downloaded and my computer turned off unexpectedly. It was a very huge file and downloading it from the beginning was a painful job. So I came  across a wget command that can be used for resuming unfinished downloads.

I found this command after reading wget manual, you can add wget -c or wget --continue to resume unfinished download.

wget -c url

Webmaster Tools errot "Warning: Missing required field "updated"" with Google Blogger

When you check your blog hosted with Blogger for Google Authorship with Rich snippet testing tool mostly you get two common warning and error messages 'Warning: Missing required field "updated".' and 'Warning: Missing required hCard "author".

Warning: Missing required field "updated"

Note: Before making any changes to the template please take the backup. Link given below will help you.

Go to Blogger Dashboard › Select Blog › Click on Template › Proceed › Edit HTML

Now press Ctrl+F to find the code timestamp-link   or  published   like below

<a class='timestamp-link' expr:href='data:post.url' rel='bookmark' title='permanent link'><abbr class='published' expr:title='data:post.timestampISO8601'><data:post.timestamp/></abbr></a>

Now care fully change it to the code below

<a class='timestamp-link' expr:href='data:post.url' rel='bookmark' title='permanent link'><abbr class='updated published' expr:title='data:post.timestampISO8601'><data:post.timestamp/></abbr></a>

Now have a smile!


You can re check this here Rich Snippet testing tool.

Tuesday, October 7, 2014

Delete a VM in an Error State in Openstack

Delete a VM in an Error State

mysql -u$MYSQL_USER -p$MYSQL_PASSWD -h$MYSQL_HOST -e 'USE nova; DELETE FROM security_group_instance_association WHERE instance_id IN (SELECT id FROM instances WHERE vm_state = "error");'
mysql -u$MYSQL_USER -p$MYSQL_PASSWD -h$MYSQL_HOST -e 'USE nova; DELETE FROM block_device_mapping WHERE instance_id IN (SELECT id FROM instances WHERE vm_state = "error");'
mysql -u$MYSQL_USER -p$MYSQL_PASSWD -h$MYSQL_HOST -e 'USE nova; DELETE FROM instance_info_caches WHERE instance_id IN (SELECT uuid FROM instances WHERE vm_state = "error");'
mysql -u$MYSQL_USER -p$MYSQL_PASSWD -h$MYSQL_HOST -e 'USE nova; UPDATE fixed_ips SET allocated = 0 WHERE instance_id IN (SELECT id FROM instances WHERE vm_state = "error");'
mysql -u$MYSQL_USER -p$MYSQL_PASSWD -h$MYSQL_HOST -e 'USE nova; DELETE FROM instances WHERE vm_state = "error";'

Resetting the Instance state once it’s in a stuck state in Openstack

Resetting the Instance state once it’s in a stuck state

$ nova list
+--------------------------------------+----------------+---------+------------------------------------------.  -------------+-------------+----------------------------------+
| ID                                                                 | Name         | Status        |   Task State  | Power State | Networks                                      |
+--------------------------------------+----------------+---------+-------------------------------------------  -------------+-------------+----------------------------------+
| ca9496e9-0bd2-4734-9cf9-eb4e264628f7 | www            | SHUTOFF | powering-on | Shutdown    | fsf-lan=10.0.3.18, 93.20.168.177  |
+--------------------------------------+----------------+---------+----------------------------------------------------------+-------------+----------------------------------+

   
Setting the fields for the instance directly in the database will allow operations on the instance (nova start or nova volume-detach for instance):

$ mysql -e "update instances set task_state = NULL, \
           vm_state = 'stopped', \
           power_state = 4 \
           where deleted = 0 and hostname = 'www' and \
           uuid = 'ca9496e9-0bd2-4734-9cf9-eb4e264628f7'" nova

Removing a Cinder volume from the MYSQL in Openstack



Get the Cinder Volume’s ID from Cinder List and use it in other commands

>>cinder list;
$> nova volume-detach testvm aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
$> cinder delete vol-00000001
Or
In mysql Server
mysql
use cidner;
SELECT id,status,attach_status,mountpoint,instance_uuid from volumes;
UPDATE volumes SET status="available", attach_status="detached", mountpoint=NULL, instance_uuid=NULL WHERE id="57b32eaf-7b71-49bf-a8fd-4115567a6cda";
SELECT id,status,attach_status,mountpoint,instance_uuid from volumes;
bye

Monday, October 6, 2014

Controlling Shell-Fork-Bombing in linux User's

ulimit: Provides control over the resources available to the  shell  and to  processes started by it, on systems that allow such control. The -H and -S options specify that the hard or soft limit is set for  the  given resource.  A hard limit cannot be increased by a non-root user once it is set; a soft limit may be  increased  up to  the value of the hard limit.  If neither -H nor -S is speci- fied, both the soft and hard limits are set.  The value of limit can be a number in the unit specified for the resource or one of the special values hard, soft, or unlimited, which stand for the current  hard  limit,  the  current  soft  limit,  and no limit, respectively.  If limit is omitted, the  current  value  of  the soft  limit  of the resource is printed, unless the -H option is given.  When more than one resource is specified, the limit name and unit are printed before the value. 

 Other options are inter-preted as follows:
-a     All current limits are reported
-b     The maximum socket buffer size
-c     The maximum size of core files created
-d     The maximum size of a process’s data segment
-e     The maximum scheduling priority ("nice")
-f     The maximum size of files written by the  shell  and  its children
-i     The maximum number of pending signals
-l     The maximum size that may be locked into memory
-m     The  maximum resident set size (many systems do not honor this limit)
-n     The maximum number of open file descriptors (most systems do not allow this value to be set)
-p     The pipe size in 512-byte blocks (this may not be set)
-q     The maximum number of bytes in POSIX message queues
-r     The maximum real-time scheduling priority
-s     The maximum stack size
-t     The maximum amount of cpu time in seconds
-u     The maximum number of processes available to a single user
-v     The maximum amount of virtual memory available to the shell
-x     The maximum number of file locks
-T     The maximum number of threads

You can add the following to bashrc file for protecting the local shell users from fork bomb attack.

#unlimit so we can run the whoami
ulimit -n 4096 -u 14335 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null

LIMITUSER=$USER
if [ -e "/usr/bin/whoami" ]; then
        LIMITUSER=`/usr/bin/whoami`
fi
if [ "$LIMITUSER" != "root" ]; then
        ulimit -n 100 -u 35 -m 200000 -d 200000 -s 8192 -c 200000 -v unlimited 2>/dev/null
else
        ulimit -n 4096 -u 14335 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null
fi