nova 通过 python curl 创建虚拟机---keystone v3
2024-09-06 18:28:02
#! /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
最新文章
- C# 解析 Json数据
- hdu2457
- redis与memcache的区别2
- 2016-08-05:samba服务器配置
- js 排列 组合 的一个简单例子
- 【分布式存储】GlusterFS failing to mount at boot with Ubuntu 14.04
- 查看 activex 组件的方法
- BitMap排序
- IIS6.0禁止用户下载txt文件
- Spring BOOT PERFORMANCE
- 贪心(哈夫曼树):HDU 5884 sort
- R语言重要数据集分析研究——  数据集本身的分析技巧
- [转载] 多图详解Spring框架的设计理念与设计模式
- 研华ADAM 6000系列型号枚举值
- nodejs之使用express框架连接mongodb数据库
- 【XSY2721】求和 杜教筛
- jmeter 二次开发
- chrome播放m3u8視頻失败
- VS2015安装ASP.NET MVC4
- scrollReveal.js页面滚动动态效果