Commit 52b76175 authored by Noe Nieto's avatar Noe Nieto 💬

Use XDG_CONFIG_HOME instead of custom one

parent cfc325cc
......@@ -27,12 +27,12 @@ Vagrant.configure("2") do |config|
end
"""
XDG_CONFIG_HOME = Path(os.environ['HOME'],'.config','ldh_developer','shipyard')
def only_if_box_exist(func):
def wrapper(*args, **kwargs):
hostname = args[0]
dot_shipyard = Path(os.environ['HOME'], '.shipyard')
vagrant_wd = dot_shipyard.joinpath(hostname)
vagrant_wd = XDG_CONFIG_HOME.joinpath(hostname)
if vagrant_wd.exists():
func(*args, **kwargs)
else:
......@@ -87,8 +87,7 @@ def create_box(hostname, ram, cpus):
"""
This creates a box using the template
"""
dot_shipyard = Path(os.environ['HOME'], '.shipyard')
vagrant_wd = dot_shipyard.joinpath(hostname)
vagrant_wd = XDG_CONFIG_HOME.joinpath(hostname)
if vagrant_wd.exists():
print("Shipyard error: There's already a vm with that hostname")
exit(0)
......@@ -112,8 +111,7 @@ def destroy_box(hostname):
"""
Destroy a box, or all
"""
dot_shipyard = Path(os.environ['HOME'], '.shipyard')
vagrant_wd = dot_shipyard.joinpath(hostname)
vagrant_wd = XDG_CONFIG_HOME.joinpath(hostname)
subprocess.run(['vagrant','destroy'], cwd=vagrant_wd)
shutil.rmtree(vagrant_wd)
......@@ -123,8 +121,7 @@ def run_playbook(hostname, playbook):
"""
run a playbook against one of the boxes
"""
dot_shipyard = Path(os.environ['HOME'], '.shipyard')
vagrant_wd = dot_shipyard.joinpath(hostname)
vagrant_wd = XDG_CONFIG_HOME.joinpath(hostname)
subprocess.run(['vagrant','destroy'], cwd=vagrant_wd)
......@@ -133,8 +130,7 @@ def invoke_shell(hostname):
"""
Open a SSH session to the hostname
"""
dot_shipyard = Path(os.environ['HOME'], '.shipyard')
vagrant_wd = dot_shipyard.joinpath(hostname)
vagrant_wd = XDG_CONFIG_HOME.joinpath(hostname)
subprocess.run(['vagrant','ssh'], cwd=vagrant_wd)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment