How to use reboot_server method in tempest

Best Python code snippet using tempest_python

utility_restart_circuits.py

Source: utility_restart_circuits.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2# pragma pylint: disable=unused-argument, no-self-use3# This function will restart Resilient Circuits.4# File: utility_restart_circuits.py5# Date: 04/​26/​2019 - Modified: 04/​11/​20206# Author: Jared F7"""Function implementation"""8# @function -> utility_restart_resilient_circuits9# @params -> boolean: reboot_server10# @return -> boolean: results['was_successful']11import os12import time13import shutil14import logging15import datetime16from resilient_circuits import ResilientComponent, function, handler, StatusMessage, FunctionResult, FunctionError17import utilities.util.selftest as selftest18class FunctionComponent(ResilientComponent):19 """Component that implements Resilient function 'utility_restart_resilient_circuits"""20 def __init__(self, opts):21 """constructor provides access to the configuration options"""22 super(FunctionComponent, self).__init__(opts)23 self.options = opts.get("utilities", {})24 @handler("reload")25 def _reload(self, event, opts):26 """Configuration options have changed, save new values"""27 self.options = opts.get("utilities", {})28 @function("utility_restart_resilient_circuits")29 def _utility_restart_resilient_circuits_function(self, event, *args, **kwargs):30 results = {}31 results["was_successful"] = False32 try:33 # Get the function parameters:34 reboot_server = kwargs.get("reboot_server") # boolean35 if os.path.exists('/​home/​integrations/​.resilient/​rc_restarted.lock') is False:36 open('/​home/​integrations/​.resilient/​rc_restarted.lock', 'w+').close()37 if os.path.exists('/​home/​integrations/​.resilient/​rc_restarted.lock') is False: raise IOError38 if reboot_server is True:39 yield StatusMessage('[INFO] Rebooting the Resilient integrations server...')40 os.system('reboot')41 else:42 yield StatusMessage('[INFO] Restarting the Resilient Circuits service...')43 os.system("sudo systemctl restart resilient_circuits.service") # Modify as needed44 else:45 os.remove('/​home/​integrations/​.resilient/​rc_restarted.lock')46 if reboot_server is True: yield StatusMessage('[SUCCESS] Reboot completed!')47 else: yield StatusMessage('[SUCCESS] Restart completed!')48 except Exception as err: # Catch all exceptions and abort49 try: os.remove('/​home/​integrations/​.resilient/​rc_restarted.lock')50 except: pass51 yield StatusMessage('[FATAL ERROR] Encountered: ' + str(err))52 yield StatusMessage('[FAILURE] Fatal error caused exit!')53 # Produce a FunctionResult with the results54 yield FunctionResult(results)55 except Exception:...

Full Screen

Full Screen

monitor.py

Source: monitor.py Github

copy

Full Screen

...19 body = 'Make sure the server restarted and it is back up'20 msg = f'Subject: {subject}\n\n{body}'21 # logging.info('Sending Email...')22 smtp.sendmail(EMAIL_ADDRESS, 'INSERT_RECEIVER_ADDRESS', msg)23def reboot_server():24 client = LinodeClient(LINODE_TOKEN)25 my_server = client.load(Instance, 376715)26 my_server.reboot()27 # logging.info('Attempting to reboot server...')28try:29 r = requests.get('https:/​/​example.com', timeout=5)30 if r.status_code != 200:31 # logging.info('Website is DOWN!')32 notify_user()33 reboot_server()34 else:35 # logging.info('Website is UP')36except Exception as e:37 # logging.info('Website is DOWN!')38 notify_user()...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Using ChatGPT for Test Automation

ChatGPT broke all Internet records by going viral in the first week of its launch. A million users in 5 days are unprecedented. A conversational AI that can answer natural language-based questions and create poems, write movie scripts, write social media posts, write descriptive essays, and do tons of amazing things. Our first thought when we got access to the platform was how to use this amazing platform to make the lives of web and mobile app testers easier. And most importantly, how we can use ChatGPT for automated testing.

LIVE With Automation Testing For OTT Streaming Devices ????

People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.

Feeding your QA Career – Developing Instinctive & Practical Skills

The QA testing profession requires both educational and long-term or experience-based learning. One can learn the basics from certification courses and exams, boot camp courses, and college-level courses where available. However, developing instinctive and practical skills works best when built with work experience.

How To Handle Dynamic Dropdowns In Selenium WebDriver With Java

Joseph, who has been working as a Quality Engineer, was assigned to perform web automation for the company’s website.

How to Recognize and Hire Top QA / DevOps Engineers

With the rising demand for new services and technologies in the IT, manufacturing, healthcare, and financial sector, QA/ DevOps engineering has become the most important part of software companies. Below is a list of some characteristics to look for when interviewing a potential candidate.

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