How to use _get_server_key method in tempest

Best Python code snippet using tempest_python

pool.py

Source:pool.py Github

copy

Full Screen

...6from django.utils import timezone7from common_env.models import ServerCreatePool, WaitingCreatePool8from common_env.setting import api_settings9logger = logging.getLogger(__name__)10def _get_server_key(server):11 return '%s:%s' % (server._meta.db_table, server.pk)12def add_server(server=None, key=None, estimate_consume_time=0):13 if server and key is None:14 key = _get_server_key(server)15 if key is not None:16 ServerCreatePool.objects.create(unique_id=key, estimate_consume_time=estimate_consume_time)17def remove_server(server=None, key=None):18 if server and key is None:19 key = _get_server_key(server)20 if key is not None:21 ServerCreatePool.objects.filter(unique_id=key).delete()22def is_full(need_count=1):23 creating_count = ServerCreatePool.objects.count()24 if creating_count + need_count > api_settings.SERVER_CREATE_POOL_LIMIT:25 return True26 else:27 return False28def get_executing_min_remain_time():29 now_time = timezone.now()30 min_remain_time = 031 for create_instance in ServerCreatePool.objects.all():32 pass_seconds = (now_time - create_instance.create_time).total_seconds()33 remain_time = create_instance.estimate_consume_time - pass_seconds...

Full Screen

Full Screen

cloudservers.py

Source:cloudservers.py Github

copy

Full Screen

...33 media_type = 'text/plain'34 format = 'txt'35 def render(self, data, media_type=None, renderer_context=None):36 return data.encode(self.charset)37def _get_server_key(instance_id=None):38 key = ''39 server = server_model.collection.find_one({'instance_id': instance_id})40 if server:41 key = server.get('key')42 return key43class CloudServersGetServerKeyView(APIView):44 permission_classes = (ApiKeyPermission,)45 renderer_classes = (PlainTextRenderer,)46 47 def get(self, request, provider_id):48 key = ""49 params = request.query_params50 instance_id = params.get('instance_id')51 if provider_id in ['amazon', 'google', 'digitalocean']:52 key = _get_server_key(instance_id=instance_id)53 else:54 status = settings.API_RESULTS['not-found']...

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