Archive

Archive for the ‘Python’ Category

Resolved – AttributeError: ‘NoneType’ object has no attribute ‘_imgName’

November 6th, 2014 Comments off

Today when I tried to list Virtual Machines on one Oracle OVMM, error message prompted:

[root@ovmm_test ~]# ovm -uadmin -ppassword vm ls
Traceback (most recent call last):
  File "/usr/bin/ovm", line 43, in ?
    ovmcli.ovmmain.main(sys.argv[1:])
  File "/usr/lib/python2.4/site-packages/ovmcli/ovmmain.py", line 122, in main
    return ovm.ovmcli.runcmd(args)
  File "/usr/lib/python2.4/site-packages/ovmcli/ovmcli.py", line 147, in runcmd
    return method(options)
  File "/usr/lib/python2.4/site-packages/ovmcli/ovmcli.py", line 1578, in do_vm_ls
    result.append((serverpool._serverPoolName, vm._imgName))
AttributeError: 'NoneType' object has no attribute '_imgName'

Then I tried list VMs by server pool:

[root@ovmm_test ~]# ovm -uadmin -ppassword vm ls -s Pool1_test
Name                 Size(MB) Mem   VCPUs Status  Server_Pool
testvm1              17750    8196  4     Running Pool1_test
testvm2               50518    8196  4     Running Pool1_test
testvm3          19546    8192  2     Running Pool1_test
testvm4          50518    20929 4     Running Pool1_test
testvm5          19546    8192  2     Running Pool1_test
[root@ovmm_test ~]# ovm -uadmin -ppassword vm ls -s Pool1_test_A
Traceback (most recent call last):
  File "/usr/bin/ovm", line 43, in ?
    ovmcli.ovmmain.main(sys.argv[1:])
  File "/usr/lib/python2.4/site-packages/ovmcli/ovmmain.py", line 122, in main
    return ovm.ovmcli.runcmd(args)
  File "/usr/lib/python2.4/site-packages/ovmcli/ovmcli.py", line 147, in runcmd
    return method(options)
  File "/usr/lib/python2.4/site-packages/ovmcli/ovmcli.py", line 1578, in do_vm_ls
    result.append((serverpool._serverPoolName, vm._imgName))
AttributeError: 'NoneType' object has no attribute '_imgName'

One pool was working and the other was not, so the problematic VMs must reside in pool Pool1_test_A.

Another symptom was that, although ovmcli wouldn't work, the OVMM GUI worked as expected and returns all the VMs.

As ovmcli read entries from Oracle DB(SID XE) on OVMM, so the issue maybe caused by the inconsistency between DB & OVMM agent DB.

I got the list of all VMs on the problematic server pool from OVMM GUI, and then ran the following query to get all entries in DB:

select IMG_NAME from OVS_VM_IMG where SITE_ID=110 and STATUS !='Running' and length(IMG_NAME)>50; #Pool1_test_A was with ID 110, got from table OVS_SITE. I used length() here because in the problematic server pool, VMs all should have IMG_NAME with more than 50 characters; if less than 50, then they were VM templates which should have no issue

Comparing the output from OVMM GUI & OVM DB, I found some entries which only existed in DB. And for all of these entries, they all had "Status" in "Creating", and also the

select IMG_NAME from OVS_VM_IMG where STATUS='Creating';

Then I removed these weird entries:

delete from OVS_VM_IMG where SITE_ID=110 and STATUS !='Running' and length(IMG_NAME)>50; #you can try rename/drop table OVS_VM_IMG(alter table TBL1 rename to TBL2; drop table TBL1), remove entries in backup table(OVS_VM_IMG_bak20141106), and then rename backup table(OVS_VM_IMG_bak20141106) to OVS_VM_IMG if failed at this step caused by foreign key or other reasons (don't do this, it will cause problem about constraints etc)

After this, the issue got resolved.

PS:

  1. After you removed entries with STATUS being "Creating", and if you found some more entries of this kind occurred in OVM DB, then maybe it's caused by VM templates not working or DB table corrupted. In this case, you'll need recover OVMM by rollong back to previous version of your backup, and then import VM templates/VM images etc.
  2. Actually the issue was caused by breaking constraint(constraint name conflicts caused by table backups. So better not to backup table when doing operation against OVMM DB using sql directly). This issue can be resolved by alter constraint name, and later remove backup tables.

quick configuration of python httpd server

November 28th, 2013 Comments off

Let's assume that you want to copy files from server A to server B, and you have found that no scp available, but wget is there for use. Then you can try run one python command and use wget to download files from server A.

Here's the steps:

On server A:

cd <directory of files you want to copy>

python -m SimpleHTTPServer 8080 #notice the output of this command, for example, "Serving HTTP on 0.0.0.0 port 8080 ..."

Now you can open browser and visit http://<hostname of server A>:8080. You will notice files are there now.

On server B:

wget http://<hostname of server A>:8080/<files to copy>

After you've copied files, you can press control+c to terminate that python http server on Server A. (Or you can press ctrl+z, and then %<job id> & to make that python httpd server run in background)

quick configuration of httpd /var/tmp

July 8th, 2013 Comments off

yum -y install httpd

vi /etc/httpd/conf/httpd.conf

Alias /test /var/tmp
<Directory /var/tmp>
Options +Indexes
Order allow,deny
Allow from all
</Directory>

apachectl restart

Now copy files to /var/tmp and visit http://<ip address>/test

PS:

1. If you the installation of httpd server is not possibe, you can try the easier way of python httpd server here quick configuration of python httpd server.

2. If you want to share /var/tmp so that others can mount it as NFS share, you can do the following:

echo "/var/tmp *(rw)" >> /etc/exports

exportfs -a

/etc/init.d/nfs start

Then on the host you want to mount the NFS share, do the following:

mount -t nfs slc03nsv:/var/tmp /mnt

3. Want to write .htaccess for 301 redirect? Then you can refer to Three types of 301 rewrite/redirect for apache httpd server and apache rewrite with and without ending slash.

4. Here's a guide for nginx installation with a bash script: Install nginx reverse proxy server under centos(bash shell) and the way to get the real user ip address when using nginx as reverse proxy(from backend apache server) & logrotate linux log files.

5. Now your boss asked you to have a monitor of enterprise's website, than you may find the following article useful - Auto-monitor your server status and restart or reboot server(bash shell script) and awstats installation and configuration guide on linux centos.

6. Your httpd server is now under DDos Attack? I've undergone this, you can read the stories resolved – port 53 dns flooding attack.

7. You'll be sure to met some errors when you handled linux httpd server a lot, here're several of them Resolved – ld.so.1: httpd: fatal: libaprutil-0.so.0: open failed: No such file or directory & Solved:Cannot load /etc/httpd/modules/mod_auth_mysql.so into server: libmysqlclient.so.15: cannot open shared object file: No such file or directory & resolved awstats 500 internal server error after installation on centos linux.

Categories: IT Architecture, Linux, Python, Systems Tags: