import ip_handler as IP
+LOG = logging.getLogger("api.openstack.heat.parser")
+
+
class HeatParser:
"""
The HeatParser will parse a heat dictionary and create a stack and its components, to instantiate it within son-emu.
if len(self.bufferResource) > 0:
print(str(len(self.bufferResource)) +
- ' classes could not be created, because the dependencies could not be found.')
+ ' classes of the HOT could not be created, because the dependencies could not be found.')
+ print("the problem classes are:")
+ for br in self.bufferResource:
+ print("class: %s" % str(br))
return False
return True
stack.nets[net_name] = self.compute.create_network(net_name, True)
except Exception as e:
- logging.warning('Could not create Net: ' + e.message)
+ LOG.warning('Could not create Net: ' + e.message)
return
if 'OS::Neutron::Subnet' in resource['type'] and "Net" not in resource['type']:
if not stack_update:
net.set_cidr(IP.get_new_cidr(net.subnet_id))
except Exception as e:
- logging.warning('Could not create Subnet: ' + e.message)
+ LOG.warning('Could not create Subnet: ' + e.message)
return
if 'OS::Neutron::Port' in resource['type']:
else:
port = stack.ports[port_name]
- if resource['properties']['network']['get_resource'] in stack.nets:
+ if str(resource['properties']['network']['get_resource']) in stack.nets:
net = stack.nets[resource['properties']['network']['get_resource']]
if net.subnet_id is not None:
port.net_name = net.name
port.ip_address = net.get_new_ip_address(port.name)
return
except Exception as e:
- logging.warning('Could not create Port: ' + e.message)
+ LOG.warning('Could not create Port: ' + e.message)
self.bufferResource.append(resource)
return
server.port_names.append(port_name)
return
except Exception as e:
- logging.warning('Could not create Server: ' + e.message)
+ LOG.warning('Could not create Server: ' + e.message)
return
if 'OS::Neutron::RouterInterface' in resource['type']:
stack.routers[router_name].add_subnet(subnet_name)
return
except Exception as e:
- logging.warning('Could not create RouterInterface: ' + e.__repr__())
+ LOG.warning('Could not create RouterInterface: ' + e.__repr__())
self.bufferResource.append(resource)
return
stack.ports[port_name].floating_ip = floating_network_id
except Exception as e:
- logging.warning('Could not create FloatingIP: ' + e.message)
+ LOG.warning('Could not create FloatingIP: ' + e.message)
return
if 'OS::Neutron::Router' in resource['type']:
print('Could not create Router: ' + e.message)
return
- logging.warning('Could not determine resource type!')
+ if 'OS::Heat::ResourceGroup' in resource['type']:
+ try:
+ embedded_resource = resource['properties']['resource_def']
+ LOG.debug("Found resource in resource group: {}".format(embedded_resource))
+ # recursively parse embedded resource
+ self.handle_resource(embedded_resource, stack, dc_label, stack_update)
+ except Exception as e:
+ print('Could not create Router: ' + e.message)
+ return
+
+ LOG.warning('Could not determine resource type: {}'.format(resource['type']))
return
def shorten_server_name(self, server_name, stack):