diff --git a/doc/api_samples/os-user-data/userdata-post-req.json b/doc/api_samples/os-user-data/userdata-post-req.json
new file mode 100644
index 000000000000..255d14820a40
--- /dev/null
+++ b/doc/api_samples/os-user-data/userdata-post-req.json
@@ -0,0 +1,17 @@
+{
+ "server" : {
+ "name" : "new-server-test",
+ "imageRef" : "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b",
+ "flavorRef" : "http://openstack.example.com/openstack/flavors/1",
+ "metadata" : {
+ "My Server Name" : "Apache1"
+ },
+ "user_data" : "IyEvYmluL2Jhc2gKL2Jpbi9zdQplY2hvICJJIGFtIGluIHlvdSEiCg==",
+ "personality" : [
+ {
+ "path" : "/etc/banner.txt",
+ "contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA=="
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/doc/api_samples/os-user-data/userdata-post-req.xml b/doc/api_samples/os-user-data/userdata-post-req.xml
new file mode 100644
index 000000000000..f2b427c314db
--- /dev/null
+++ b/doc/api_samples/os-user-data/userdata-post-req.xml
@@ -0,0 +1,25 @@
+
+
+
+ IyEvYmluL2Jhc2gKL2Jpbi9zdQplY2hvICJJIGFtIGluIHlvdSEiCg==
+
+
+ Apache1
+
+
+
+ ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp
+ dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k
+ IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs
+ c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g
+ QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo
+ ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv
+ dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy
+ c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6
+ b25zLiINCg0KLVJpY2hhcmQgQmFjaA==
+
+
+
\ No newline at end of file
diff --git a/doc/api_samples/os-user-data/userdata-post-resp.json b/doc/api_samples/os-user-data/userdata-post-resp.json
new file mode 100644
index 000000000000..347095525e99
--- /dev/null
+++ b/doc/api_samples/os-user-data/userdata-post-resp.json
@@ -0,0 +1,16 @@
+{
+ "server": {
+ "adminPass": "bwQZtcB28c29",
+ "id": "55116d7b-2cad-4d65-9c7c-964cde61946e",
+ "links": [
+ {
+ "href": "http://openstack.example.com/v2/openstack/servers/55116d7b-2cad-4d65-9c7c-964cde61946e",
+ "rel": "self"
+ },
+ {
+ "href": "http://openstack.example.com/openstack/servers/55116d7b-2cad-4d65-9c7c-964cde61946e",
+ "rel": "bookmark"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/doc/api_samples/os-user-data/userdata-post-resp.xml b/doc/api_samples/os-user-data/userdata-post-resp.xml
new file mode 100644
index 000000000000..24f94ba218f6
--- /dev/null
+++ b/doc/api_samples/os-user-data/userdata-post-resp.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/nova/tests/integrated/api_samples/os-user-data/userdata-post-req.json.tpl b/nova/tests/integrated/api_samples/os-user-data/userdata-post-req.json.tpl
new file mode 100644
index 000000000000..fb7744a3d0a3
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-user-data/userdata-post-req.json.tpl
@@ -0,0 +1,17 @@
+{
+ "server" : {
+ "name" : "new-server-test",
+ "imageRef" : "%(host)s/openstack/images/%(image_id)s",
+ "flavorRef" : "%(host)s/openstack/flavors/1",
+ "metadata" : {
+ "My Server Name" : "Apache1"
+ },
+ "user_data" : "%(user_data)s",
+ "personality" : [
+ {
+ "path" : "/etc/banner.txt",
+ "contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA=="
+ }
+ ]
+ }
+}
diff --git a/nova/tests/integrated/api_samples/os-user-data/userdata-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-user-data/userdata-post-req.xml.tpl
new file mode 100644
index 000000000000..22ec4d5c5fea
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-user-data/userdata-post-req.xml.tpl
@@ -0,0 +1,25 @@
+
+
+
+ %(user_data)s
+
+
+ Apache1
+
+
+
+ ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp
+ dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k
+ IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs
+ c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g
+ QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo
+ ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv
+ dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy
+ c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6
+ b25zLiINCg0KLVJpY2hhcmQgQmFjaA==
+
+
+
diff --git a/nova/tests/integrated/api_samples/os-user-data/userdata-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-user-data/userdata-post-resp.json.tpl
new file mode 100644
index 000000000000..d5f030c8730b
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-user-data/userdata-post-resp.json.tpl
@@ -0,0 +1,16 @@
+{
+ "server": {
+ "adminPass": "%(password)s",
+ "id": "%(id)s",
+ "links": [
+ {
+ "href": "%(host)s/v2/openstack/servers/%(uuid)s",
+ "rel": "self"
+ },
+ {
+ "href": "%(host)s/openstack/servers/%(uuid)s",
+ "rel": "bookmark"
+ }
+ ]
+ }
+}
diff --git a/nova/tests/integrated/api_samples/os-user-data/userdata-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-user-data/userdata-post-resp.xml.tpl
new file mode 100644
index 000000000000..2ad5c102b088
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-user-data/userdata-post-resp.xml.tpl
@@ -0,0 +1,8 @@
+
+
+
+
+
+
diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py
index dc4883315747..b35dbf00d7d8 100644
--- a/nova/tests/integrated/test_api_samples.py
+++ b/nova/tests/integrated/test_api_samples.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import base64
import os
import re
import uuid
@@ -590,6 +591,28 @@ class ServerStartStopXmlTest(ServerStartStopJsonTest):
ctype = 'xml'
+class UserDataJsonTest(ApiSampleTestBase):
+ extension_name = "nova.api.openstack.compute.contrib.user_data.User_data"
+
+ def test_user_data_post(self):
+ user_data_contents = '#!/bin/bash\n/bin/su\necho "I am in you!"\n'
+ user_data = base64.b64encode(user_data_contents)
+ subs = {
+ 'image_id': fake.get_valid_image_id(),
+ 'host': self._get_host(),
+ 'user_data': user_data
+ }
+ response = self._do_post('servers', 'userdata-post-req', subs)
+
+ self.assertEqual(response.status, 202)
+ subs.update(self._get_regexes())
+ return self._verify_response('userdata-post-resp', subs, response)
+
+
+class UserDataXmlTest(UserDataJsonTest):
+ ctype = 'xml'
+
+
class FlavorsExtraDataJsonTest(ApiSampleTestBase):
extension_name = ('nova.api.openstack.compute.contrib.flavorextradata.'
'Flavorextradata')