projects
/
osm
/
vim-emu.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
077e16f
)
Improved OpenStack API logging
author
peusterm
<manuel.peuster@uni-paderborn.de>
Mon, 19 Jun 2017 09:22:11 +0000
(11:22 +0200)
committer
peusterm
<manuel.peuster@uni-paderborn.de>
Mon, 19 Jun 2017 09:22:11 +0000
(11:22 +0200)
src/emuvim/api/openstack/compute.py
patch
|
blob
|
history
src/emuvim/api/openstack/heat_parser.py
patch
|
blob
|
history
src/emuvim/api/openstack/openstack_dummies/heat_dummy_api.py
patch
|
blob
|
history
diff --git
a/src/emuvim/api/openstack/compute.py
b/src/emuvim/api/openstack/compute.py
index
45cef59
..
fd9b1ac
100755
(executable)
--- a/
src/emuvim/api/openstack/compute.py
+++ b/
src/emuvim/api/openstack/compute.py
@@
-8,6
+8,9
@@
import time
import ip_handler as IP
import ip_handler as IP
+LOG = logging.getLogger("api.openstack.compute")
+
+
class HeatApiStackInvalidException(Exception):
"""
Exception thrown when a submitted stack is invalid.
class HeatApiStackInvalidException(Exception):
"""
Exception thrown when a submitted stack is invalid.
@@
-95,25
+98,25
@@
class OpenstackCompute(object):
for server in stack.servers.values():
for port_name in server.port_names:
if port_name not in stack.ports:
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:
(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:
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:
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:
(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:
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:
everything_ok = False
for router in stack.routers.values():
for subnet_name in router.subnet_names:
@@
-123,7
+126,7
@@
class OpenstackCompute(object):
found = True
break
if not found:
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
(router.name, stack.stack_name, subnet_name))
everything_ok = False
return everything_ok
@@
-208,6
+211,7
@@
class OpenstackCompute(object):
* *False*: else
:rtype: ``bool``
"""
* *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]
if old_stack_id not in self.stacks:
return False
old_stack = self.stacks[old_stack_id]
@@
-399,7
+403,7
@@
class OpenstackCompute(object):
:param server: Specifies the compute resource.
:type server: :class:`heat.resources.server`
"""
: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:
network = list()
for port_name in server.port_names:
@@
-447,7
+451,7
@@
class OpenstackCompute(object):
:param server: The server that should be removed
:type server: ``heat.resources.server``
"""
: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)
link_names = list()
for port_name in server.port_names:
link_names.append(self.find_port_by_name_or_id(port_name).intf_name)
@@
-553,9
+557,9
@@
class OpenstackCompute(object):
:type stack_operation: ``bool``
:return: :class:`heat.resources.net`
"""
: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:
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())
raise Exception("Network with name %s already exists." % name)
network = Net(name)
network.id = str(uuid.uuid4())
@@
-593,9
+597,9
@@
class OpenstackCompute(object):
"""
port = self.find_port_by_name_or_id(name)
if port is not None and not stack_operation:
"""
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)
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
port = Port(name)
if not stack_operation:
self.ports[port.id] = port
diff --git
a/src/emuvim/api/openstack/heat_parser.py
b/src/emuvim/api/openstack/heat_parser.py
index
672a76b
..
376659b
100755
(executable)
--- a/
src/emuvim/api/openstack/heat_parser.py
+++ b/
src/emuvim/api/openstack/heat_parser.py
@@
-8,6
+8,9
@@
import logging
import ip_handler as IP
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.
class HeatParser:
"""
The HeatParser will parse a heat dictionary and create a stack and its components, to instantiate it within son-emu.
@@
-96,7
+99,7
@@
class HeatParser:
stack.nets[net_name] = self.compute.create_network(net_name, True)
except Exception as e:
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']:
return
if 'OS::Neutron::Subnet' in resource['type'] and "Net" not in resource['type']:
@@
-116,7
+119,7
@@
class HeatParser:
if not stack_update:
net.set_cidr(IP.get_new_cidr(net.subnet_id))
except Exception as e:
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']:
return
if 'OS::Neutron::Port' in resource['type']:
@@
-135,7
+138,7
@@
class HeatParser:
port.ip_address = net.get_new_ip_address(port.name)
return
except Exception as e:
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
self.bufferResource.append(resource)
return
@@
-168,7
+171,7
@@
class HeatParser:
server.port_names.append(port_name)
return
except Exception as e:
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']:
return
if 'OS::Neutron::RouterInterface' in resource['type']:
@@
-189,7
+192,7
@@
class HeatParser:
stack.routers[router_name].add_subnet(subnet_name)
return
except Exception as e:
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
self.bufferResource.append(resource)
return
@@
-202,7
+205,7
@@
class HeatParser:
stack.ports[port_name].floating_ip = floating_network_id
except Exception as e:
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']:
return
if 'OS::Neutron::Router' in resource['type']:
@@
-214,7
+217,7
@@
class HeatParser:
print('Could not create Router: ' + e.message)
return
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):
return
def shorten_server_name(self, server_name, stack):
diff --git
a/src/emuvim/api/openstack/openstack_dummies/heat_dummy_api.py
b/src/emuvim/api/openstack/openstack_dummies/heat_dummy_api.py
index
e020a9d
..
107d8fd
100755
(executable)
--- a/
src/emuvim/api/openstack/openstack_dummies/heat_dummy_api.py
+++ b/
src/emuvim/api/openstack/openstack_dummies/heat_dummy_api.py
@@
-306,9
+306,11
@@
class HeatUpdateStack(Resource):
self.api = api
def put(self, tenant_id, stack_name_or_id, stack_id=None):
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):
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):
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):
@@
-323,7
+325,6
@@
class HeatUpdateStack(Resource):
500, if any exception occurred while updating.
202, if everything worked out.
"""
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:
try:
old_stack = None
if stack_name_or_id in self.api.compute.stacks: