Updates to fix issues found in testing

This commit is contained in:
Scott Hussey 2017-06-18 20:06:28 -05:00
parent 3c3ecd83f3
commit 3f2f734b1e
3 changed files with 33 additions and 10 deletions

View File

@ -396,7 +396,7 @@ class MaasNodeDriver(NodeDriver):
worked = failed = False worked = failed = False
#TODO Add timeout to config #TODO Add timeout to config
while running_subtasks > 0 and attempts < 30: while running_subtasks > 0 and attempts < 120:
for t in subtasks: for t in subtasks:
subtask = self.state_manager.get_task(t) subtask = self.state_manager.get_task(t)
@ -738,7 +738,7 @@ class MaasTaskRunner(drivers.DriverTaskRunner):
# Poll machine status # Poll machine status
attempts = 0 attempts = 0
while attempts < 20 and machine.status_name != 'Ready': while attempts < 30 and machine.status_name != 'Ready':
attempts = attempts + 1 attempts = attempts + 1
time.sleep(1 * 60) time.sleep(1 * 60)
try: try:
@ -881,13 +881,13 @@ class MaasTaskRunner(drivers.DriverTaskRunner):
found = False found = False
for a in getattr(node, 'addressing', []): for a in getattr(node, 'addressing', []):
if a.network == iface_net: if a.network == iface_net:
link_options['ip_address'] = None if a.address == 'dhcp' else a.address link_options['ip_address'] = 'dhcp' if a.address == 'dhcp' else a.address
found = True found = True
if not found: if not found:
self.logger.error("No addressed assigned to network %s for node %s, cannot link." % self.logger.error("No addressed assigned to network %s for node %s, link is L2 only." %
(iface_net, node.name)) (iface_net, node.name))
continue link_options['ip_address'] = None
self.logger.debug("Linking system %s interface %s to subnet %s" % self.logger.debug("Linking system %s interface %s to subnet %s" %
(node.name, i.device_name, dd_net.cidr)) (node.name, i.device_name, dd_net.cidr))
@ -969,9 +969,28 @@ class MaasTaskRunner(drivers.DriverTaskRunner):
failed = True failed = True
continue continue
self.logger.info("Node %s deployed" % (n)) attempts = 0
while attempts < 120 and not machine.status_name.startswith('Deployed'):
attempts = attempts + 1
time.sleep(1 * 60)
try:
machine.refresh()
self.logger.debug("Polling node %s status attempt %d: %s" % (n, attempts, machine.status_name))
except:
self.logger.warning("Error updating node %s status during commissioning, will re-attempt." %
(n))
if machine.status_name.startswith('Deployed'):
result_detail['detail'].append("Node %s deployed" % (n))
self.logger.info("Node %s deployed" % (n))
worked = True
else:
result_detail['detail'].append("Node %s deployment timed out" % (n))
self.logger.warning("Node %s deployment timed out." % (n))
failed = True
if failed: if worked and failed:
final_result = hd_fields.ActionResult.PartialSuccess
elif failed:
final_result = hd_fields.ActionResult.Failure final_result = hd_fields.ActionResult.Failure
else: else:
final_result = hd_fields.ActionResult.Success final_result = hd_fields.ActionResult.Success

View File

@ -120,12 +120,16 @@ class Interface(model_base.ResourceBase):
# TODO Probably need to enumerate link mode # TODO Probably need to enumerate link mode
options = { 'subnet': subnet.resource_id, options = { 'subnet': subnet.resource_id,
'mode': 'dhcp' if ip_address is None else 'static',
'default_gateway': primary, 'default_gateway': primary,
} }
if ip_address is not None: if ip_address == 'dhcp':
options['mode'] = 'dhcp'
elif ip_address is not None:
options['ip_address'] = ip_address options['ip_address'] = ip_address
options['mode'] = 'static'
else:
options['mode'] = 'link_up'
self.logger.debug("Linking interface %s to subnet: subnet=%s, mode=%s, address=%s, primary=%s" % self.logger.debug("Linking interface %s to subnet: subnet=%s, mode=%s, address=%s, primary=%s" %
(self.resource_id, subnet.resource_id, options['mode'], ip_address, primary)) (self.resource_id, subnet.resource_id, options['mode'], ip_address, primary))

View File

@ -47,7 +47,7 @@ class Subnet(model_base.ResourceBase):
# Static ranges are what is left after reserved (not assigned by MaaS) # Static ranges are what is left after reserved (not assigned by MaaS)
# and DHCP ranges are removed from a subnet # and DHCP ranges are removed from a subnet
if addr_range.get('type', None) in ['reserved','dhcp']: if addr_range.get('type', None) in ['reserved','dhcp']:
range_type = addr_range('type', None) range_type = addr_range.get('type', None)
if range_type == 'dhcp': if range_type == 'dhcp':
range_type = 'dynamic' range_type = 'dynamic'