zoukankan      html  css  js  c++  java
  • nova 通过 python curl 创建虚拟机---keystone v3

    #! /bin/python
    #coding=utf-8
    
    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
  • 相关阅读:
    hbase scan超时问题
    hadoop的shuffle和排序
    MapReduce作业的调度
    hadoop hdfs问题集锦
    JVM--双亲委派机制
    springboot快速搭建
    CircleView
    TabHost实现底部导航栏
    GridView的stretchMode属性
    Android直连SQL Server数据库
  • 原文地址:https://www.cnblogs.com/wangjq19920210/p/13372073.html
Copyright © 2011-2022 走看看