Ask Your Question
0

copy a file while creating a vm

asked 2015-02-17 10:20:46 -0600

nutshi gravatar image

I want to copy a file from host to guest while spinning a vm .. any pointers?

Since network is not setup on my cluster ..I figured i just copy the unxibench gzip to benchmark the vm.

But what i fail to understand is how do i copy the gzip tp vm while creating the vm ? I am using this script to create vms

 server = nova.servers.create(name = vmName, image = image.id, flavor = flavor.id,  nics = nics, availability_zone  = availability_zone , userdata = user_data, key_name = key_pair.name  )

http://stackoverflow.com/questions/28...

edit retag flag offensive close merge delete

Comments

the files is 139571 bytes unixbench.gzip

nutshi gravatar imagenutshi ( 2015-02-19 15:24:45 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2015-02-18 03:58:52 -0600

Poonam Agarwal gravatar image

I think you need to consider using cloud init via horizon or writing a custom script to copy the data and passing that as an argument user-data while creating the instance

Cloud init:

#cloud-config
runcmd:

 - wget http://example.com/latest.tar.gz -P /tmp/
edit flag offensive delete link more

Comments

the problem is Poonam i do not have internet accessibility. I did think about that option but as i mentioned network/neutron is not setup so yum,apt-get,wget, curl will not work.

nutshi gravatar imagenutshi ( 2015-02-18 08:40:26 -0600 )edit
0

answered 2015-02-19 15:27:01 -0600

nutshi gravatar image

I was able to use --file version to copy a small file and test on the vm . But the issue is its not able to take the package file (unixbench.gzip)

this is the error i am getting

  File "/usr/local/lib/python2.7/dist-packages/novaclient/client.py", line 433, in request
    raise exceptions.from_response(resp, body, url, method)
novaclient.exceptions.OverLimit: Over limit (HTTP 413) (Request-ID: req-567955bf-dbc9-4f52-bcb5-1068f5a969b7)

and this is roughly the code i am using

movefile = "unixbench-5.1.2.tar.gz"
fp = gzip.open(movefile)
contents = fp.read() # contents now has the uncompressed bytes of foo.gz
fp.close()
u_str = contents.decode('utf-8') # u_str is now a unicode string
files = {"/testub":u_str}

server = nova.servers.create(name = vmName, image = image.id, flavor = flavor.id,  nics = nics, availability_zone  = availability_zone , userdata = user_data, key_name = key_pair.name , config_drive = True, files = files )

either i am doing passing the contents of the gzip incorrectly of this is not permissible ( to copy a big file on vm ) any pointers???

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2015-02-17 10:20:46 -0600

Seen: 899 times

Last updated: Feb 19 '15