Skip to content
Permalink
Browse files

Fix for M&R async workflow.

Removed create_tasks in lieue of the loop executing those tasks
straight away.

Change-Id: Ibcf2654a94181d03e248128ddbbabf2314601383
  • Loading branch information...
grafuls committed Sep 2, 2019
1 parent 98af2c3 commit 9f8f5b72d2e0742a2abea6d1656d2f9e895f1563
Showing with 19 additions and 22 deletions.
  1. +4 −1 bin/quads-cli
  2. +1 −1 quads/tools/badfish.py
  3. +13 −19 quads/tools/move_and_rebuild_hosts.py
  4. +1 −1 quads/tools/validate_env.py
@@ -394,12 +394,15 @@ def main(_args):
except asyncio.CancelledError:
logger.exception('Move command failed')
provisioned = False
except SystemExit:
logger.exception('Move command failed')
provisioned = False
except Exception:
logger.exception('Move command failed')
provisioned = False
for task in switch_tasks:
try:
logger.info("Running switch config.")
logger.info(f"Running switch config for {task.args[0]}")
task()
except Exception:
logger.exception("There was something wrong configuring the switch.")
@@ -263,7 +263,7 @@ def progress_bar(value, end_value, state, bar_length=20):
response = await self.get_request(self.root_uri)

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

if response:
@@ -75,7 +75,7 @@ def switch_config(host, old_cloud, new_cloud):
str(new_vlan)
)
if success:
logger.info("Successfully update switch settings.")
logger.info("Successfully updated switch settings.")
else:
logger.error("There was something wrong updating switch for %s:%s" % (host, interface.name))
return False
@@ -108,7 +108,7 @@ def switch_config(host, old_cloud, new_cloud):
ipmi_on = [
"chassis", "power", "on",
]
asyncio.create_task(execute_ipmi(host, ipmi_on))
await execute_ipmi(host, ipmi_on)


async def move_and_rebuild(host, old_cloud, new_cloud, rebuild=False, loop=None):
@@ -144,12 +144,12 @@ def switch_config(host, old_cloud, new_cloud):
str(conf["ipmi_cloud_username_id"]), ipmi_new_pass
]

await asyncio.create_task(execute_ipmi(host, arguments=ipmi_set_pass))
await execute_ipmi(host, arguments=ipmi_set_pass)

ipmi_set_operator = [
"user", "priv", str(conf["ipmi_cloud_username_id"]), "0x4"
]
await asyncio.create_task(execute_ipmi(host, arguments=ipmi_set_operator))
await execute_ipmi(host, arguments=ipmi_set_operator)

if rebuild and _new_cloud_obj.name != _host_obj.default_cloud.name:
if "pdu_management" in conf and conf["pdu_management"]:
@@ -161,7 +161,7 @@ def switch_config(host, old_cloud, new_cloud):
"chassis", "bootdev", "pxe",
"options", "=", "persistent"
]
await asyncio.create_task(execute_ipmi(host, arguments=ipmi_pxe_persistent))
await execute_ipmi(host, arguments=ipmi_pxe_persistent)

if is_supported(host):
try:
@@ -170,20 +170,16 @@ def switch_config(host, old_cloud, new_cloud):
logger.exception("Could not initialize Badfish. Verify ipmi credentials.")
return False
try:
await asyncio.create_task(
badfish.change_boot(
"director",
os.path.join(
os.path.dirname(__file__),
"../../conf/idrac_interfaces.yml"
)
await badfish.change_boot(
"director",
os.path.join(
os.path.dirname(__file__),
"../../conf/idrac_interfaces.yml"
)
)
except asyncio.CancelledError:
raise
except Exception:
logger.exception("Could not set boot order via Badfish.")
await asyncio.create_task(badfish.reboot_server())
await badfish.reboot_server()
return False

params = [
@@ -214,15 +210,13 @@ def switch_config(host, old_cloud, new_cloud):
"../../conf/idrac_interfaces.yml"
)
)
await asyncio.create_task(badfish.reboot_server(graceful=False))
except asyncio.CancelledError:
raise
await badfish.reboot_server(graceful=False)
except Exception:
logger.exception("Error setting PXE boot via Badfish on: %s." % host)
return False
else:
if is_supermicro(host):
await asyncio.create_task(ipmi_reset(host))
await ipmi_reset(host)

logger.debug("Updating host: %s")
_host_obj.update(cloud=_new_cloud_obj, build=False, last_build=datetime.now())
@@ -81,7 +81,7 @@ def post_system_test(self):
self.report = self.report + "Verify Foreman password is correct: %s\n" % self.cloud.ticket
return False

build_hosts = asyncio.run(foreman.get_build_hosts())
build_hosts = loop.run_until_complete(foreman.get_build_hosts())

pending = []
schedules = Schedule.current_schedule(cloud=self.cloud)

0 comments on commit 9f8f5b7

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