Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Noe Nieto
Shipwright - LDH Developer
Commits
52b76175
Commit
52b76175
authored
Nov 26, 2018
by
Noe Nieto
💬
Browse files
Use XDG_CONFIG_HOME instead of custom one
parent
cfc325cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
shipyard/shipyard
View file @
52b76175
...
...
@@ -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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment