How to use list_floating_ips method in tempest

Best Python code snippet using tempest_python

floating_ips.py

Source:floating_ips.py Github

copy

Full Screen

...83 (r'^/(\w+)(?:/|.json|.xml)?$', 'compute_floating_ip_demux'),84)85def demux(request):86 if request.method == 'GET':87 return list_floating_ips(request)88 elif request.method == 'POST':89 return allocate_floating_ip(request)90 else:91 return api.api_method_not_allowed(request,92 allowed_methods=['GET', 'POST'])93def floating_ip_demux(request, floating_ip_id):94 if request.method == 'GET':95 return get_floating_ip(request, floating_ip_id)96 elif request.method == 'DELETE':97 return release_floating_ip(request, floating_ip_id)98 elif request.method == 'PUT':99 return update_floating_ip(request, floating_ip_id)100 else:101 return api.api_method_not_allowed(request,102 allowed_methods=['GET', 'DELETE'])103def compute_demux(request):104 if request.method == 'GET':105 return list_floating_ips(request, _compute_floatingip_list_view)106 elif request.method == 'POST':107 return compute_allocate_floating_ip(request)108 else:109 return api.api_method_not_allowed(request,110 allowed_methods=['GET', 'POST'])111def compute_floating_ip_demux(request, floating_ip_id):112 if request.method == 'GET':113 return get_floating_ip(request, floating_ip_id)114 elif request.method == 'DELETE':115 return release_floating_ip(request, floating_ip_id)116 else:117 return api.api_method_not_allowed(request,118 allowed_methods=['GET', 'DELETE'])119@api.api_method(http_method='POST', user_required=True, logger=log,120 serializations=["json"])121def floating_ip_action_demux(request, floating_ip_id):122 credentials = request.credentials123 req = utils.get_json_body(request)124 log.debug("User %s, Floating IP %s, Request: %s",125 credentials.userid, floating_ip_id, req)126 if len(req) != 1:127 raise faults.BadRequest('Malformed request.')128 action = req.keys()[0]129 try:130 f = FLOATING_IP_ACTIONS[action]131 except KeyError:132 raise faults.BadRequest("Action %s not supported." % action)133 action_args = req[action]134 if not isinstance(action_args, dict):135 raise faults.BadRequest("Invalid argument.")136 return f(request, floating_ip_id, action_args)137@api.api_method(http_method="GET", user_required=True, logger=log,138 serializations=["json"])139def list_floating_ips(request, view=_floatingip_list_view):140 """Return user reserved floating IPs"""141 floating_ips = IPAddressPolicy.filter_list(request.credentials)\142 .filter(floating_ip=True)\143 .order_by("id")\144 .select_related("nic")145 floating_ips = utils.filter_modified_since(request, objects=floating_ips)146 return HttpResponse(view(floating_ips), status=200)147@api.api_method(http_method="GET", user_required=True, logger=log,148 serializations=["json"])149def get_floating_ip(request, floating_ip_id, view=_floatingip_details_view):150 """Return information for a floating IP."""151 floating_ip = util.get_floating_ip_by_id(request.credentials,152 floating_ip_id)153 return HttpResponse(view(floating_ip), status=200)...

Full Screen

Full Screen

layer_three_test.py

Source:layer_three_test.py Github

copy

Full Screen

...4import time5auth = authorization('admin','password')6a = auth.get_auth()7router = layer_three_ops(a)8ip_list = router.list_floating_ips("6492cba476994153800c5220a2f51bc2")9print "fip list"10print ip_list11'''12get_ip = router.get_floating_ip("2476890a-ab03-4c16-b99c-b5fddd92d8e4");13print "get ip"14print get_ip15print16update_dict = {'floating_ip':"192.168.10.162",'instance_id':"aa6a498e-dbd7-44fa-8dd5-b56feefcdaf1",'project_id':"d7b57ec600724d429a3c7916d2243474",'action':"add"}17update_ip = router.update_floating_ip(update_dict)18print "update ip"19print update_ip20print "Adding a new router"21r = {'router_name':'inttestrouter10','project_id':"84d3e074012a42ce919771c503993f4e"}22create = router.add_router(r)23print create24time.sleep(1)25print"-------------------------------------------------"26print "Adding an internal interface."27add_dict = {'router_id':create['router_id'],'subnet_id':"3dfe0e67-61ed-43f6-bad7-db6fa146ac24",'project_id':'84d3e074012a42ce919771c503993f4e'}28int_interface = router.add_router_internal_interface(add_dict)29print int_interface30time.sleep(1)31print "-------------------------------------------------"32print "Add a gateway"33add_dict2 = {'router_id':create['router_id'],'ext_net_id':"bf14df23-065b-4aaf-ab2a-8ca77fca2755","project_id":"84d3e074012a42ce919771c503993f4e"}34ext_int = router.add_router_gateway_interface(add_dict2)35print ext_int36time.sleep(1)37print "-------------------------------------------------"38print "listing the routers"39lister = router.list_routers()40print lister41time.sleep(1)42print "updateing a router"43print create['router_id']44update_dict = {'router_id':create['router_id'],'router_name':"jonarranceYO",'router_admin_state_up':"false"}45update = router.update_router(update_dict)46print update47del_dict = {'router_id':'','subnet_id':"7e45e5b6-f95b-415a-893a-c8e092f0150d",'project_id':"a38c70b7a87c404cab33d0a5959ba57a"}48delete = router.delete_router_internal_interface(del_dict)49print delete50time.sleep(1)51print "-------------------------------------------------"52router_stuff = {'router_id':create['router_id'],'project_id':"a38c70b7a87c404cab33d0a5959ba57a"}53del_ext = router.delete_router_gateway_interface(router_stuff)54print del_ext55time.sleep(1)56print "--------------------------------------------------"57print "deleteing router"58router_dict = {'router_id':'411fb076-5f22-474b-8b8b-d05bb646b197','project_id':"84d3e074012a42ce919771c503993f4e"}59yo = router.delete_router(router_dict)60print yo61print "Allocating a new floating ip"62s = {'ext_net_id':"1d8bb1cd-85b6-45fa-8b43-f51eb302aa25",'project_id':"9a2b2eae323f437eb60183d26fa76a50"}63yo = router.allocate_floating_ip(s)64print yo65print "Listing floating ips"66yo2 = router.list_floating_ips()67print yo268for y in yo2:69 print "Getting floating ip info"70 yo3 = router.get_floating_ip(y['floating_ip_id'])71 print yo372 73print "attaching floating ip to instance"74update_dict = {'floating_ip':'192.168.10.71','instance_id':"ac65509e-da9d-4d2a-b82f-ad269287367d",'project_id':"1c52c0fdf145438d9a8b3b114cbc608a",'action':"add"}75yo4 = router.update_floating_ip(update_dict)76print yo477print "Listing floating ips"78yo5 = router.list_floating_ips()79print yo580for z in yo5:81 print "Getting floating ip info"82 yo6 = router.get_floating_ip(z['floating_ip_id'])83 print yo684print "detaching floating ip from instance"85update_dict = {'floating_ip':'192.168.2.202','instance_id':"aac0f01-bdf6-4368-b59d-4c04ae9697ae",'project_id':"a38c70b7a87c404cab33d0a5959ba57a",'action':"remove"}86yo12 = router.update_floating_ip(update_dict)87print yo1288print "Listing floating ips"89yo10 = router.list_floating_ips()90print yo1091for z2 in yo10:92 print "Getting floating ip info"93 yo11 = router.get_floating_ip(z2['floating_ip_id'])94 print yo1195print "deallocating a new floating ip"96e = {'floating_ip':yo['floating_ip'],'project_id':"a38c70b7a87c404cab33d0a5959ba57a"}97yo7 = router.deallocate_floating_ip(e)98print yo799print "Listing floating ips"100yo13 = router.list_floating_ips()101print yo13102for z3 in yo13:103 print "Getting floating ip info"104 yo14 = router.get_floating_ip(z3['floating_ip_id'])105 print yo14...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful