当前位置: 首页>>代码示例>>Python>>正文


Python MyRequests.post方法代码示例

本文整理汇总了Python中MyRequestsClass.MyRequests.post方法的典型用法代码示例。如果您正苦于以下问题:Python MyRequests.post方法的具体用法?Python MyRequests.post怎么用?Python MyRequests.post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MyRequestsClass.MyRequests的用法示例。


在下文中一共展示了MyRequests.post方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_machine

# 需要导入模块: from MyRequestsClass import MyRequests [as 别名]
# 或者: from MyRequestsClass.MyRequests import post [as 别名]
def create_machine(
    uri, cloud_id, key_id, name, location, image, size, script=None, disk=None, image_extra=None, cookie=None, csrf=None
):
    payload = {
        #'cloud': cloud_id,
        "key": key_id,
        "name": name,
        "location": location,
        "image": image,
        "size": size,
        "script": script,
        "disk": disk,
        "image_extra": image_extra,
    }
    req = MyRequests(
        uri=uri + "/clouds/" + cloud_id + "/machines", cookie=cookie, data=json.dumps(payload), timeout=600, csrf=csrf
    )
    response = req.post()
    assert response.ok, u"\nGot %d Response Status: %s \n%s" % (response.status_code, response.reason, response.text)

    try:
        params = response.json()
        print "Created machine with Name: %s and id %s a" % (params["name"], params["id"])
        return params
    except Exception as e:
        assert False, u"Exception: %s" % e
开发者ID:mario-olivarez,项目名称:mist.io,代码行数:28,代码来源:machines.py

示例2: create_machine

# 需要导入模块: from MyRequestsClass import MyRequests [as 别名]
# 或者: from MyRequestsClass.MyRequests import post [as 别名]
def create_machine(uri, backend_id, key_id, name, location, image, size,
                   script=None, disk=None, image_extra=None, cookie=None,
                   csrf=None):
    payload = {
        #'backend': backend_id,
        'key': key_id,
        'name': name,
        'location': location,
        'image': image,
        'size': size,
        'script': script,
        'disk': disk,
        'image_extra': image_extra
    }
    req = MyRequests(uri=uri+"/backends/"+backend_id+"/machines",
                     cookie=cookie, data=json.dumps(payload), timeout=600,
                     csrf=csrf)
    response = req.post()
    assert response.ok, u'\nGot %d Response Status: %s \n%s' % (response.status_code, response.reason, response.text)

    try:
        params = response.json()
        print "Created machine with Name: %s and id %s a" % (params['name'], params['id'])
        return params
    except Exception as e:
        assert False, u'Exception: %s' % e
开发者ID:AVD087,项目名称:mist.io,代码行数:28,代码来源:machines.py

示例3: stop_machine

# 需要导入模块: from MyRequestsClass import MyRequests [as 别名]
# 或者: from MyRequestsClass.MyRequests import post [as 别名]
def stop_machine(uri, cloud_id, machine_id, cookie=None, csrf=None):
    payload = {"action": "stop"}
    req = MyRequests(
        uri=uri + "/clouds/" + cloud_id + "/machines/" + machine_id, data=json.dumps(payload), cookie=cookie, csrf=csrf
    )
    response = req.post()
    assert response.ok, u"\nGot %d Response Status: %s \n%s" % (response.status_code, response.reason, response.text)
    print "Stopped machine with id: %s" % machine_id
开发者ID:mario-olivarez,项目名称:mist.io,代码行数:10,代码来源:machines.py

示例4: start_machine

# 需要导入模块: from MyRequestsClass import MyRequests [as 别名]
# 或者: from MyRequestsClass.MyRequests import post [as 别名]
def start_machine(uri, backend_id, machine_id, cookie=None):
    payload = {
        'action':'start'
    }
    req = MyRequests(uri=uri+"/backends/"+backend_id+"/machines/"+machine_id, data=payload, cookie=cookie)
    response = req.post()
    assert response.ok, u'\nGot %d Response Status: %s \n%s' % (response.status_code, response.reason, response.text)
    print "Started machine with id: %s" % machine_id
开发者ID:a42,项目名称:mist.io,代码行数:10,代码来源:machines.py

示例5: reboot_machine

# 需要导入模块: from MyRequestsClass import MyRequests [as 别名]
# 或者: from MyRequestsClass.MyRequests import post [as 别名]
def reboot_machine(uri, backend_id, machine_id, cookie=None, csrf=None):
    payload = {
        'action': 'reboot'
    }
    req = MyRequests(uri=uri+"/backends/"+backend_id+"/machines/"+machine_id,
                     cookie=cookie, data=json.dumps(payload), csrf=csrf)
    response = req.post()
    assert response.ok, u'\nGot %d Response Status: %s \n%s' % (response.status_code, response.reason, response.text)
    print "Rebooted machine with id: %s" % machine_id
