Custom Search

Monday, May 28, 2012

Saturday, May 26, 2012

how to checkout, track and pull all remote git branches as local branches

how to checkout, track and pull all remote git branches as local branches

1) Type this command in one line and run
#for remote in `git branch -r | grep -v master `; 
do git checkout --track $remote ; done
 
2) 
#git branch 
 
3)
#git checkout somebranch
#git pull

4)
#git branch -a
 
5)
#git branch -r

Tuesday, May 22, 2012

vmware psphere find compute resource

from psphere.client import Client
from psphere.managedobjects import ComputeResource

client = Client("192.168.0.144", "root", "xxxxx")#ESXi node's IP

compute_res_list = ComputeResource.all(client)

print "=====cr_list=====", cr_list

for compute_res in compute_res_list:
    print "Compute Resource Name: ", compute_res.name



OUTPUT
=======

=====cr_list===== [psphere.managedobjects.ComputeResource object at 0xbc4f750>]

Compute Resource Name: localhost.



Note:
We can also find ComputeResource of vClient

Saturday, May 12, 2012

psphere hostsystem examples

psphere is a Python interface for the VMware vSphere Web Services SDK, a powerful API for programatically managing your VMware infrastructure.


IP of ESXi-5 Hots : 192.168.0.144


>>>
>>>
>>> from psphere.client import Client
>>>
>>> clnt = Client(server="192.168.0.144", username="root", password="xxxxx")
Logging to ~/.psphere/psphere.log at INFO level
>>>
>>>
>>> import psphere.managedobjects as mo
>>>
>>>
>>> mo.__dict__.keys()
['ResourcePool', 'HostActiveDirectoryAuthentication', 'SessionManager', 'HostDirectoryStore', 'EventHistoryCollector', 'AuthorizationManager', 'ViewManager', 'LicenseManager', 'HostLocalAccountManager', 'VirtualApp', 'Datacenter', 'InventoryView', 'ProfileComplianceManager', 'ClusterProfileManager', '__file__', 'TaskManager', 'HostPciPassthruSystem', 'HostFirmwareSystem', 'classmapper', 'EnvironmentBrowser', 'HostBootDeviceSystem', 'FileManager', 'PropertyCollector', 'HostProfile', 'EventManager', 'Datastore', 'HostPowerSystem', 'VirtualMachineSnapshot', 'ScheduledTask', 'Network', 'ClusterComputeResource', 'VirtualDiskManager', 'HostServiceSystem', 'SearchIndex', 'VirtualMachineProvisioningChecker', 'ClusterProfile', 'HostFirewallSystem', 'TaskHistoryCollector', 'IpPoolManager', 'ServiceInstance', '__builtins__', 'HostMemorySystem', 'PerformanceManager', '__name__', 'HttpNfcLease', 'CustomFieldsManager', 'DistributedVirtualSwitchManager', 'StorageResourceManager', 'HistoryCollector', 'ScheduledTaskManager', 'AlarmManager', 'HostSystem', 'ResourcePlanningManager', 'DistributedVirtualPortgroup', 'ManagedEntity', 'ComputeResource', 'HostPatchManager', 'HostSnmpSystem', 'HostDiagnosticSystem', 'UserDirectory', 'VmwareDistributedVirtualSwitch', 'ManagedObject', '__doc__', 'HostKernelModuleSystem', 'cached_property', 'HostDatastoreBrowser', 'classmap', 'ListView', 'HostVirtualNicManager', 'ProfileManager', 'LocalizationManager', 'HostDatastoreSystem', 'HostAutoStartManager', 'HostProfileManager', 'DiagnosticManager', 'Folder', 'OptionManager', 'Profile', 'VirtualMachine', 'HostHealthStatusSystem', 'ExtensibleManagedObject', 'CustomizationSpecManager', 'HostVMotionSystem', '__package__', 'Task', 'VirtualMachineCompatibilityChecker', 'OvfManager', 'HostLocalAuthentication', 'HostCpuSchedulerSystem', 'PropertyFilter', 'Alarm', 'HostStorageSystem', 'ContainerView', 'ManagedObjectView', 'HostAuthenticationManager', 'View', 'DistributedVirtualSwitch', 'LicenseAssignmentManager', 'VirtualizationManager', 'HostAuthenticationStore', 'ExtensionManager', 'HostDateTimeSystem', 'HostNetworkSystem']
>>>
>>>
>>>
>>> from psphere.managedobjects import HostSystem
>>>
>>>
>>> hosts = HostSystem.all(clnt)
>>>
>>>
>>> for host in hosts:
...     host.name
...
localhost.localdomain
>>>
>>>
>>>
>>> host = HostSystem.get(clnt, name="localhost.localdomain")
>>>
>>>
>>>
>>> host.name
localhost.localdomain
>>>
>>>
>>>
>>> host.summary.hardware
(HostHardwareSummary){
   vendor = "BIOSTAR Group"
   model = "A770E3"
   uuid = "00020003-0004-0005-0006-000700080009"
   otherIdentifyingInfo[] =
      (HostSystemIdentificationInfo){
         identifierValue = " None"
         identifierType =
            (ElementDescription){
               label = "AssetTag"
               summary = "AssetTag"
               key = "AssetTag"
            }
      },
      (HostSystemIdentificationInfo){
         identifierValue = "None"
         identifierType =
            (ElementDescription){
               label = "ServiceTag"
               summary = "ServiceTag"
               key = "ServiceTag"
            }
      },
   memorySize = 17179070464
   cpuModel = "AMD Athlon(tm) II X3 435 Processor"
   cpuMhz = 2900
   numCpuPkgs = 1
   numCpuCores = 3
   numCpuThreads = 3
   numNics = 1
   numHBAs = 6
 }
