Call boxes list from a config.rb

10 views
Skip to first unread message

Joris van der Kwast

unread,
Jun 23, 2017, 2:59:45 PM6/23/17
to Vagrant
Hi,

I'm, pretty new to ruby, but not vagrant. I'm setting up a config file in config.rb, as for instance the folks at coreos do (https://coreos.com/os/docs/latest/booting-on-vagrant.html#clone-vagrant-repo).

In my own adaption I want to get an array to list all boxes that are available, but not sure how to. If I call the vagrantfile, with require_relative config.rb, how would you call vagrant::BoxCollections #all?

On windows/7.

Thnx,


Alvaro Miranda Aguilera

unread,
Jun 26, 2017, 3:47:12 AM6/26/17
to vagra...@googlegroups.com
If you can share a git repo of what you got, will be easier to have a look.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/f733108c-0132-46ea-948a-4f3cb22b1c32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Joris van der Kwast

unread,
Jul 1, 2017, 6:35:26 AM7/1/17
to Vagrant
Hi Alvaro,

Thank you fro your interest. I realized my total noobness to ruby and the vagrant code was the problem. So I did some reading and experimenting, and came up with a solution that works (although still clumpsy no doubt).

For completeness, I'll share what I came up with config.rb:

{
require "fileuitls"
require "vagrant"

# Clumpsy code, there must be a global to call
home_path = "#{ENV['HOME']}\\.vagrant.d\\boxes\\"
pn = Pathname.new(home_path)

boxes = Vagrant::BoxCollection::new(pn)
box = boxes.all

print "boxes = #{box} \n"
}

It works ;)


Op maandag 26 juni 2017 09:47:12 UTC+2 schreef Alvaro Miranda Aguilera:
If you can share a git repo of what you got, will be easier to have a look.
On Fri, Jun 23, 2017 at 8:59 PM, Joris van der Kwast <jvdk...@gmail.com> wrote:
Hi,

I'm, pretty new to ruby, but not vagrant. I'm setting up a config file in config.rb, as for instance the folks at coreos do (https://coreos.com/os/docs/latest/booting-on-vagrant.html#clone-vagrant-repo).

In my own adaption I want to get an array to list all boxes that are available, but not sure how to. If I call the vagrantfile, with require_relative config.rb, how would you call vagrant::BoxCollections #all?

On windows/7.

Thnx,


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.



--
Alvaro

Reply all
Reply to author
Forward
0 new messages