forked from ungleich-public/cdist
prepare source records, cleanup
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
b4a431a03b
commit
6485299a7c
1 changed files with 21 additions and 36 deletions
57
bin/cdist
57
bin/cdist
|
@ -77,37 +77,6 @@ def file_to_list(filename):
|
|||
|
||||
return lines
|
||||
|
||||
class TypeEmulator:
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
self.type = os.path.basename(name)
|
||||
|
||||
|
||||
def type_emulator(self):
|
||||
type = basename(sys.argv[0])
|
||||
|
||||
type_is_singleton(type)
|
||||
|
||||
# Check object id
|
||||
|
||||
# Prevent double slash if id begins with /
|
||||
|
||||
# Record parameter: opt_file="${opt#--}"
|
||||
# [ $# -ge 1 ] || __cdist_usage "Missing value for $opt"
|
||||
# echo "${value}" > "${__cdist_parameter_dir}/${opt_file}"
|
||||
|
||||
# Record requirements
|
||||
# echo $requirement >> "$(__cdist_object_require "$__cdist_object_self")"
|
||||
|
||||
# Ensure required parameters are given
|
||||
# Ensure that only optional or required parameters are given
|
||||
# [ "$is_valid" ] || __cdist_usage "Unknown parameter $parameter"
|
||||
|
||||
# Merge object (creating twice with the same parameter + requirements == allowed)
|
||||
|
||||
# diff -ru "${__cdist_new_object_dir}/${__cdist_name_parameter}
|
||||
# # Add "I was here message"
|
||||
# _cdist_object_source_add "${__cdist_object_dir}"
|
||||
|
||||
class Cdist:
|
||||
"""Cdist main class to hold arbitrary data"""
|
||||
|
@ -471,9 +440,9 @@ class Cdist:
|
|||
# Legacy stuff to make cdist-type-emulator work
|
||||
env['__cdist_core_dir'] = os.path.join(self.base_dir, "core")
|
||||
env['__cdist_local_base_dir'] = self.temp_dir
|
||||
env['__cdist_manifest'] = self.initial_manifest
|
||||
|
||||
# Submit information to new type emulator
|
||||
env['__cdist_manifest'] = manifest
|
||||
env['__cdist_type_base_dir'] = self.type_base_dir
|
||||
|
||||
# Other environment stuff
|
||||
|
@ -644,22 +613,38 @@ def emulator():
|
|||
# Setup optional parameters
|
||||
for parameter in file_to_list(os.path.join(param_dir, "optional")):
|
||||
argument = "--" + parameter
|
||||
print("Adding" + argument)
|
||||
parser.add_argument(argument, action='store', required=False)
|
||||
|
||||
# Setup required parameters
|
||||
for parameter in file_to_list(os.path.join(param_dir, "required")):
|
||||
argument = "--" + parameter
|
||||
print("Adding" + argument)
|
||||
parser.add_argument(argument, action='store', required=True)
|
||||
|
||||
# Setup positional parameter, if not singleton
|
||||
|
||||
if not os.path.isfile(os.path.join(type_dir, "singleton")):
|
||||
parser.add_argument("object_id", nargs=1)
|
||||
else:
|
||||
print("singleton")
|
||||
|
||||
# And finally verify parameter
|
||||
args = parser.parse_args(sys.argv[1:])
|
||||
|
||||
print("Oh, noe")
|
||||
sys.exit(1)
|
||||
# Record parameter
|
||||
# wh
|
||||
print(args)
|
||||
|
||||
# Record requirements
|
||||
if "__require" in os.environ:
|
||||
requirements = os.environ['__require']
|
||||
|
||||
# Merge / mv object into tree
|
||||
|
||||
# Record / Append source
|
||||
source = os.environ['__cdist_manifest']
|
||||
# write to .source?
|
||||
|
||||
# sys.exit(1)
|
||||
|
||||
|
||||
def commandline():
|
||||
|
|
Loading…
Reference in a new issue