• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python MyRequestsClass.MyRequests类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: create_machine

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,代码行数:26,代码来源:machines.py


示例2: create_machine

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,代码行数:26,代码来源:machines.py


示例3: stop_machine

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,代码行数:8,代码来源:machines.py


示例4: edit_key

def edit_key(uri, key_id, new_name, cookie=None):
    payload = {
        'key':key_id,
        'newName': new_name
    }
    req = MyRequests(uri=uri+"/keys/" + key_id,  data=json.dumps(payload), cookie=cookie)
    response = req.put()
    assert response.ok, u'\nGot %d Response Status: %s \n%s' % (response.status_code, response.reason, response.text)
开发者ID:a42,项目名称:mist.io,代码行数:8,代码来源:keypairs.py


示例5: start_machine

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,代码行数:8,代码来源:machines.py


示例6: list_machines

def list_machines(uri, cloud_id, cookie=None, csrf=None):
    req = MyRequests(uri=uri + "/clouds/" + cloud_id + "/machines", cookie=cookie, csrf=csrf)
    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:mario-olivarez,项目名称:mist.io,代码行数:9,代码来源:machines.py


示例7: list_machines

def list_machines(uri, backend_id, cookie=None):
    req = MyRequests(uri=uri+'/backends/'+backend_id+"/machines", 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,代码行数:9,代码来源:machines.py


示例8: reboot_machine

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,代码行数:9,代码来源:machines.py


示例9: rename_cloud

def rename_cloud(uri, cloud_id, new_name, cookie=None, csrf=None):
    payload = {
        'new_name': new_name
    }

    req = MyRequests(uri=uri+"/clouds/"+cloud_id, data=json.dumps(payload),
                     cookie=cookie, csrf=csrf)
    response = req.put()
    assert response.ok, u'\nGot %d Response Status: %s \n%s' % (response.status_code, response.reason, response.text)
开发者ID:mario-olivarez,项目名称:mist.io,代码行数:9,代码来源:clouds.py


示例10: list_clouds

def list_clouds(uri, cookie=None, csrf=None):
    req = MyRequests(uri=uri + '/clouds', cookie=cookie, csrf=csrf)
    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:mario-olivarez,项目名称:mist.io,代码行数:10,代码来源:clouds.py


示例11: get_public_key

def get_public_key(uri, key_id, cookie=None):
    req = MyRequests(uri=uri+"/keys/"+key_id+"?action=public", 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:
        print response.text
        assert False, u'Exception: %s' %e
开发者ID:a42,项目名称:mist.io,代码行数:11,代码来源:keypairs.py


示例12: delete_key

def delete_key(uri, key_id, cookie=None):
    req = MyRequests(uri=uri+"/keys/"+key_id, cookie=cookie)
    response = req.delete()
    assert response.ok, u'\nGot %d Response Status: %s \n%s' % (response.status_code, response.reason, response.text)

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


示例13: generate_keypair

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,代码行数:11,代码来源:keypairs.py


示例14: start_machine

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,代码行数:12,代码来源:machines.py


示例15: start_machine

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,代码行数:12,代码来源:machines.py


示例16: supported_providers

def supported_providers(uri, cookie=None, csrf=None):
    req = MyRequests(uri=uri+'/providers', cookie=cookie, csrf=csrf)
    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()
    except Exception as e:
        assert False, u'Exception: %s' %e

    SUPPORTED_PROVIDERS = params['supported_providers']
    print '\nSupported providers:'
    return SUPPORTED_PROVIDERS
开发者ID:mario-olivarez,项目名称:mist.io,代码行数:13,代码来源:clouds.py


示例17: add_key

def add_key(uri, name, private, cookie=None):
    payload = {
        'name': name,
        'priv': private
    }
    req = MyRequests(uri=uri+"/keys", cookie=cookie, data=json.dumps(payload))
    response = req.put()
    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,代码行数:14,代码来源:keypairs.py


示例18: list_images

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,代码行数:17,代码来源:backends.py


示例19: add_backend

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,代码行数:19,代码来源:backends.py


示例20: delete_cloud

def delete_cloud(uri, cloud_id, cookie=None, csrf=None):
    req = MyRequests(uri=uri+'/clouds/'+cloud_id, cookie=cookie, csrf=csrf)
    response = req.delete()
    assert response.ok, u'\nGot %d Response Status: %s \n%s' % (response.status_code, response.reason, response.text)

    print "Deleted Cloud with id: %s" % cloud_id
开发者ID:mario-olivarez,项目名称:mist.io,代码行数:6,代码来源:clouds.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python MySQL.MySQL类代码示例发布时间:2022-05-24
下一篇:
Python SinglyLinkedList.SinglyLinkedList类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap