#! /bin/python
#coding=utf- import urllib2
import json
import requests # token
post_url = 'http://10.249.104.81:35357/v3/auth/tokens'
postData = {
"auth": {
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"domain":{
"name":"default"
},
"name": "admin",
"password": "Qihoo360"
}
}
},
"scope": {
"project": {
"domain":{
"name":"default"
},
"name": "admin"
}
}
}
} data = json.dumps(postData)
req = urllib2.Request(post_url)
req.add_header('Content-Type','application/json')
response = urllib2.urlopen(req, data=data) header = response.headers
token_id = header['X-Subject-Token']
print token_id post_url = 'http://10.249.104.81:8774/v2/7fc59737268940cd950e0b5b4faaa2e7/servers' DICT_CREATE_INSTANCE = {
"server": {
"name": "test-test",
"imageRef": "29d2631a-9002-4368-a1f0-48804442c52b",
"flavorRef": "m1",
"networks": [{
"uuid" : "23f48b65-4174-4fc2-8512-34004563ba0b"
}],
}
} data = json.dumps(DICT_CREATE_INSTANCE)
req = urllib2.Request(post_url)
req.add_header('Content-Type','application/json')
req.add_header('X-Auth-Token',token_id)
response = urllib2.urlopen(req, data=data)
response.read()
print data

最新文章

  1. C# 解析 Json数据
  2. hdu2457
  3. redis与memcache的区别2
  4. 2016-08-05:samba服务器配置
  5. js 排列 组合 的一个简单例子
  6. 【分布式存储】GlusterFS failing to mount at boot with Ubuntu 14.04
  7. 查看 activex 组件的方法
  8. BitMap排序
  9. IIS6.0禁止用户下载txt文件
  10. Spring BOOT PERFORMANCE
  11. 贪心(哈夫曼树):HDU 5884 sort
  12. R语言重要数据集分析研究——  数据集本身的分析技巧
  13. [转载] 多图详解Spring框架的设计理念与设计模式
  14. 研华ADAM 6000系列型号枚举值
  15. nodejs之使用express框架连接mongodb数据库
  16. 【XSY2721】求和 杜教筛
  17. jmeter 二次开发
  18. chrome播放m3u8視頻失败
  19. VS2015安装ASP.NET MVC4
  20. scrollReveal.js页面滚动动态效果

热门文章

  1. R 数据读取与写入
  2. bootstrap插件-滚动监听
  3. 萌新学渗透系列之Hack The Box_Legacy
  4. leetcode 5473
  5. PHP password_needs_rehash() 函数
  6. PHP get_html_translation_table() 函数
  7. 【CSP2019】括号树 题解(递推+链表)
  8. JAVAWEB开发下常见中文乱码问题解决
  9. 秦九韶算法 & 三分法
  10. Spark Streaming——Spark第一代实时计算引擎