Fix for issue #75: no more -f in cfn-init
Removed -f in cfn-init. Instead, cfn-init reads resource metadata from /var/lib/cloud/data-cfn-init-data. Also, added logging. cfn-init now logs to stdout and to /var/log/cfn-init.log
This commit is contained in:
parent
20e10f2bf7
commit
64c654f71c
@ -40,7 +40,14 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
log_file_name = "/var/log/cfn-init.log"
|
||||||
|
log_format = '%(levelname)s [%(asctime)s] %(message)s'
|
||||||
|
# setup stdout logging
|
||||||
|
logging.basicConfig(format=log_format, level=logging.INFO)
|
||||||
|
# setup file logging
|
||||||
|
file_handler = logging.FileHandler(log_file_name)
|
||||||
|
file_handler.setFormatter(logging.Formatter(log_format))
|
||||||
|
logging.getLogger().addHandler(file_handler)
|
||||||
|
|
||||||
class CommandRunner(object):
|
class CommandRunner(object):
|
||||||
"""
|
"""
|
||||||
@ -560,12 +567,10 @@ def get_metadata(fname):
|
|||||||
|
|
||||||
|
|
||||||
## Main
|
## Main
|
||||||
|
metadata_file = "/var/lib/cloud/data-cfn-init-data"
|
||||||
|
|
||||||
description = " "
|
description = " "
|
||||||
parser = argparse.ArgumentParser(description=description)
|
parser = argparse.ArgumentParser(description=description)
|
||||||
parser.add_argument("-f", "--metadata-file",
|
|
||||||
dest="metafile",
|
|
||||||
help="File containing the resource metadata to process",
|
|
||||||
required=True)
|
|
||||||
parser.add_argument('-s', '--stack',
|
parser.add_argument('-s', '--stack',
|
||||||
dest="stack_name",
|
dest="stack_name",
|
||||||
help="A Heat stack name",
|
help="A Heat stack name",
|
||||||
@ -589,7 +594,7 @@ parser.add_argument('--region',
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
# FIXME: implement real arg
|
# FIXME: implement real arg
|
||||||
|
|
||||||
metadata = Metadata(get_metadata(args.metafile))
|
metadata = Metadata(get_metadata(metadata_file))
|
||||||
try:
|
try:
|
||||||
metadata.process()
|
metadata.process()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user