Skip to main content

Posts

Showing posts from July, 2014

Experiment with Python Ceilometer API

I will give a brief and quick introduction to Ceilometer API with python. Just noticed that there is no such example on Internet. Although it is quite easy, I thought that it may be helpful for some. Just create a python file where you store constants. By this way, it will be easy to manage them: OS_USERNAME="admin" OS_PASSWORD="PASS" OS_TENANT_NAME="admin" OS_AUTH_URL="http://controller:5000/v2.0/" CEILOMETER_ENDPOINT="http://controller:8777"

Find max positive product of three integer in an array

In careercup.com, I have seen a problem. It basically asks to get an integer array(includes positives and negatives) and return maximum positive product of three distinct element in it. Sorting is not allowed. For example: arr = [9, 10, -12, 4, 7, -8, -13, 4, -8, 12] elements = (-13, -12, 12) There are two cases: either P1*P2*P3 or N1*N2*P1(Pi stands for ith biggest and Ni stands for ith smalltest number.). So, the algorithm finds 2 elements in the array by partitioning. One is the 2nd smallest  and the other is 3rd biggest number. Then, among biggest 2 element, it finds the maximum. The latest form of array is as follows: N1,N2,...........,P3,P2,P1 It compares N1*N2 ith. P3*P2. It returns elements of bigger one with P1.

Openstack-compute on virtual machine - Unable to create an instance

I have built an openstack(icehouse) platform with three virtual machines; controller, compute and network nodes. I aim to use qemu instead of kvm for virtualization. So I have inserted the following lines into /etc/nova/nova.conf in compute node: [default] compute_driver=libvirt.LibvirtDriver [libvirt] virt_type=qemu But if an instance is tried to be created, it immediately gets into error state: Error: internal error: no supported architecture for os type 'hvm' After some research, I have found the golden information: Qemu hypervisor only supports RAW, QCOW2, VMDK virtual disk formats. Mine is VDI. I have converted the disk image into VMDK format. qemu-img convert input.vdi -O vmdk output.vmdk After running compute-vm on vmdk image, I become able to create an instance without any error.