import ip_handler as IP
+LOG = logging.getLogger("api.openstack.compute")
+
+
class HeatApiStackInvalidException(Exception):
"""
Exception thrown when a submitted stack is invalid.
for server in stack.servers.values():
for port_name in server.port_names:
if port_name not in stack.ports:
- logging.warning("Server %s of stack %s has a port named %s that is not known." %
+ LOG.warning("Server %s of stack %s has a port named %s that is not known." %
(server.name, stack.stack_name, port_name))
everything_ok = False
if server.image is None:
- logging.warning("Server %s holds no image." % (server.name))
+ LOG.warning("Server %s holds no image." % (server.name))
everything_ok = False
if server.command is None:
- logging.warning("Server %s holds no command." % (server.name))
+ LOG.warning("Server %s holds no command." % (server.name))
everything_ok = False
for port in stack.ports.values():
if port.net_name not in stack.nets:
- logging.warning("Port %s of stack %s has a network named %s that is not known." %
+ LOG.warning("Port %s of stack %s has a network named %s that is not known." %
(port.name, stack.stack_name, port.net_name))
everything_ok = False
if port.intf_name is None:
- logging.warning("Port %s has no interface name." % (port.name))
+ LOG.warning("Port %s has no interface name." % (port.name))
everything_ok = False
if port.ip_address is None:
- logging.warning("Port %s has no IP address." % (port.name))
+ LOG.warning("Port %s has no IP address." % (port.name))
everything_ok = False
for router in stack.routers.values():
for subnet_name in router.subnet_names:
found = True
break
if not found:
- logging.warning("Router %s of stack %s has a network named %s that is not known." %
+ LOG.warning("Router %s of stack %s has a network named %s that is not known." %
(router.name, stack.stack_name, subnet_name))
everything_ok = False
return everything_ok
* *False*: else
:rtype: ``bool``
"""
+ LOG.debug("updating stack {} with new_stack {}".format(old_stack_id, new_stack))
if old_stack_id not in self.stacks:
return False
old_stack = self.stacks[old_stack_id]
:param server: Specifies the compute resource.
:type server: :class:`heat.resources.server`
"""
- logging.debug("Starting new compute resources %s" % server.name)
+ LOG.debug("Starting new compute resources %s" % server.name)
network = list()
for port_name in server.port_names:
:param server: The server that should be removed
:type server: ``heat.resources.server``
"""
- logging.debug("Stopping container %s with full name %s" % (server.name, server.full_name))
+ LOG.debug("Stopping container %s with full name %s" % (server.name, server.full_name))
link_names = list()
for port_name in server.port_names:
link_names.append(self.find_port_by_name_or_id(port_name).intf_name)
:type stack_operation: ``bool``
:return: :class:`heat.resources.net`
"""
- logging.debug("Creating network with name %s" % name)
+ LOG.debug("Creating network with name %s" % name)
if self.find_network_by_name_or_id(name) is not None and not stack_operation:
- logging.warning("Creating network with name %s failed, as it already exists" % name)
+ LOG.warning("Creating network with name %s failed, as it already exists" % name)
raise Exception("Network with name %s already exists." % name)
network = Net(name)
network.id = str(uuid.uuid4())
"""
port = self.find_port_by_name_or_id(name)
if port is not None and not stack_operation:
- logging.warning("Creating port with name %s failed, as it already exists" % name)
+ LOG.warning("Creating port with name %s failed, as it already exists" % name)
raise Exception("Port with name %s already exists." % name)
- logging.debug("Creating port with name %s" % name)
+ LOG.debug("Creating port with name %s" % name)
port = Port(name)
if not stack_operation:
self.ports[port.id] = port
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.
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']:
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!')
+ LOG.warning('Could not determine resource type: {}'.format(resource['type']))
return
def shorten_server_name(self, server_name, stack):
self.api = api
def put(self, tenant_id, stack_name_or_id, stack_id=None):
+ LOG.debug("API CALL: %s PUT" % str(self.__class__.__name__))
return self.update_stack(tenant_id, stack_name_or_id, stack_id)
def patch(self, tenant_id, stack_name_or_id, stack_id=None):
+ LOG.debug("API CALL: %s PATCH" % str(self.__class__.__name__))
return self.update_stack(tenant_id, stack_name_or_id, stack_id)
def update_stack(self, tenant_id, stack_name_or_id, stack_id=None):
500, if any exception occurred while updating.
202, if everything worked out.
"""
- LOG.debug("API CALL: %s PUT" % str(self.__class__.__name__))
try:
old_stack = None
if stack_name_or_id in self.api.compute.stacks: