當前位置: 首頁>>代碼示例>>Python>>正文


Python HandlePycurl.postData方法代碼示例

本文整理匯總了Python中openstack.utils.HandlePycurl.postData方法的典型用法代碼示例。如果您正苦於以下問題:Python HandlePycurl.postData方法的具體用法?Python HandlePycurl.postData怎麽用?Python HandlePycurl.postData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在openstack.utils.HandlePycurl的用法示例。


在下文中一共展示了HandlePycurl.postData方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: v3_addProject

# 需要導入模塊: from openstack.utils import HandlePycurl [as 別名]
# 或者: from openstack.utils.HandlePycurl import postData [as 別名]
def v3_addProject(request):
    """ Adds a project.
            Method:POST
            URI:/v3/projects
    """
    req_params = {
        "remotehost": request.POST.get("remotehost"),
        "token_id": request.POST.get("token_id"),
        "pro_desc": request.POST.get("pro_desc"),
        "domain_id": request.POST.get("domain_id"),
        "pro_name": request.POST.get("pro_name"),
    }
    data = {
        "project": {
            "description": req_params.get("pro_desc"),
            "domain_id": req_params.get("domain_id"),
            "enabled": True,
            "name": req_params.get("pro_name")
        }
    }
    head = [
        "Content-Type: application/json",
        "Accept: application/json",
        "X-Auth-Token: %s" % req_params.get("token_id"),
    ]
    parms = {
        'servername': req_params.get("remotehost"),
        'port': 5000,
        'uri': '/v3/projects'
    }
    url = 'http://%(servername)s:%(port)d%(uri)s' % parms
    hpc = HandlePycurl()
    context = hpc.postData(hpc.initCurl(), url, json.dumps(data), head)

    return HttpResponse(context)
開發者ID:RockyLiys,項目名稱:self-learning,代碼行數:37,代碼來源:views.py

示例2: v2_addService

# 需要導入模塊: from openstack.utils import HandlePycurl [as 別名]
# 或者: from openstack.utils.HandlePycurl import postData [as 別名]
def v2_addService(request):
    """ Adds a service.
            Method:POST
            URI:/v2.0/OS-KSADM/services
    """
    req_params = {
        "token_id": request.POST.get("token_id"),
        "remotehost": request.POST.get("remotehost"),
        "service_id": request.POST.get("service_id"),
        "service_name": request.POST.get("service_name"),
        "service_type": request.POST.get("service_type"),
        "service_desc": request.POST.get("service_desc"),
    }
    data = {
        "OS-KSADM:service": {
            "id": req_params.get("service_id"),
            "name": req_params.get("service_name"),
            "type": req_params.get("service_type"),
            "description": req_params.get("service_desc")
        }
    }

    head = [
        "X-Auth-Token: %s" % req_params.get("token_id"),
    ]
    parms = {
        'servername': req_params.get("remotehost"),
        'port': 35357,
        'uri': '/v2.0/OS-KSADM/services'
    }
    url = 'http://%(servername)s:%(port)d%(uri)s' % parms
    hpc = HandlePycurl()
    context = hpc.postData(hpc.initCurl(), url, json.dumps(data), head)
    return HttpResponse(context)
開發者ID:RockyLiys,項目名稱:self-learning,代碼行數:36,代碼來源:views.py

示例3: v2_createTenant

# 需要導入模塊: from openstack.utils import HandlePycurl [as 別名]
# 或者: from openstack.utils.HandlePycurl import postData [as 別名]
def v2_createTenant(request):
    """ Creates a tenant.
            Method:POST
            URI:/v2.0/tenants
    """
    req_params = {
        "token_id": request.POST.get("token_id"),
        "remotehost": request.POST.get("remotehost"),
        "tenantName": request.POST.get("tenantName"),
        "description": request.POST.get("description", "description tenant")
    }

    data = {
        "tenant": {
            "name": req_params.get("tenantName"),
            "description": req_params.get("description"),
            "enabled": True
        }
    }

    head = [
        "X-Auth-Token: %s" % req_params.get("token_id"),
    ]
    parms = {
        'servername': req_params.get("remotehost"),
        'port': 35357,
        'uri': '/v2.0/tenants'
    }
    url = 'http://%(servername)s:%(port)d%(uri)s' % parms
    hpc = HandlePycurl()
    context = hpc.postData(hpc.initCurl(), url, json.dumps(data), head)
    return HttpResponse(context)
開發者ID:RockyLiys,項目名稱:self-learning,代碼行數:34,代碼來源:views.py

示例4: v2_addUser

# 需要導入模塊: from openstack.utils import HandlePycurl [as 別名]
# 或者: from openstack.utils.HandlePycurl import postData [as 別名]
def v2_addUser(request):
    """ Adds a user.
            Method:POST
            URI:/v2.0/users
    """
    req_params = {
        "token_id": request.POST.get("token_id"),
        "remotehost": request.POST.get("remotehost"),
        "userId": request.POST.get("userId"),
        "userName": request.POST.get("userName"),
        "userEmail": request.POST.get("userEmail")
    }
    data = {
        "user": {
            "id": req_params.get("userId"),
            "name": req_params.get("userName"),
            "email": req_params.get("userEmail"),
            "enabled": True
        }
    }

    head = [
        "X-Auth-Token: %s" % req_params.get("token_id"),
    ]
    parms = {
        'servername': req_params.get("remotehost"),
        'port': 35357,
        'uri': '/v2.0/users'
    }
    url = 'http://%(servername)s:%(port)d%(uri)s' % parms
    hpc = HandlePycurl()
    context = hpc.postData(hpc.initCurl(), url, json.dumps(data), head)
    return HttpResponse(context)
開發者ID:RockyLiys,項目名稱:self-learning,代碼行數:35,代碼來源:views.py

示例5: v2_createMeteringsMeteringLabels

# 需要導入模塊: from openstack.utils import HandlePycurl [as 別名]
# 或者: from openstack.utils.HandlePycurl import postData [as 別名]
def v2_createMeteringsMeteringLabels(request):
	""" Creates a l3 metering label.
		Method:POST
		URI:/v2.0/metering/metering-labels
	"""
	data = {
		"metering_label": {
			"name": "label1",
			"description": "description of label1"
		}
	}
	token_id = '2c769e9c9eea47c8bbd2c31712c51ba1'

	head = [
		"X-Auth-Token: %s"%token_id,
		]
	parms = {
		'servername':'192.168.30.127',
		'port':9696,
		'uri':'/v2.0/metering/metering-labels'
	}
	url = 'http://%(servername)s:%(port)d%(uri)s'%parms
	hpc = HandlePycurl()
	context = hpc.postData(hpc.initCurl(),url,json.dumps(data),head)
	return HttpResponse(context)
開發者ID:RockyLiys,項目名稱:self-learning,代碼行數:27,代碼來源:views.py

示例6: v2_createMeteringsMeteringLabelsRules

# 需要導入模塊: from openstack.utils import HandlePycurl [as 別名]
# 或者: from openstack.utils.HandlePycurl import postData [as 別名]
def v2_createMeteringsMeteringLabelsRules(request):
	""" Creates a l3 metering label rule.
		Method:POST
		URI:/v2.0/metering/metering-label-rules
	"""
	data = {
		"metering_label_rule": {
			"remote_ip_prefix": "10.0.1.0/24",
			"direction": "ingress",
			"metering_label_id": "448c774e-9dbc-4d31-a864-f85ecc19bb25"
		}
	}
	token_id = '2c769e9c9eea47c8bbd2c31712c51ba1'

	head = [
		"X-Auth-Token: %s"%token_id,
		]
	parms = {
		'servername':'192.168.30.127',
		'port':9696,
		'uri':'/v2.0/metering/metering-label-rules'
	}
	url = 'http://%(servername)s:%(port)d%(uri)s'%parms
	hpc = HandlePycurl()
	context = hpc.postData(hpc.initCurl(),url,json.dumps(data),head)
	return HttpResponse(context)
開發者ID:RockyLiys,項目名稱:self-learning,代碼行數:28,代碼來源:views.py

示例7: v2_createImages

# 需要導入模塊: from openstack.utils import HandlePycurl [as 別名]
# 或者: from openstack.utils.HandlePycurl import postData [as 別名]
def v2_createImages(request):
    """ Creates a virtual machine (VM) image. (Since Image APIv2.0.)
        Method:POST
        URI:/v2/images
    """
    print request.POST

    req_params = {
        "token_id": request.POST.get("token_id"),
        "remotehost": request.POST.get("remotehost"),
        "image_name": request.POST.get("image_name"),
        "image_file": request.POST.get("image_file")
    }
    data = {
        "name": req_params.get("image_name"),
        "description": req_params.get("image_desc", req_params.get("image_name")),
        "container_format": req_params.get("container_format", "bare"),
        "disk_format": req_params.get("disk_format", "qcow2"),
        "file": req_params.get("image_file"),
        "schema": "/v2/schemas/image",
    }

    head = [
        "X-Auth-Token: %s" % req_params.get("token_id"),
    ]
    parms = {
        'servername': req_params.get("remotehost"),
        'port': 8777,
        'uri': '/v2.0/images'
    }
    url = 'http://%(servername)s:%(port)d%(uri)s' % parms
    hpc = HandlePycurl()
    context = hpc.postData(hpc.initCurl(), url, json.dumps(data), head)
    return HttpResponse(context)
