diff --git a/MANIFEST.in b/MANIFEST.in index c978a52..fdc88bd 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,7 @@ -include AUTHORS -include ChangeLog exclude .gitignore exclude .gitreview - global-exclude *.pyc + +include AUTHORS +include ChangeLog +include molteniron/conf.yaml diff --git a/conf.yaml b/molteniron/conf.yaml similarity index 100% rename from conf.yaml rename to molteniron/conf.yaml diff --git a/molteniron/molteniron b/molteniron/molteniron index 6cf33e6..302629c 100755 --- a/molteniron/molteniron +++ b/molteniron/molteniron @@ -29,6 +29,7 @@ import argparse import json from molteniron import molteniron import os +from pkg_resources import resource_filename import sys import yaml @@ -77,11 +78,11 @@ if __name__ == "__main__": print(msg, file=sys.stderr) sys.exit(1) - yaml_file = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) + YAML_CONF = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) else: - yaml_file = "/usr/local/etc/molteniron/conf.yaml" + YAML_CONF = resource_filename("molteniron", "conf.yaml") - with open(yaml_file, "r") as fobj: + with open(YAML_CONF, "r") as fobj: conf = yaml.load(fobj) mi.setup_conf(conf) diff --git a/molteniron/moltenirond-helper b/molteniron/moltenirond-helper index 1663739..2095a45 100755 --- a/molteniron/moltenirond-helper +++ b/molteniron/moltenirond-helper @@ -25,15 +25,16 @@ This is a helper program for the MoltenIron server. from __future__ import print_function import argparse -import sys -import os -import signal -import yaml from daemonize import Daemonize from molteniron import moltenirond +import os +from pkg_resources import resource_filename +import signal +import sys +import yaml PID = "/var/run/moltenirond.pid" -YAML_CONF = "/usr/local/etc/molteniron/conf.yaml" +YAML_CONF = None ERROR_LOGFILE = "/tmp/MoltenIron-error-logfile" @@ -120,6 +121,12 @@ if __name__ == "__main__": sys.exit(1) YAML_CONF = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) + else: + YAML_CONF = resource_filename("molteniron", "conf.yaml") + + # Test for read ability + fobj = open(YAML_CONF, "r") + fobj.close() if args.pid_dir: if not os.path.isdir(args.pid_dir): diff --git a/molteniron/moltenirond.py b/molteniron/moltenirond.py index 5010f10..84f7639 100755 --- a/molteniron/moltenirond.py +++ b/molteniron/moltenirond.py @@ -34,6 +34,7 @@ import calendar from datetime import datetime import json import os +from pkg_resources import resource_filename import sys import time import traceback @@ -1334,11 +1335,11 @@ if __name__ == "__main__": print(msg, file=sys.stderr) sys.exit(1) - yaml_file = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) + YAML_CONF = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) else: - yaml_file = "/usr/local/etc/molteniron/conf.yaml" + YAML_CONF = resource_filename("molteniron", "conf.yaml") - with open(yaml_file, "r") as fobj: + with open(YAML_CONF, "r") as fobj: conf = yaml.load(fobj) listener(conf) diff --git a/molteniron/tests/testAddBMNode.py b/molteniron/tests/testAddBMNode.py index d77f34c..ac87244 100755 --- a/molteniron/tests/testAddBMNode.py +++ b/molteniron/tests/testAddBMNode.py @@ -26,6 +26,7 @@ from __future__ import print_function import argparse from molteniron import moltenirond import os +from pkg_resources import resource_filename import sys import yaml @@ -46,11 +47,11 @@ if __name__ == "__main__": print(msg, file=sys.stderr) sys.exit(1) - yaml_file = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) + YAML_CONF = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) else: - yaml_file = "/usr/local/etc/molteniron/conf.yaml" + YAML_CONF = resource_filename("molteniron", "conf.yaml") - with open(yaml_file, "r") as fobj: + with open(YAML_CONF, "r") as fobj: conf = yaml.load(fobj) request1 = { diff --git a/molteniron/tests/testAllocateBM.py b/molteniron/tests/testAllocateBM.py index 01cc255..dcc31cd 100755 --- a/molteniron/tests/testAllocateBM.py +++ b/molteniron/tests/testAllocateBM.py @@ -27,6 +27,7 @@ import argparse import json from molteniron import moltenirond import os +from pkg_resources import resource_filename import sys import yaml @@ -88,11 +89,11 @@ if __name__ == "__main__": print(msg, file=sys.stderr) sys.exit(1) - yaml_file = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) + YAML_CONF = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) else: - yaml_file = "/usr/local/etc/molteniron/conf.yaml" + YAML_CONF = resource_filename("molteniron", "conf.yaml") - with open(yaml_file, "r") as fobj: + with open(YAML_CONF, "r") as fobj: conf = yaml.load(fobj) request1 = { diff --git a/molteniron/tests/testCull.py b/molteniron/tests/testCull.py index f8e9b4a..7be5b66 100755 --- a/molteniron/tests/testCull.py +++ b/molteniron/tests/testCull.py @@ -27,6 +27,7 @@ import argparse import json from molteniron import moltenirond import os +from pkg_resources import resource_filename import sys import time import yaml @@ -86,11 +87,11 @@ if __name__ == "__main__": print(msg, file=sys.stderr) sys.exit(1) - yaml_file = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) + YAML_CONF = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) else: - yaml_file = "/usr/local/etc/molteniron/conf.yaml" + YAML_CONF = resource_filename("molteniron", "conf.yaml") - with open(yaml_file, "r") as fobj: + with open(YAML_CONF, "r") as fobj: conf = yaml.load(fobj) request1 = { diff --git a/molteniron/tests/testDeallocateBM.py b/molteniron/tests/testDeallocateBM.py index 57470a7..0e7ea36 100755 --- a/molteniron/tests/testDeallocateBM.py +++ b/molteniron/tests/testDeallocateBM.py @@ -27,6 +27,7 @@ import argparse import json from molteniron import moltenirond import os +from pkg_resources import resource_filename import sys import yaml @@ -88,11 +89,11 @@ if __name__ == "__main__": print(msg, file=sys.stderr) sys.exit(1) - yaml_file = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) + YAML_CONF = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) else: - yaml_file = "/usr/local/etc/molteniron/conf.yaml" + YAML_CONF = resource_filename("molteniron", "conf.yaml") - with open(yaml_file, "r") as fobj: + with open(YAML_CONF, "r") as fobj: conf = yaml.load(fobj) request1 = { diff --git a/molteniron/tests/testDeallocateOwner.py b/molteniron/tests/testDeallocateOwner.py index 5db1213..a91976a 100755 --- a/molteniron/tests/testDeallocateOwner.py +++ b/molteniron/tests/testDeallocateOwner.py @@ -27,6 +27,7 @@ import argparse import json from molteniron import moltenirond import os +from pkg_resources import resource_filename import sys import yaml @@ -88,11 +89,11 @@ if __name__ == "__main__": print(msg, file=sys.stderr) sys.exit(1) - yaml_file = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) + YAML_CONF = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) else: - yaml_file = "/usr/local/etc/molteniron/conf.yaml" + YAML_CONF = resource_filename("molteniron", "conf.yaml") - with open(yaml_file, "r") as fobj: + with open(YAML_CONF, "r") as fobj: conf = yaml.load(fobj) request1 = { diff --git a/molteniron/tests/testDoClean.py b/molteniron/tests/testDoClean.py index b581cfb..9590dae 100755 --- a/molteniron/tests/testDoClean.py +++ b/molteniron/tests/testDoClean.py @@ -26,6 +26,7 @@ from __future__ import print_function import argparse from molteniron import moltenirond import os +from pkg_resources import resource_filename import sys import yaml @@ -47,11 +48,11 @@ if __name__ == "__main__": print(msg, file=sys.stderr) sys.exit(1) - yaml_file = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) + YAML_CONF = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) else: - yaml_file = "/usr/local/etc/molteniron/conf.yaml" + YAML_CONF = resource_filename("molteniron", "conf.yaml") - with open(yaml_file, "r") as fobj: + with open(YAML_CONF, "r") as fobj: conf = yaml.load(fobj) request1 = { diff --git a/molteniron/tests/testGetField.py b/molteniron/tests/testGetField.py index a1bcae3..6a9b787 100755 --- a/molteniron/tests/testGetField.py +++ b/molteniron/tests/testGetField.py @@ -26,6 +26,7 @@ from __future__ import print_function import argparse from molteniron import moltenirond import os +from pkg_resources import resource_filename import sys import yaml @@ -47,11 +48,11 @@ if __name__ == "__main__": print(msg, file=sys.stderr) sys.exit(1) - yaml_file = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) + YAML_CONF = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) else: - yaml_file = "/usr/local/etc/molteniron/conf.yaml" + YAML_CONF = resource_filename("molteniron", "conf.yaml") - with open(yaml_file, "r") as fobj: + with open(YAML_CONF, "r") as fobj: conf = yaml.load(fobj) request1 = { diff --git a/molteniron/tests/testGetIps.py b/molteniron/tests/testGetIps.py index 5f464c5..6f0f8c1 100755 --- a/molteniron/tests/testGetIps.py +++ b/molteniron/tests/testGetIps.py @@ -26,6 +26,7 @@ from __future__ import print_function import argparse from molteniron import moltenirond import os +from pkg_resources import resource_filename import sys import yaml @@ -47,11 +48,11 @@ if __name__ == "__main__": print(msg, file=sys.stderr) sys.exit(1) - yaml_file = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) + YAML_CONF = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) else: - yaml_file = "/usr/local/etc/molteniron/conf.yaml" + YAML_CONF = resource_filename("molteniron", "conf.yaml") - with open(yaml_file, "r") as fobj: + with open(YAML_CONF, "r") as fobj: conf = yaml.load(fobj) request1 = { diff --git a/molteniron/tests/testRemoveBMNode.py b/molteniron/tests/testRemoveBMNode.py index 122dba5..38fa923 100755 --- a/molteniron/tests/testRemoveBMNode.py +++ b/molteniron/tests/testRemoveBMNode.py @@ -26,6 +26,7 @@ from __future__ import print_function import argparse from molteniron import moltenirond import os +from pkg_resources import resource_filename import sys import yaml @@ -47,11 +48,11 @@ if __name__ == "__main__": print(msg, file=sys.stderr) sys.exit(1) - yaml_file = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) + YAML_CONF = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) else: - yaml_file = "/usr/local/etc/molteniron/conf.yaml" + YAML_CONF = resource_filename("molteniron", "conf.yaml") - with open(yaml_file, "r") as fobj: + with open(YAML_CONF, "r") as fobj: conf = yaml.load(fobj) request1 = { diff --git a/setup.py b/setup.py index c970146..e73540e 100755 --- a/setup.py +++ b/setup.py @@ -34,6 +34,7 @@ setup(name="molteniron", "molteniron/molteniron", "utils/test_hook_mi_ipmiblob.py", "utils/test_hook_mi_ipmiblob.sh"], - data_files=[("etc/molteniron/", ["conf.yaml"])], + package_data={"molteniron": ["*.yaml"]}, + include_package_data=True, setup_requires=['pbr'], pbr=True) diff --git a/tox.ini b/tox.ini index 026c736..1e7cfb7 100644 --- a/tox.ini +++ b/tox.ini @@ -22,17 +22,13 @@ commands = mkdir -p testenv/var/run/ --install-scripts=testenv/bin/ \ --install-purelib=testenv/lib/python2.7/site-packages/ moltenirond-helper \ - --conf-dir=testenv/etc/molteniron/ \ --pid-dir=testenv/var/run/ \ start molteniron \ - --conf-dir=testenv/etc/molteniron/ \ delete_db molteniron \ - --conf-dir=testenv/etc/molteniron/ \ add_baremetal test1 10.1.2.1 user password 10.1.2.3,10.1.2.4 de:ad:be:ef:00:01 ppc64el 8 2048 32 molteniron \ - --conf-dir=testenv/etc/molteniron/ \ add_keyvalue_pairs test2 \ 10.1.2.2 \ 10.1.2.5,10.1.2.6 \ @@ -51,53 +47,39 @@ commands = mkdir -p testenv/var/run/ # passes in '\\{"ipmi_user": "user"\\}' which breaks json.loads() # ValueError: No JSON object could be decoded # molteniron \ -# --conf-dir=testenv/etc/molteniron/ \ # add_json_blob test3 \ # 10.1.2.3 \ # 10.1.2.7,10.1.2.8 \ # '{"ipmi_user": "user", "ipmi_password": "password", "port_hwaddr": "de:ad:be:ef:00:01", "cpu_arch": "ppc64el", "cpus": 8, "ram_mb": 2048, "disk_gb": 32''}' molteniron \ - --conf-dir=testenv/etc/molteniron/ \ allocate hamzy 1 molteniron \ - --conf-dir=testenv/etc/molteniron/ \ get_field hamzy port_hwaddr molteniron \ - --conf-dir=testenv/etc/molteniron/ \ release hamzy # Sadly needs a bash shell to run uuidgen test_hook_mi_ipmiblob.sh diff testenv/tmp/hardware_info molteniron/tests/hardware_info.good diff testenv/tmp/localrc molteniron/tests/localrc.good python \ - molteniron/tests/testAllocateBM.py \ - --conf-dir=testenv/etc/molteniron/ + molteniron/tests/testAllocateBM.py python \ - molteniron/tests/testAddBMNode.py \ - --conf-dir=testenv/etc/molteniron/ + molteniron/tests/testAddBMNode.py python \ - molteniron/tests/testCull.py \ - --conf-dir=testenv/etc/molteniron/ + molteniron/tests/testCull.py python \ - molteniron/tests/testDeallocateBM.py \ - --conf-dir=testenv/etc/molteniron/ + molteniron/tests/testDeallocateBM.py python \ - molteniron/tests/testDeallocateOwner.py \ - --conf-dir=testenv/etc/molteniron/ + molteniron/tests/testDeallocateOwner.py python \ - molteniron/tests/testDoClean.py \ - --conf-dir=testenv/etc/molteniron/ + molteniron/tests/testDoClean.py python \ - molteniron/tests/testGetField.py \ - --conf-dir=testenv/etc/molteniron/ + molteniron/tests/testGetField.py python \ - molteniron/tests/testGetIps.py \ - --conf-dir=testenv/etc/molteniron/ + molteniron/tests/testGetIps.py python \ - molteniron/tests/testRemoveBMNode.py \ - --conf-dir=testenv/etc/molteniron/ + molteniron/tests/testRemoveBMNode.py moltenirond-helper \ - --conf-dir=testenv/etc/molteniron/ \ --pid-dir=testenv/var/run/ \ stop diff --git a/utils/createDB.py b/utils/createDB.py index 83b4b0d..52a93bd 100755 --- a/utils/createDB.py +++ b/utils/createDB.py @@ -40,7 +40,7 @@ def main(): # This program is located in molteniron/utils/ directory. # The conf.yaml is located in the molteniron/ directory. newPath = "/".join(dirs[:-2]) + "/" - fobj = open(newPath + "conf.yaml", "r") + fobj = open(newPath + "molteniron/conf.yaml", "r") conf = yaml.load(fobj) # Create the SQL User diff --git a/utils/test_hook_mi_ipmiblob.py b/utils/test_hook_mi_ipmiblob.py index 5876ee0..88589fb 100755 --- a/utils/test_hook_mi_ipmiblob.py +++ b/utils/test_hook_mi_ipmiblob.py @@ -29,6 +29,7 @@ import argparse import json from molteniron import molteniron import os +from pkg_resources import resource_filename import sys import yaml @@ -72,12 +73,12 @@ if __name__ == "__main__": print(msg, file=sys.stderr) sys.exit(1) - yaml_file = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) + YAML_CONF = os.path.realpath("%s/conf.yaml" % (args.conf_dir, )) else: - yaml_file = "/usr/local/etc/molteniron/conf.yaml" + YAML_CONF = resource_filename("molteniron", "conf.yaml") - with open(yaml_file, "r") as f_obj: - conf = yaml.load(f_obj) + with open(YAML_CONF, "r") as fobj: + conf = yaml.load(fobj) mi.setup_conf(conf) mi.setup_parser(parser) diff --git a/utils/test_hook_mi_ipmiblob.sh b/utils/test_hook_mi_ipmiblob.sh index 3383bd7..c7eb557 100755 --- a/utils/test_hook_mi_ipmiblob.sh +++ b/utils/test_hook_mi_ipmiblob.sh @@ -16,7 +16,6 @@ # limitations under the License. test_hook_mi_ipmiblob.py \ - --conf-dir=testenv/etc/molteniron/ \ --hardware-info=testenv/tmp/hardware_info \ --localrc=testenv/tmp/localrc \ $(uuidgen) \