49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
#
|
|
# Copyright (c) 2013-2014 Dorian Pula <dorian.pula@amber-penguin-software.ca>
|
|
#
|
|
# Rookeries is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as
|
|
# published by the Free Software Foundation, either version 3 of
|
|
# the License, or (at your option) any later version.
|
|
#
|
|
# Rookeries is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public
|
|
# License along with Rookeries. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
# Please share and enjoy!
|
|
#
|
|
|
|
import pathlib
|
|
|
|
import invoke as inv
|
|
from invoke import exceptions as inv_error
|
|
import vagrant
|
|
|
|
from .. import package
|
|
|
|
|
|
@inv.task(package.build)
|
|
def to_vagrant():
|
|
vagrant_box = setup_vagrant_box()
|
|
if vagrant_box.status()[0].state != 'running':
|
|
vagrant_box.up()
|
|
|
|
|
|
def setup_vagrant_box():
|
|
vagrant_definition_path = pathlib.Path('vagrant')
|
|
if not (vagrant_definition_path.exists() and vagrant_definition_path.is_dir()):
|
|
error_message = 'No directory "{}" found.'.format(vagrant_definition_path.resolve())
|
|
raise inv_error.Failure(error_message)
|
|
|
|
vagrantfile_path = pathlib.Path(vagrant_definition_path.absolute(), 'Vagrantfile')
|
|
if not vagrantfile_path.is_file():
|
|
error_message = 'No Vagrantfile found in directory "{}" to run.'.format(vagrant_definition_path.resolve())
|
|
raise inv_error.Failure(error_message)
|
|
|
|
return vagrant.Vagrant(root=str(vagrant_definition_path.resolve()), quiet_stdout=False)
|
|
|