maanantai 22. lokakuuta 2012

Eucalyptus - removing non-needed image

Optional cleanup of non-needed image

Since the 'one image approach'  had not worked (see previous post on that), I decided to remove that image. The process in brief is as follows:

  1. Deregister the image via hybridfox. For example go to the images tab and type the beginning of your image.  There is a dedicated button (red minus sign) for deregistering.
  2. Once the image is deregistered you still have the image in the s3 bucket. s3 is a key-value based datastore where the images are stored in sequence of smaller blobs.
For removing the image from the s3 buckket you need the s3cmd tool. In our environment I needed a very particular version of s3cmd that I got via our intranet (seems newer versions did not work at least in our setup). Since s3cmd is originally made for amazon,  there is a small patch to make it run on eucalyptus. I got the patch also from our intranet. S3cmd can be run on any image to remove data from s3 so I started one instance and uploaded the s3cmd tar file and the patch there.
Untar the command (creating a sub-directory where you place the tar fike; change to it) and apply patch with command
patch -p1 <../s3patch.txtMy image did not have the patch command so I installed it by setting the proxy and giving ‘yum install patch’ command.

In the s3cmd directory there are instructions in a file called INSTALL.
First you still need to apply one command due to the fact that all euca tools are python based:
python setup.py install
Then edit config file for s3cmd (you need to be in the root’s home directory)
vi .s3cfg
I had sample file for this just a couple of lines needed editing:
[default]
access_key = (look this up from the eucarc file)
...
host_base = (look this up from the eucarc file)
host_bucket = (look this up from the eucarc file)
...
secret_key = (look this up from the eucarc file)

Now s3cmd an run. Check what is on the s3 bucket store
[root@ignode ~]# s3cmd ls s3://rhel54soasuite_fullI had lots of small files. These can be deleted with s3cmd del command but unfornately there is no wild char support so write a small awk script to remove all of them

for f in $(s3cmd ls s3://rhel54soasuite_full | awk '/img.part/{print $4}'); do s3cmd del $f; done
Check what is left
[root@ignode ~]# s3cmd ls s3://rhel54soasuite_full/usr/lib/python2.6/site-packages/S3/S3.py:9: DeprecationWarning: the md5 module is deprecated; use hashlib instead
  import md5
/usr/lib/python2.6/site-packages/S3/S3.py:10: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
  import sha
Bucket 'rhel54soasuite_full':
2012-08-14 17:47    110597   s3://rhel54soasuite_full/rhel54soasuite.img.manifest.xml
Seems there is still one file. Remove the manifest file

[root@ignode ~]# s3cmd del s3://rhel54soasuite_full/rhel54soasuite.img.manifest.xml
/usr/lib/python2.6/site-packages/S3/S3.py:9: DeprecationWarning: the md5 module is deprecated; use hashlib instead
  import md5
/usr/lib/python2.6/site-packages/S3/S3.py:10: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
  import sha
Object s3://rhel54soasuite_full/rhel54soasuite.img.manifest.xml deleted
Finally remove the bucket itself with
[root@ignode ~]# s3cmd rb s3://rhel54soasuite_full
/usr/lib/python2.6/site-packages/S3/S3.py:9: DeprecationWarning: the md5 module is deprecated; use hashlib instead
  import md5
/usr/lib/python2.6/site-packages/S3/S3.py:10: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
  import sha
Bucket 'rhel54soasuite_full' removed

That’s all Folks for now on installing Oracle SOA Suite on Eucalyptus on premises cloud.

1 kommentti:

  1. Hi
    Another way to do the image deletion is with with euca2ools commands form some linux server with latest euca2ools installed.
    euca-deregister emi
    euca-delete-bundle -b bucketname --clear
    euca-deregister emi
    Also described in eucalyptus pages https://engage.eucalyptus.com/customer/portal/articles/489947

    --clear flag deletes the files from storage

    VastaaPoista