def handle(self, request, data): try: assign = neutron.networktemplateassignment_get( request, request.user.tenant_id) # we only want the one that matches the network template stack = heat.stack_get(request, assign.stack_id) if not stack: msg = _('Stack instance %(stack_id)s could not be found. ' 'Deleting the network template association ' '%(assign_id)s.') % {'stack_id': assign.stack_id, 'assign_id': assign.id} LOG.error(msg) messages.error(request, msg) else: # stack found, delete it heat.stack_delete(request, assign.stack_id) stack = heat.stack_get(request, assign.stack_id) if stack.stack_status not in \ ['DELETE_IN_PROGRESS', 'DELETE_COMPLETED']: msg = _('Stack instance %(stack_name)s could not be ' 'deleted. Reason: %(status_reason)s. Skipping ' 'network template removal.') % \ {'stack_name': stack.stack_name, 'status_reason': stack.stack_status_reason} LOG.error(msg) messages.error(request, msg) return False msg = _('Stack %s delete in progress..') % assign.stack_id LOG.info(msg) messages.warning(request, msg) return True except Exception as e: messages.error(request, e) return False
def get_data(self, request, stack_id): assignment = None try: assignments = neutron.networktemplateassignment_list( request, **{'stack_id': stack_id}) if not assignments: raise Exception('Network template associationg not found.') assignment = assignments[0] template = neutron.networktemplate_get(request, assignment.template_id) stack = heat.stack_get(request, stack_id) resources = heat.resources_list(request, stack.stack_name) if stack.stack_status == 'DELETE_COMPLETE': # returning 404 to the ajax call removes the # row from the table on the ui raise Http404 rowdata = { 'template_id': assignment.template_id, 'template_name': template.name, 'stack_id': stack_id, 'heat_stack_name': stack.stack_name, 'description': stack.description, 'status': stack.status, 'stack_status': stack.stack_status, 'stack_status_reason': stack.stack_status_reason, 'resources': mark_safe('<br>'.join([ ('%s (%s)' % (r.resource_name, r.resource_type)).replace( ' ', ' ') for r in resources ])) } return rowdata except Http404: try: # remove corresponding network template if assignment: neutron.networktemplateassignment_delete( request, assignment.id) msg = _('Removed template association for stack_id %s') % \ stack_id LOG.debug(msg) messages.success(request, msg) except Exception as e: msg = _('Network template association removal failed ' 'due to %s') % e LOG.error(msg) messages.error(request, msg) raise except Exception as e: raise
def d3_data(request, stack_id=''): try: stack = heat.stack_get(request, stack_id) except Exception: stack = Stack() stack.id = stack_id stack.stack_name = request.session.get('stack_name', '') stack.stack_status = 'DELETE_COMPLETE' stack.stack_status_reason = 'DELETE_COMPLETE' try: resources = heat.resources_list(request, stack.stack_name) except Exception: resources = [] d3_data = {"nodes": [], "stack": {}} if stack: stack_image = mappings.get_resource_image(stack.stack_status, 'stack') stack_node = { 'stack_id': stack.id, 'name': stack.stack_name, 'status': stack.stack_status, 'image': stack_image, 'image_size': 60, 'image_x': -30, 'image_y': -30, 'text_x': 40, 'text_y': ".35em", 'in_progress': (stack.status == 'IN_PROGRESS'), 'info_box': sro.stack_info(stack, stack_image) } d3_data['stack'] = stack_node if resources: for resource in resources: resource_image = mappings.get_resource_image( resource.resource_status, resource.resource_type) resource_status = mappings.get_resource_status( resource.resource_status) if resource_status in ('IN_PROGRESS', 'INIT'): in_progress = True else: in_progress = False resource_node = { 'name': resource.resource_name, 'status': resource.resource_status, 'image': resource_image, 'required_by': resource.required_by, 'image_size': 50, 'image_x': -25, 'image_y': -25, 'text_x': 35, 'text_y': ".35em", 'in_progress': in_progress, 'info_box': sro.resource_info(resource) } d3_data['nodes'].append(resource_node) return json.dumps(d3_data)
def get(cls, request, stack_id): """Return the Heat Stack associated with this Overcloud :return: Heat Stack associated with the stack_id; or None if no Stack is associated, or no Stack can be found :rtype: tuskar_ui.api.heat.Stack or None """ return cls(heat.stack_get(request, stack_id), request=request)
def stack(self): """Return the Heat Stack associated with this Overcloud :return: Heat Stack associated with this Overcloud; or None if no Stack is associated, or no Stack can be found :rtype: heatclient.v1.stacks.Stack or None """ return heat.stack_get(self._request, 'overcloud')
def get(cls, request, stack_id, plan=None): """Return the Heat Stack associated with this Overcloud :return: Heat Stack associated with this Overcloud; or None if no Stack is associated, or no Stack can be found :rtype: heatclient.v1.stacks.Stack or None """ stack = heat.stack_get(request, stack_id) return cls(stack, request=request, plan=plan)
def get(self, request, stack_id): result = heat.stack_get(request, stack_id) return result.stack_status