开发者ID:AVD087,项目名称:mist.io,代码行数:11,代码来源:machines.py

示例6: generate_keypair

# 需要导入模块: from MyRequestsClass import MyRequests [as 别名]
# 或者: from MyRequestsClass.MyRequests import post [as 别名]
def generate_keypair(uri, cookie=None):
    req = MyRequests(uri=uri+"/keys", cookie=cookie)
    response = req.post()
    assert response.ok, u'\nGot %d Response Status: %s \n%s' % (response.status_code, response.reason, response.text)

    try:
        params = response.json()
        print params
        return params
    except Exception as e:
        assert False, u'Exception: %s' %e
开发者ID:a42,项目名称:mist.io,代码行数:13,代码来源:keypairs.py

示例7: start_machine

# 需要导入模块: from MyRequestsClass import MyRequests [as 别名]
# 或者: from MyRequestsClass.MyRequests import post [as 别名]
def start_machine(uri, cloud_id, machine_id, cookie=None, csrf=None):
    sleep(30)
    payload = {"action": "start"}
    req = MyRequests(
        uri=uri + "/clouds/" + cloud_id + "/machines/" + machine_id, data=json.dumps(payload), cookie=cookie, csrf=csrf
    )
    response = req.post()
    if response.status_code == 503:
        print "Machine state is not yet ready to be started"
        return
    assert response.ok, u"\nGot %d Response Status: %s \n%s" % (response.status_code, response.reason, response.text)
    print "Started machine with id: %s" % machine_id
开发者ID:mario-olivarez,项目名称:mist.io,代码行数:14,代码来源:machines.py

示例8: start_machine

# 需要导入模块: from MyRequestsClass import MyRequests [as 别名]
# 或者: from MyRequestsClass.MyRequests import post [as 别名]
def start_machine(uri, backend_id, machine_id, cookie=None):
    sleep(30)
    payload = {
        'action': 'start'
    }
    req = MyRequests(uri=uri+"/backends/"+backend_id+"/machines/"+machine_id, data=payload, cookie=cookie)
    response = req.post()
    if response.status_code == 503:
        print "Machine state is not yet ready to be started"
        return
    assert response.ok, u'\nGot %d Response Status: %s \n%s' % (response.status_code, response.reason, response.text)
    print "Started machine with id: %s" % machine_id
开发者ID:smeverts,项目名称:mist.io,代码行数:14,代码来源:machines.py

示例9: list_images

# 需要导入模块: from MyRequestsClass import MyRequests [as 别名]
# 或者: from MyRequestsClass.MyRequests import post [as 别名]
def list_images(uri, backend_id, search_term=None, cookie=None):
    payload = {
        'search_term': search_term
    }
    if not search_term:
        req = MyRequests(uri=uri+"/backends/"+backend_id+"/images", cookie=cookie)
        response = req.post()
    else:
        req = MyRequests(uri=uri+"/backends/"+backend_id+"/images", data=json.dumps(payload), cookie=cookie)
        response = req.get()
    assert response.ok, u'\nGot %d Response Status: %s \n%s' % (response.status_code, response.reason, response.text)

    try:
        params = response.json()
        return params
    except Exception as e:
        assert False, u'Exception: %s' % e
开发者ID:a42,项目名称:mist.io,代码行数:19,代码来源:backends.py

示例10: add_backend

# 需要导入模块: from MyRequestsClass import MyRequests [as 别名]
# 或者: from MyRequestsClass.MyRequests import post [as 别名]
def add_backend(uri, title, provider, apikey, apisecret, apiurl=None, tenant_name=None, cookie=None):
    payload = {
        'title': title,
        'provider': provider,
        'apikey': apikey,
        'apisecret': apisecret,
        'apiurl': apiurl,
        'tenant_name': tenant_name
    }

    req = MyRequests(uri=uri+'/backends', data=json.dumps(payload), cookie=cookie)
    response = req.post()
    assert response.ok, u'\nGot %d Response Status: %s \n%s' % (response.status_code, response.reason, response.text)

    try:
        params = response.json()
        return params
    except Exception as e:
        assert False, u'Exception: %s' % e
开发者ID:a42,项目名称:mist.io,代码行数:21,代码来源:backends.py


注:本文中的MyRequestsClass.MyRequests.post方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。