I'm not sure it's possible to do this - the XAPI web interface is very simple - 
although I'll let someone else who knows for certain to comment too.

I just wanted to highlight that the example from the blog post was about 
creating a XenAPI plugin that allows you to upload something already existing 
on the XenServer to an external service - in this case Glance.
This plugin has been written and can be seen at 
https://github.com/openstack/nova/blob/master/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance.

The intention of this plugin is to take an image already existing on XenServer 
and push it up to Glance, or to take an image on Glance and pull it down.  It 
is not possible to use this plugin to upload an image via the XAPI www 
interface.

Bob

________________________________
From: xen-api-boun...@lists.xen.org [xen-api-boun...@lists.xen.org] on behalf 
of Agyeman B. Danso Jr. [ada...@infolocktech.com]
Sent: 18 October 2013 17:16
To: xen-api@lists.xen.org
Subject: [Xen-API] FW: Help with Uploading a file to XenSever XCP

Good afternoon team,

My team and I are working on a way to have users upload a txt, jpg, or pdf, 
like files onto our XenServer XCP. I came across your host plugin write up 
http://blogs.citrix.com/2012/08/17/hello-xen-api-host-plugin/ , and saw that 
you mentioned something about uploading images.

Will it be possible for you to assist me? We have a simple html file in the 
/opt/xensource/www,
We then added a form, to allow users who browse to the ip address of the sever 
to upload a file to it.

___________________________________________________
Index.html
<form enctype="multipart/form-data" action="save_file2.py" name="save_file2.py" 
method="post" 
style="color:#454545;font-size:16px;font-weight:normal;text-align:left;margin:10px;">
Choose a file to upload: <input type="file" name="file"><br />
<input type="submit" value="Upload"></p>
</form>
___________________________________________________
Save_file.py
#!/usr/bin/env python
import cgi, os
import cgitb; cgitb.enable()

try: # Windows needs stdio set for binary mode.
    import msvcrt
    msvcrt.setmode (0, os.O_BINARY) # stdin  = 0
    msvcrt.setmode (1, os.O_BINARY) # stdout = 1
except ImportError:
    pass

form = cgi.FieldStorage()

# A nested FieldStorage instance holds the file
fileitem = form['file']

# Test if the file was uploaded
if fileitem.filename:

   # strip leading path from file name to avoid directory traversal attacks
   fn = os.path.basename(fileitem.filename)
   open('files/' + fn, 'wb').write(fileitem.file.read())
   message = 'The file "' + fn + '" was uploaded successfully'

else:
   message = 'No file was uploaded'

print """\
Content-Type: text/html\n
<html><body>
<p>%s</p>
</body></html>
""" % (message,)
___________________________________________________

Unfortunately, when I test out the html, it returns the below error:

[cid:image001.png@01CEC8E5.E5540D80]

Can you please help me to understand what is happening, and maybe I can finally 
get this upload process to work properly.


Thank you,
Agyeman B. Danso Jr.
Security Engineer
infoLock Technologies
877.610.5625 x253 - direct
ada...@infolocktech.com<mailto:ada...@infolocktech.com>

<<inline: image001.png>>

_______________________________________________
Xen-api mailing list
Xen-api@lists.xen.org
http://lists.xen.org/cgi-bin/mailman/listinfo/xen-api

Reply via email to