>>>
>>>
>>>
>>> host.summary.hardware.cpuModel
AMD Athlon(tm) II X3 435 Processor
>>>
>>>
>>>
>>> for vm in host.vm:
...     vm.name
...
ubuntu 12.04 real
vCenter Server Appliance5
vShield Manager
vCloud Director
vCD-1
cli-vm
>>>
>>>
>>>
>>>
>>> for vm in host.vm:
...     vm.summary.config
...
(VirtualMachineConfigSummary){
   name = "ubuntu 12.04 real"
   template = False
   vmPathName = "[datastore1] vm1/vm1.vmx"
   memorySizeMB = 1024
   numCpu = 1
   numEthernetCards = 1
   numVirtualDisks = 1
   uuid = "564d4e0a-3ca8-ebd9-8750-493b7136948b"
   instanceUuid = "52fe007b-291a-657a-3f42-ed77fb362c32"
   guestId = "ubuntu64Guest"
   guestFullName = "Ubuntu Linux (64-bit)"
   annotation = None
 }
--------------
(VirtualMachineConfigSummary){
   name = "vCenter Server Appliance5"
   template = False
   vmPathName = "[datastore1] vCenter Server Appliance5/vCenter Server Appliance5.vmx"
   memorySizeMB = 8192
   numCpu = 2
   numEthernetCards = 1
   numVirtualDisks = 2
   uuid = "564d0c4f-990f-5dea-6d5a-9d09cdfa26b2"
   instanceUuid = "526c78a5-d0ff-6470-3f04-09065a628d35"
   guestId = "sles11_64Guest"
   guestFullName = "Novell SUSE Linux Enterprise 11 (64-bit)"
   annotation = "VMware vCenter Server Appliance

Version 5.0 of VC running on SLES 11"
 }
>>>
>>>
>>>
>>>
>>> for vm in host.vm:
...     vm.summary.config.name
...     vm.summary.config.memorySizeMB
...     vm.summary.config.vmPathName
...     vm.summary.config.numCpu
...
ubuntu 12.04 real
1024
[datastore1] vm1/vm1.vmx
1
--------------
vCenter Server Appliance5
8192
[datastore1] vCenter Server Appliance5/vCenter Server Appliance5.vmx
2
>>>
>>>
>>>
>>>

Howto psphere Python interface for VMware vSphere Web Services SDK

psphere is a Python interface for the VMware vSphere Web Services SDK, a powerful API for programatically managing your VMware infrastructure.

1)
Install  psphere

$ pip install -U psphere


2)
Configure  psphere

$ cd ~
$ mkdir .psphere
$ cd .psphere
$ vim config.yaml
general:
    server: 192.168.0.144
    username: root
    password: xxxxx
    template_dir: ~/.psphere/templates/
logging:
    destination: ~/.psphere/psphere.log
    level: INFO # DEBUG, INFO, etc


3)
Open a Python Terminal and try following examples. 
IP of ESXi-5 Hots : 192.168.0.144

>>> from psphere.client import Client
>>>
>>> clnt = Client(server="192.168.0.144", username="root", password="xxxxx")
Logging to ~/.psphere/psphere.log at INFO level
>>>
>>> from psphere.managedobjects import VirtualMachine
>>>
>>> vms = VirtualMachine.all(clnt)
>>>
>>> for vm in vms:
...     vm.name
...
ubuntu 12.04 real
vCenter Server Appliance5
vShield Manager
vCloud Director
vCD-1
cli-vm
>>>
>>>
>>>
>>> vm = VirtualMachine.get(clnt, name="ubuntu 12.04 real")
>>>
>>> vm.name
ubuntu 12.04 real
>>>
>>> vm = VirtualMachine.get(clnt, name="vCenter Server Appliance5")
>>>
>>> vm.name
vCenter Server Appliance5
>>>
>>> vm.datastore
[psphere.managedobjects.Datastore object at 0xa61f610>]
>>>
>>> vm.datastore[0].name
datastore1
>>>
>>> vm.datastore[0].parent.name
datastore
>>>
>>>
>>> vm.datastore[0].host
[(DatastoreHostMount){
   key = psphere.managedobjects.HostSystem object at 0xa721750>
   mountInfo =
      (HostMountInfo){
         path = "/vmfs/volumes/4fa76f8a-f40f17b6-8aba-0030674106dd"
         accessMode = "readWrite"
         accessible = True
      }
 }]
>>>
>>>
>>> vm.datastore[0].host[0]
(DatastoreHostMount){
   key = psphere.managedobjects.HostSystem object at 0xa721750>
   mountInfo =
      (HostMountInfo){
         path = "/vmfs/volumes/4fa76f8a-f40f17b6-8aba-0030674106dd"
         accessMode = "readWrite"
         accessible = True
      }
 }
>>>
>>>
>>> vm.datastore[0].host[0].key.name
localhost.localdomain
>>>
>>>
>>> host = vm.datastore[0].host[0].key
>>>
>>> for vm in host.vm:
...     vm.name
...
ubuntu 12.04 real
vCenter Server Appliance5
vShield Manager
vCloud Director
vCD-1
cli-vm
>>>
>>>

Wednesday, May 9, 2012

how to install xen on CentOS 6

Installation of Xen on Centos 6 working


1)
# yum install bridge-utils

2)
# yum install http://au1.mirror.crc.id.au/repo/kernel-xen-release-6-3.noarch.rpm

3)
# yum install kernel-xen xen

4)
# vim vim /etc/grub.conf

4a) Before Edit

default=0
timeout=5
splashimage=(hd0,4)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32.57-1.el6xen.x86_64)
        root (hd0,4)
        kernel /boot/vmlinuz-2.6.32.57-1.el6xen.x86_64 ro root=UUID=12a3774f-45a5-4b9c-b08b-dad9b0654c2e rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM
        initrd /boot/initramfs-2.6.32.57-1.el6xen.x86_64.img
title CentOS (2.6.32-220.el6.x86_64)
        root (hd0,4)
        kernel /boot/vmlinuz-2.6.32-220.el6.x86_64 ro root=UUID=12a3774f-45a5-4b9c-b08b-dad9b0654c2e rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM
        initrd /boot/initramfs-2.6.32-220.el6.x86_64.img

4b) After Edit

default=0
timeout=5
splashimage=(hd0,4)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32.57-1.el6xen.x86_64)
        root (hd0,4)
        kernel /boot/xen.gz dom0_mem=1024M cpufreq=xen dom0_max_vcpus=1 dom0_vcpus_pin
        module /boot/vmlinuz-2.6.32.57-1.el6xen.x86_64 ro root=UUID=12a3774f-45a5-4b9c-b08b-dad9b0654c2e rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM
        module /boot/initramfs-2.6.32.57-1.el6xen.x86_64.img
title CentOS (2.6.32-220.el6.x86_64)
        root (hd0,4)
        kernel /boot/vmlinuz-2.6.32-220.el6.x86_64 ro root=UUID=12a3774f-45a5-4b9c-b08b-dad9b0654c2e rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM
        initrd /boot/initramfs-2.6.32-220.el6.x86_64.img

5)
vim /etc/sysconfig/selinux

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
#SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted


6)
Reboot into your new Xen kernel



7)
[root@localhost ~]# xm info

host                   : localhost.localdomain
release                : 2.6.32.57-1.el6xen.x86_64
version                : #1 SMP Tue Mar 20 10:23:34 EST 2012
machine                : x86_64
nr_cpus                : 2
nr_nodes               : 1
cores_per_socket       : 2
threads_per_core       : 1
cpu_mhz                : 2933
hw_caps                : bfebfbff:20100800:00000000:00000940:0008e3bd:00000000:00000001:00000000
virt_caps              :
total_memory           : 2009
free_memory            : 961
free_cpus              : 0
xen_major              : 4
xen_minor              : 1
xen_extra              : .2
xen_caps               : xen-3.0-x86_64 xen-3.0-x86_32p
xen_scheduler          : credit
xen_pagesize           : 4096
platform_params        : virt_start=0xffff800000000000
xen_changeset          : unavailable
xen_commandline        : dom0_mem=1024M cpufreq=xen dom0_max_vcpus=1 dom0_vcpus_pin
cc_compiler            : gcc version 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC)
cc_compile_by          : mockbuild
cc_compile_domain      : crc.id.au
cc_compile_date        : Mon Feb 20 12:52:37 EST 2012
xend_config_format     : 4
[root@localhost ~]#


