Example #1
0
    def create(self, app_obj):
        """Deploy a given pattern."""
        if app_obj.pargs.debug is True:
            print "Vagrant does not support debug logging"

        context = self.scenario.context
        raw_template = self.scenario.template
        working_path = self._working_path(app_obj)

        if os.path.isdir(working_path):
            print colored("Error: ", "red") + "Working directory already exists"
            print "Either a stack of this name is already running or an orphaned directory exists."
            exit(1)

        # Download box if it is not installed
        if context['parameters']['BoxName'] is not None:
            name = context['parameters']['BoxName']
            url = context['parameters']['BoxUrl']

            if name not in self._list_box_names(self.vagrant_backend):
                try:
                    print " - Downloading box %s" % (name)
                    execute('vagrant box add %s %s' % (name, url))
                except subprocess.CalledProcessError:
                    print colored("Error: ", "red") + 'Attempt to download box exited with a non-zero exit code.'
                    exit(1)

        try:
            if app_obj.pargs.develop is True:
                print " -", colored("Development mode:", "yellow"), "Symlinking payload to working directory"
                os.mkdir(working_path)
                os.symlink(self.payload_path, os.path.join(working_path, 'payload'))
            else:
                print " - Copying payload to working directory"
                shutil.copytree(self.payload_path, os.path.join(working_path, 'payload'))
        except:
            print colored("Error: ", "red") + "Unable to create payload directory"
            shutil.rmtree(working_path)
            exit(1)

        print " - Generating Vagrantfile"
        try:
            f = open(os.path.join(working_path, 'Vagrantfile'), 'w')
            f.write(raw_template)
            f.close()
        except:
            print colored("Error: ", "red") + "Unable to generate Vagrantfile"
            exit(1)

        with cwd(working_path):
            #v = vagrant.Vagrant()
            vm_name = None
            try:
                print " - Running Vagrant from: %s" % (working_path)
                print ""
                #v.up(provider=self.vagrant_backend, vm_name=vm_name)
                execute('vagrant up')
                print 'Vagrant run complete. Run "nepho stack status" for details or "nepho stack access" to connect.'
            except subprocess.CalledProcessError:
                print colored("Error: ", "red") + 'Vagrant exited with a non-zero exit code, but your VM may be running.  Run "nepho stack status" for details.'
Example #2
0
    def create(self, app_obj):
        """Deploy a given pattern."""
        if app_obj.pargs.debug is True:
            print "Vagrant does not support debug logging"

        context = self.scenario.context
        raw_template = self.scenario.template
        working_path = self._working_path(app_obj)

        if os.path.isdir(working_path):
            print colored("Error: ", "red") + "Working directory already exists"
            print "Either a stack of this name is already running or an orphaned directory exists."
            exit(1)

        # Download box if it is not installed
        if context['parameters']['BoxName'] is not None:
            name = context['parameters']['BoxName']
            url = context['parameters']['BoxUrl']

            if name not in self._list_box_names(self.vagrant_backend):
                try:
                    print " - Downloading box %s" % (name)
                    execute('vagrant box add %s %s' % (name, url))
                except subprocess.CalledProcessError:
                    print colored("Error: ", "red") + 'Attempt to download box exited with a non-zero exit code.'
                    exit(1)

        try:
            if app_obj.pargs.develop is True:
                print " -", colored("Development mode:", "yellow"), "Symlinking payload to working directory"
                os.mkdir(working_path)
                os.symlink(self.payload_path, os.path.join(working_path, 'payload'))
            else:
                print " - Copying payload to working directory"
                shutil.copytree(self.payload_path, os.path.join(working_path, 'payload'))
        except:
            print colored("Error: ", "red") + "Unable to create payload directory"
            shutil.rmtree(working_path)
            exit(1)

        print " - Generating Vagrantfile"
        try:
            f = open(os.path.join(working_path, 'Vagrantfile'), 'w')
            f.write(raw_template)
            f.close()
        except:
            print colored("Error: ", "red") + "Unable to generate Vagrantfile"
            exit(1)

        with cwd(working_path):
            #v = vagrant.Vagrant()
            vm_name = None
            try:
                print " - Running Vagrant from: %s" % (working_path)
                print ""
                #v.up(provider=self.vagrant_backend, vm_name=vm_name)
                execute('vagrant up')
                print 'Vagrant run complete. Run "nepho stack status" for details or "nepho stack access" to connect.'
            except subprocess.CalledProcessError:
                print colored("Error: ", "red") + 'Vagrant exited with a non-zero exit code, but your VM may be running.  Run "nepho stack status" for details.'
Example #3
0
    def update(self, app_obj):
        if app_obj.pargs.debug is True:
            print "Vagrant does not support debug logging"

        context = self.scenario.context
        raw_template = self.scenario.template
        working_path = self._working_path(app_obj)

        if not os.path.isdir(working_path):
            print colored("Error: ", "red") + "Working directory does not exist"
            print "Update can only be run on a running stack."
            exit(1)

        try:
            if app_obj.pargs.develop is True:
                print " -", colored("Development mode:", "yellow"), "Not updating payload"
            else:
                print " - Deleting old payload from working directory"
                shutil.rmtree(os.path.join(working_path, 'payload'))
                print " - Copying payload to working directory"
                shutil.copytree(self.payload_path, os.path.join(working_path, 'payload'))
        except:
            print colored("Error: ", "red") + "Unable to update payload directory"
            exit(1)

        with cwd(working_path):
            vm_name = None
            try:
                execute('vagrant provision')
            except subprocess.CalledProcessError:
                print colored("Error: ", "red") + 'Vagrant provision exited with a non-zero exit code.'
Example #4
0
    def update(self, app_obj):
        if app_obj.pargs.debug is True:
            print "Vagrant does not support debug logging"

        context = self.scenario.context
        raw_template = self.scenario.template
        working_path = self._working_path(app_obj)

        if not os.path.isdir(working_path):
            print colored("Error: ", "red") + "Working directory does not exist"
            print "Update can only be run on a running stack."
            exit(1)

        try:
            if app_obj.pargs.develop is True:
                print " -", colored("Development mode:", "yellow"), "Not updating payload"
            else:
                print " - Deleting old payload from working directory"
                shutil.rmtree(os.path.join(working_path, 'payload'))
                print " - Copying payload to working directory"
                shutil.copytree(self.payload_path, os.path.join(working_path, 'payload'))
        except:
            print colored("Error: ", "red") + "Unable to update payload directory"
            exit(1)

        with cwd(working_path):
            vm_name = None
            try:
                execute('vagrant provision')
            except subprocess.CalledProcessError:
                print colored("Error: ", "red") + 'Vagrant provision exited with a non-zero exit code.'