1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
import datetime
from ..models import Cluster, WrInstallSchedule, WrBatch
from django.conf import settings
from .helpers import Address, Jinja
from .ansibleservice import AnsibleService
from .icingapollservice import IcingaPollService
import logging
logger = logging.getLogger("caas")
class WrService(AnsibleService):
"""
target == ilo_host_address, later becomes cluster_name
"""
def __init__(self, target, git, branch, playbook, zmq):
super().__init__("wr", target, git, branch, playbook, zmq)
def schedule_install(self):
logger.debug("%s Enter schedule_install" % self.target)
try:
wrbatch_kwargs = {"ilo_host_address": self.target}
wrbatch = WrBatch.objects.get(**wrbatch_kwargs)
except WrBatch.DoesNotExist:
logger.error("FAILED: while scheduling Wind River installation: cannot find wrbatch with ilo_host_address: %s" % self.target)
raise
try:
cluster_kwargs = {"pk": wrbatch.cluster_id}
cluster = Cluster.objects.get(**cluster_kwargs)
except Cluster.DoesNotExist:
logger.error("FAILED: while scheduling Wind River installation: cannot find cluster associated with wrbatch with ilo_host_address: %s" % wrbatch.ilo_host_address)
raise
wr_kwargs = {"cluster_id": cluster.pk}
wr, wr_created = WrInstallSchedule.objects.get_or_create(**wr_kwargs)
if wr.date_scheduled is None:
wr.date_scheduled = datetime.datetime.now()
if wr.kirke_ticket_number is None:
# TODO bealer: create KIRKE ticket
pass
wr.save()
def deploy(self):
kirke_inprocess_kwargs = {"kirke_ticket_number__isnull": False,
"kirke_ticket_completed__isnull": True}
kirke_inprocess = WrInstallSchedule.objects.filter(**kirke_inprocess_kwargs)
for rec in kirke_inprocess:
# TODO bealer: query KIRKE and update status
rec.save()
wr_schedule_kwargs = {"kirke_ticket_completed__isnull": False,
"date_completed__isnull": True}
wr_schedule_ready = WrInstallSchedule.objects.filter(**wr_schedule_kwargs)
for sched in wr_schedule_ready:
try:
wrbatch_kwargs = {"cluster_id": sched.cluster.pk,
"intel_nic_firmware_version": settings.INTEL_NIC_FIRMWARE_VERSION}
wrbatch_results = WrBatch.objects.filter(**wrbatch_kwargs)
except WrBatch.DoesNotExist:
logger.error("FAILED: while running WR batch playbook: failed to look up wrbatch")
raise
# check hardware before wr isntall
wrbatch = wrbatch_results[0]
icingapoll = IcingaPollService(wrbatch.ilo_host_address,
settings.ANSIBLE["icinga_poll"]["git"],
settings.ANSIBLE["icinga_poll"]["branch"],
settings.ANSIBLE["icinga_poll"]["playbook"],
settings.ANSIBLE["icinga_poll"]["zmq"],
"wrinstallnow")
icingapoll.deploy()
|