Compare commits
No commits in common. "a2b36e7299222141588c3e319f5bbad203f027a5" and "95038a060cb6b5ece8e5ab68c2594fe7ad94c35e" have entirely different histories.
a2b36e7299
...
95038a060c
43
main.py
43
main.py
|
@ -7,7 +7,6 @@ import configparser
|
|||
import os
|
||||
import socket
|
||||
import sys
|
||||
import uuid as uuid_module
|
||||
from ipaddress import AddressValueError, IPv4Address, IPv6Address
|
||||
from os import access, R_OK
|
||||
|
||||
|
@ -34,17 +33,10 @@ class CloudInitRequest:
|
|||
self.remoteip = None
|
||||
self.hostinfo = ('localhost', )
|
||||
self.request = request
|
||||
self.uuid = uuid
|
||||
self.meta_data = None
|
||||
self.meta_data_loaded = False
|
||||
self.user_data = None
|
||||
|
||||
try:
|
||||
self.uuid = str(uuid_module.UUID('{' + uuid + '}'))
|
||||
# ValueError is wrong UUID syntax
|
||||
# TypeError is None
|
||||
except (ValueError, TypeError):
|
||||
self.uuid = None
|
||||
|
||||
self._init_ip()
|
||||
self._generate_default_meta_data()
|
||||
|
||||
|
@ -134,7 +126,7 @@ class CloudInitRequest:
|
|||
filename = self._get_filename(META_DATA_FILENAME)
|
||||
if filename:
|
||||
self._update_meta_data_from_file(
|
||||
filename
|
||||
filename
|
||||
)
|
||||
self.meta_data_loaded = True
|
||||
return self.meta_data
|
||||
|
@ -202,8 +194,9 @@ class CloudInitApp:
|
|||
@staticmethod
|
||||
def _wrap_metadata(metadata):
|
||||
return {'ds': {
|
||||
'meta_data': metadata
|
||||
}}
|
||||
'meta_data': metadata
|
||||
}
|
||||
}
|
||||
|
||||
def _user_data(self, uuid=None):
|
||||
"""
|
||||
|
@ -301,19 +294,19 @@ if __name__ == "__main__":
|
|||
CONFIG["server"].getint("server_port", 8081)
|
||||
ENGINE = cherrypy.engine
|
||||
|
||||
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
CONFIG = {
|
||||
'/include': {
|
||||
'tools.staticdir.on': True,
|
||||
'tools.staticdir.dir': os.path.join(CURRENT_DIR,
|
||||
'data',
|
||||
'include'),
|
||||
'tools.staticdir.content_types': {
|
||||
'yml': 'text/yaml'
|
||||
}
|
||||
}
|
||||
}
|
||||
cherrypy.tree.mount(ROOT, config=CONFIG)
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
config = {
|
||||
'/include': {
|
||||
'tools.staticdir.on': True,
|
||||
'tools.staticdir.dir': os.path.join(current_dir,
|
||||
'data',
|
||||
'include'),
|
||||
'tools.staticdir.content_types': {
|
||||
'yml': 'text/yaml'
|
||||
}
|
||||
}
|
||||
}
|
||||
cherrypy.tree.mount(ROOT, config=config)
|
||||
|
||||
if hasattr(ENGINE, "signal_handler"):
|
||||
ENGINE.signal_handler.subscribe()
|
||||
|
|
Loading…
Reference in New Issue
Block a user