本文整理匯總了Python中openstack.utils.HandlePycurl類的典型用法代碼示例。如果您正苦於以下問題:Python HandlePycurl類的具體用法?Python HandlePycurl怎麽用?Python HandlePycurl使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了HandlePycurl類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: v3_revokeProjectUserRole
def v3_revokeProjectUserRole(request):
""" Revokes a role from a project user.
Method:DELETE
URI:/v3/projects/{project_id}/users/{user_id}/roles/{role_id}
"""
req_params = {
"remotehost": request.POST.get("remotehost"),
"token_id": request.POST.get("token_id"),
"project_id": request.POST.get("project_id"),
"user_id": request.POST.get("user_id"),
"role_id": request.POST.get("role_id"),
}
data = dict()
head = [
"X-Auth-Token: %s" % req_params.get("token_id"),
]
parms = {
'servername': req_params.get("remotehost"),
'port': 5000,
'uri': '/v3/projects/%(project_id)s/users/%(user_id)s/roles/%(role_id)s' % {
"project_id": req_params.get('project_id'),
"user_id": req_params.get('user_id'),
"role_id": req_params.get('role_id')
}
}
url = 'http://%(servername)s:%(port)d%(uri)s' % parms
hpc = HandlePycurl()
context = hpc.deleteData(hpc.initCurl(), url, head)
return HttpResponse(context or 'delete successfully')
示例2: v2_uploadImagesFile
def v2_uploadImagesFile(request):
""" Uploads binary image data. (Since Image API v2.0.)
Method:PUT
URI:/v2/images/{image_id}/file
"""
req_params = {
"token_id": request.POST.get("token_id"),
"remotehost": request.POST.get("remotehost"),
"image_id": request.POST.get("image_id")
}
head = [
"X-Auth-Token: %s" % req_params.get("token_id"),
"Content-Type: application/octet-stream"
]
parms = {
'servername': req_params.get("remotehost"),
'port': 9292,
'uri': '/v2/images/%(image_id)s/file' % {
"image_id": req_params.get("image_id")
}
}
url = 'http://%(servername)s:%(port)d%(uri)s' % parms
hpc = HandlePycurl()
context = hpc.putData(hpc.initCurl(), url, head)
return HttpResponse(context)
示例3: v2_createMeteringsMeteringLabelsRules
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)
示例4: v2_createMeteringsMeteringLabels
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)
示例5: v2_createImages
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)
示例6: v3_listProjectUserRole
def v3_listProjectUserRole(request):
""" Lists roles for a user in a project.
Method:GET
URI:/v3/projects/{project_id}/users/{user_id}/roles
"""
req_params = {
"remotehost": request.GET.get("remotehost"),
"token_id": request.GET.get("token_id"),
"project_id": request.GET.get("project_id"),
"user_id": request.GET.get('user_id')
}
head = [
"X-Auth-Token: %s" % req_params.get("token_id"),
]
parms = {
'servername': req_params.get("remotehost"),
'port': 5000,
'uri': '/v3/projects/%(project_id)s/users/%(user_id)s/roles' % {
'project_id': req_params.get('project_id'),
'user_id': req_params.get('user_id')
}
}
url = 'http://%(servername)s:%(port)d%(uri)s' % parms
hpc = HandlePycurl()
code, context = hpc.getData(hpc.initCurl(), url, head)
return HttpResponse(context)
示例7: v2_validateToken
def v2_validateToken(request):
""" Validates a token and confirms that it belongs to a specified tenant.
Method:GET
URI:/v2.0/tokens/{tokenId}{?belongsTo}
"""
req_params = {
"token_id": request.GET.get("token_id"),
"remotehost": request.GET.get("remotehost"),
}
head = [
"X-Auth-Token: %s" % req_params.get("token_id"),
"Content-Type: application/json",
"Accept: application/json"
]
parms = {
'servername': req_params.get("remotehost"),
'port': 8774,
'uri': '/v2.0/tokens/%(tokenId)s' % {
"tokenId": req_params.get("token_id")
}
}
url = 'http://%(servername)s:%(port)d%(uri)s' % parms
hpc = HandlePycurl()
context = hpc.getData(hpc.initCurl(), url, head=[])
return HttpResponse(context)
示例8: v2_infoServiceById
def v2_infoServiceById(request):
""" Gets a service.
Method:GET
URI:/v2.0/OS-KSADM/services/{serviceId}
"""
req_params = {
"token_id": request.GET.get("token_id"),
"remotehost": request.GET.get("remotehost"),
"service_id": request.GET.get("service_id"),
}
head = [
"X-Auth-Token: %s" % req_params.get("token_id"),
]
parms = {
'servername': req_params.get("remotehost"),
'port': 35357,
'uri': '/v2.0/OS-KSADM/services/%(serviceId)s' % {
"serviceId": req_params.get("service_id")
}
}
url = 'http://%(servername)s:%(port)d%(uri)s' % parms
hpc = HandlePycurl()
context = hpc.getData(hpc.initCurl(), url, head)
return HttpResponse(context)
示例9: v2_addTenantUserRole
def v2_addTenantUserRole(request):
""" Adds a specified role to a user for a tenant.
Method:PUT
URI:/v2.0/tenants/{tenantId}/users/{userId}/roles/OS-KSADM/{roleId}
"""
req_params = {
"token_id": request.POST.get("token_id"),
"remotehost": request.POST.get("remotehost"),
"tenantId": request.POST.get("tenantId") ,
"userId": request.POST.get("userId"),
"roleId": request.POST.get("roleId"),
}
head = [
"X-Auth-Token: %s" % req_params.get("token_id"),
]
parms = {
'servername': req_params.get("remotehost"),
'port': 35357,
'uri': '/v2.0/tenants/%(tenantId)s/users/%(userId)s/roles/OS-KSADM/%(roleId)s' % {
"tenantId": req_params.get("tenantId"),
"userId": req_params.get("userId"),
"roleId": req_params.get("roleId")
}
}
url = 'http://%(servername)s:%(port)d%(uri)s' % parms
hpc = HandlePycurl()
context = hpc.putData(hpc.initCurl(), url, head=head)
return HttpResponse(context)
示例10: v2_createTenant
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)
示例11: v2_deleteTenant
def v2_deleteTenant(request):
""" Deletes a tenant.
Method:DELETE
URI:/v2.0/tenants/{tenantId}
"""
req_params = {
"token_id": request.GET.get("token_id"),
"remotehost": request.GET.get("remotehost"),
"tenantId": request.GET.get("tenantId") ,
}
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.deleteData(hpc.initCurl(), url, head)
return HttpResponse(context or "delete seccussful")
示例12: v3_listUserProject
def v3_listUserProject(request):
""" List projects for a specified user.
Method:GET
URI:/v3/users/{user_id}/projects
"""
req_params = {
"remotehost": request.GET.get("remotehost"),
"token_id": request.GET.get("token_id"),
"user_id": request.GET.get("user_id")
}
head = [
"X-Auth-Token: %s" % req_params.get("token_id"),
]
parms = {
'servername': req_params.get("remotehost"),
'port': 5000,
'uri': '/v3/users/%(user_id)s/projects' % {
'user_id': req_params.get('user_id')
}
}
url = 'http://%(servername)s:%(port)d%(uri)s' % parms
hpc = HandlePycurl()
context = hpc.getData(hpc.initCurl(), url, head)
return HttpResponse(context)
示例13: v2_listTenantUserRoles
def v2_listTenantUserRoles(request):
""" Lists roles for a specified user on a specified tenant. Excludes global roles.
Method:GET
URI:/v2.0/tenants/{tenantId}/users/{userId}/roles{?limit,marker}
"""
req_params = {
"token_id": request.GET.get("token_id"),
"remotehost": request.GET.get("remotehost"),
"tenantId": request.GET.get("tenantId"),
"userId": request.GET.get("userId"),
}
head = [
"X-Auth-Token: %s" % req_params.get("token_id"),
]
parms = {
'servername': req_params.get("remotehost"),
'port': 35357,
'uri': '/v2.0/tenants/%(tenantId)s/users/%(userId)s/roles' % {
"tenantId": req_params.get("tenantId"),
"userId": req_params.get("userId")
}
}
url = 'http://%(servername)s:%(port)d%(uri)s' % parms
hpc = HandlePycurl()
context = hpc.getData(hpc.initCurl(), url, head)
return HttpResponse(context)
示例14: v2_addService
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)
示例15: v2_deleteRole
def v2_deleteRole(request):
""" Deletes a role.
Method:DELETE
URI:/v2.0/OS-KSADM/roles/{roleId}
"""
req_params = {
"token_id": request.POST.get("token_id"),
"remotehost": request.POST.get("remotehost"),
"role_id": request.POST.get("role_id")
}
head = [
"X-Auth-Token: %s" % req_params.get("token_id"),
]
parms = {
'servername': req_params.get("remotehost"),
'port': 35357,
'uri': '/v2.0/OS-KSADM/roles/%(roleId)s' % {
"roleId": req_params.get("role_id")
}
}
url = 'http://%(servername)s:%(port)d%(uri)s' % parms
hpc = HandlePycurl()
context = hpc.deleteData(hpc.initCurl(), url, head)
return HttpResponse(context or "delete successfully")