8)
[root@localhost ~]# ls /proc/xen/
capabilities  privcmd  xenbus  xsd_kva  xsd_port
[root@localhost ~]#

Tuesday, May 8, 2012

How to delete and create openstack nova database

delete and recreate openstack nova database

mysql> drop database nova;
Query OK, 49 rows affected (1.94 sec)

mysql>
mysql>
mysql> CREATE DATABASE nova;
Query OK, 1 row affected (0.00 sec)

mysql>
mysql>
mysql> GRANT ALL PRIVILEGES ON nova.* TO 'novadbadmin'@'%'
    ->   IDENTIFIED BY 'yourpasssword';

Query OK, 0 rows affected (0.02 sec)

mysql>
mysql>
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>

root@u1204x:~# nova-manage db sync
2012-05-08 05:24:26 DEBUG nova.utils [-] backend from (pid=23587) __get_backend /usr/lib/python2.7/dist-packages/nova/utils.py:658
root@u1204x:~# 


root@u1204x:~# su -
root@u1204x:~# 



root@u1204x:~# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
92:3f:8b:8f:dd:70:46:da:af:03:4e:92:b5:84:66:51 root@u1204x
The key's randomart image is:
+--[ RSA 2048]----+
|       .E        |
|      .          |
|       o         |
|      +.o        |
|     oo+S..      |
|      oo++       |
|       +=.+      |
|       +.B..     |
|      o.+ oo.    |
+-----------------+
root@u1204x:~#  


root@u1204x:~/openstack/scripts# nova keypair-add --pub_key ~/.ssh/id_rsa.pub research_key
root@u1204x:~/openstack/scripts#






openstack how to create private network

how to create private network in Nova

root@u1204x:~# nova-manage network create private --fixed_range_v4=192.168.22.32/27 --num_networks=1 --bridge=br100 --bridge_interface=eth0 --network_size=32

2012-05-08 02:09:48 DEBUG nova.utils [req-bbffc9ea-09be-4121-8913-37b1ff2ac026 None None] backend from (pid=8157) __get_backend /usr/lib/python2.7/dist-packages/nova/utils.py:658
root@u1204x:~#




root@u1204x:~# nova-manage network list

id       IPv4                  IPv6               start address      DNS1               DNS2               VlanID             project            uuid          
2012-05-08 02:09:57 DEBUG nova.utils [req-de496dd9-51a3-4e84-af35-9a5d7efeb4fd None None] backend from (pid=8163) __get_backend /usr/lib/python2.7/dist-packages/nova/utils.py:658
2        192.168.22.32/27      None               192.168.22.34      8.8.4.4            None               None               None               505954cd-e77e-4ee3-a590-2f678afab541
root@u1204x:~#



root@u1204x:~# nova-manage fixed list


root@u1204x:~# nova-manage fixed

 

openstack how to delete network

how to delete network in Nova

root@u1204x:~# nova-manage network list
id       IPv4                  IPv6               start address      DNS1               DNS2               VlanID             project            uuid          
2012-05-08 01:52:18 DEBUG nova.utils [req-4381a60e-24f5-467e-adbb-f662de1cc713 None None] backend from (pid=6738) __get_backend /usr/lib/python2.7/dist-packages/nova/utils.py:658
1        192.168.22.32/27      None               192.168.22.34      8.8.4.4            None               None               None               c6fd11e1-101e-4e99-b256-1a842ffc10ce
root@u1204x:~#



root@u1204x:~# nova-manage network delete --uuid c6fd11e1-101e-4e99-b256-1a842ffc10ce
2012-05-08 01:57:47 DEBUG nova.utils [req-adb187d5-9eb4-41ab-80f7-4949904954bc None None] backend from (pid=7175) __get_backend /usr/lib/python2.7/dist-packages/nova/utils.py:658
root@u1204x:~#


root@u1204x:~# nova-manage network list

Friday, May 4, 2012

Creating large empty files using dd command Linux

  
1) Example to create 10GB file.

root@u1204x:~/openstack/volume# dd if=/dev/zero of=testfile bs=10M count=1024
1024+0 records in
1024+0 records out
10737418240 bytes (11 GB) copied, 93.2277 s, 115 MB/s
root@u1204x:~/openstack/volume#
root@u1204x:~/openstack/volume# ls -lsh
total 11G
11G -rw-r--r-- 1 root root 10G May  3 23:33 testfile
root@u1204x:~/openstack/volume#