Skip to content
Permalink
Browse files

feat: added ipmi credentials validation

Added validate_credentials method to badfish library and calling
this as an additional step on validate_env

fixes:
#145
#280

Change-Id: I098256a0b5a8bb2cb2e12ebcdb0db5fdd62b0e11
  • Loading branch information...
grafuls committed Oct 9, 2019
1 parent ece5fef commit f2d731e4f1ccb25652e006f2d578900b116b9b2f
Showing with 19 additions and 6 deletions.
  1. +5 −1 quads/tools/badfish.py
  2. +14 −5 quads/tools/validate_env.py
@@ -50,6 +50,7 @@ def __init__(self, _host, _username, _password, loop=None, _retries=RETRIES):
self.bios_uri = None

async def init(self):
await self.validate_credentials()
self.system_resource = await self.find_systems_resource()
self.manager_resource = await self.find_managers_resource()
self.bios_uri = "%s/Bios/Settings" % self.system_resource[len(self.redfish_uri):]
@@ -265,13 +266,16 @@ def progress_bar(value, end_value, state, bar_length=20):

return None

async def find_systems_resource(self):
async def validate_credentials(self):
response = await self.get_request(self.root_uri)

if response.status == 401:
logger.error(f"Failed to authenticate. Verify your credentials for {self.host}")
raise BadfishException

async def find_systems_resource(self):
response = await self.get_request(self.root_uri)

if response:
data = await response.json(content_type="application/json")
if 'Systems' not in data:
@@ -10,6 +10,7 @@

from quads.config import conf, TEMPLATES_PATH, INTERFACES
from quads.model import Cloud, Schedule, Host, Notification
from quads.tools.badfish import Badfish, BadfishException
from quads.tools.foreman import Foreman
from quads.tools.postman import Postman
from quads.tools.ssh_helper import SSHHelper
@@ -22,6 +23,7 @@ class Validator(object):
def __init__(self, cloud):
self.cloud = cloud
self.report = ""
self.hosts = Host.objects(cloud=self.cloud)

def notify_failure(self):
template_file = "validation_failed"
@@ -98,19 +100,26 @@ def post_system_test(self):
self.report = self.report + "%s\n" % host
return False

return True
failed = False
for host in self.hosts:
try:
badfish = Badfish(host.name, self.cloud.name, self.cloud.ticket, loop)
loop.run_until_complete(badfish.validate_credentials())
except BadfishException:
logger.info(f"Could not verify badfish credentials for: {host.name}")
failed = True

def post_network_test(self):
_cloud_hosts = Host.objects(cloud=self.cloud)
return not failed

test_host = _cloud_hosts[0]
def post_network_test(self):
test_host = self.hosts[0]
try:
ssh_helper = SSHHelper(test_host.name)
except SSHException:
logger.exception("Could not establish connection with host: %s." % test_host.name)
self.report = self.report + "Could not establish connection with host: %s.\n" % test_host.name
return False
host_list = " ".join([host.name for host in _cloud_hosts])
host_list = " ".join([host.name for host in self.hosts])

if type(ssh_helper.run_cmd("fping -u %s" % host_list)) != list:

0 comments on commit f2d731e

Please sign in to comment.
You can’t perform that action at this time.