開發者ID:RockyLiys,項目名稱:self-learning,代碼行數:36,代碼來源:views.py

示例8: v3_obtainAuthToken

# 需要導入模塊: from openstack.utils import HandlePycurl [as 別名]
# 或者: from openstack.utils.HandlePycurl import postData [as 別名]
def v3_obtainAuthToken(request):
    """ Authenticates and generates a token.
            Method: POST
            URI:/v3/auth/tokens
    """
    req_params = {
        "remotehost": request.POST.get("remotehost"),
        "admin_name": request.POST.get("admin_name"),
        "admin_pwd": request.POST.get("admin_pwd"),
        "project_name": request.POST.get("project_name")
    }
    print req_params
    data = {
        "auth": {
            "identity": {
                "methods": ["password"],
                "password": {
                    "user": {
                        "name": req_params.get("admin_name"),
                        "domain": {"id": "default"},
                        "password": req_params.get("admin_pwd")
                    }
                }
            },
            "scope": {
                "project": {
                    "name": req_params.get("project_name"),
                    "domain": {"id": "default"}
                }
            }
        }
    }

    parms = {
        'servername': req_params.get("remotehost"),
        'port': 5000,
        'uri': '/v3/auth/tokens'
    }
    url = 'http://%(servername)s:%(port)d%(uri)s' % parms
    hpc = HandlePycurl()
    context = hpc.postData(hpc.initCurl(), url, data=json.dumps(data), head=[], v3=True)

    return HttpResponse(context)
開發者ID:RockyLiys,項目名稱:self-learning,代碼行數:45,代碼來源:views.py

示例9: v2_updateTenant

# 需要導入模塊: from openstack.utils import HandlePycurl [as 別名]
# 或者: from openstack.utils.HandlePycurl import postData [as 別名]
def v2_updateTenant(request):
    """ Updates a tenant.
            Method:POST
            URI:/v2.0/tenants/{tenantId}
    """
    req_params = {
        "token_id": request.POST.get("token_id"),
        "remotehost": request.POST.get("remotehost"),
        "tenantId": request.POST.get("tenantId")    ,
        "tenantName": request.POST.get("tenantName"),
        "description": request.POST.get("description")
    }
    data = {
        "tenant": {
            "id": req_params.get("tenantId"),
            "name": req_params.get("tenantName"),
            "description": req_params.get("description"),
            "enabled": True
        }
    }
    token_id = 'ce894ef7c23d462fab19d8ace0b34e73'

    head = [
        "X-Auth-Token: %s" % req_params.get("token_id"),
    ]
    parms = {
        'servername': req_params.get("remotehost"),
        'port': 35357,
        'uri': '/v2.0/tenants/%(tenantId)s' % {
            "tenantId": req_params.get("tenantId")
        }
    }
    url = 'http://%(servername)s:%(port)d%(uri)s' % parms
    hpc = HandlePycurl()
    context = hpc.postData(hpc.initCurl(), url, json.dumps(data), head)
    return HttpResponse(context)
開發者ID:RockyLiys,項目名稱:self-learning,代碼行數:38,代碼來源:views.py

示例10: v2_obtainToken

# 需要導入模塊: from openstack.utils import HandlePycurl [as 別名]
# 或者: from openstack.utils.HandlePycurl import postData [as 別名]
def v2_obtainToken(request):
    """ Authenticates and generates a token. 
            uri: POST /v2.0/tokens
    """
    req_params = {
        "remotehost": request.POST.get('remotehost'),
        "tenantName": request.POST.get('tenantName'),
        "username": request.POST.get("username"),
        "password": request.POST.get('password')

    }
    data = {
        "auth": {
            "tenantName": req_params.get("tenantName"),
            "passwordCredentials": {
                "username": req_params.get("username"),
                "password": req_params.get("password")
            }
        }
    }
    parms = {
        'servername': req_params.get("remotehost"),
        'port': 5000,
        'uri': '/v2.0/tokens'
    }
    head = [
        "Content-Type: application/json",
        "Accept: application/json"
    ]

    # print request.__class__.__bases__
    url = 'http://%(servername)s:%(port)d%(uri)s' % parms
    hpc = HandlePycurl()
    context = hpc.postData(hpc.initCurl(), url, json.dumps(data), head=head)

    return HttpResponse(context)
開發者ID:RockyLiys,項目名稱:self-learning,代碼行數:38,代碼來源:views.py


注:本文中的openstack.utils.HandlePycurl.postData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。