Machine prefix should be configurable #121

Closed
purpleidea opened this Issue Jan 7, 2014 · 6 comments

Comments

Projects
None yet
2 participants
Contributor

purpleidea commented Jan 7, 2014

When you are in a vagrant project dir called 'foo', and you start a machine named 'bar', the image file created is named foo_bar.img, and the vm name used is foo_bar.

I think other providers call this vm.name = 'foo_bar' or something. Not sure exactly.

In any case, it would be nice to support this functionality. I'm told it's standard.

If it exists, and I don't know the name for it, then sorry for the noise.

Cheers,
James

Collaborator

sciurus commented Jan 11, 2014

Hi James,

There are three different names that I can think of:

  1. The string to which vagrant set's the VM OS's hostname. This is configured via the host_name method.

  2. The string vagrant uses to identify a VM in a multi-machine environment. This is configured via an argument to the define method.

  3. The string to which vagrant sets the hypervisor's name for the VM. For the libvirt provider this is not currently configurable. It's constructed from the name of the directory holding the Vagrantfile and 2.

So in this example

$ cat my_project/Vagrantfile
config.vm.define :vagrant_name do |vagrant_name|
  vagrant_name.host_name = "host_name"
end

1 is "host_name", 2 is "vagrant_name", and 3 is "my_project_vagrant_name".

What you're interested in setting is 3, right? I see where this was added for virtualbox as the method name. Adding the same to vagrant-libvirt should be easy. If you're interested, I can let you know how to get started developing this.

Contributor

purpleidea commented Jan 11, 2014

What you're interested in setting is 3, right? I see where this was added for virtualbox as the method name. Adding the same to vagrant-libvirt should be easy. If you're interested, I can let you know how to get started developing this.

Right! Thanks for pointing me to the virtualbox equivalent patch. I'll have a look at this, and put this type of patch on my TODO list. If you have comments to add for the patch, please let me know, and I'll be sure to take them into account when hacking.

As a side note, instead of 2, I actually use 'vagrant_name.vm.hostname' as seen in:
https://github.com/purpleidea/puppet-gluster/blob/master/vagrant/gluster/Vagrantfile

Not sure if they are equivalent, but it seems to do the trick.

Collaborator

sciurus commented Jan 11, 2014

If you wanted to develop this, you'd need to

  • add a new attribute in config.rb
  • change the logic in action/set_name_of_domain.rb to use the new attribute if it is set, and otherwise use the current naming logic

Hopefully I'm not forgetting anything. Let me know if you run in to any trouble.

Contributor

purpleidea commented Jan 12, 2014

@sciurus

Okay, I've got a patch for what I'd like to implement:
pradels#122

I also think as a second patch it would make sense to also add a 'vm.name' support, like the virtualbox provider does, but that's a second issue.

Actually, when I tried to add a 'name' property, it got blocked:

There are errors in the configuration of this machine. Please fix
the following errors and try again:
vm:
* The following settings shouldn't exist: name

I guess it's some sort of reserved value, and there's a special way to implement this.

In any case, please merge the prefix patch or let me know if there are any issues.

Cheers,
James

cc: @pradels

Collaborator

sciurus commented Jan 18, 2014

Since this is merged are we ready to close this issue?

Contributor

purpleidea commented Jan 19, 2014

Of course :)

purpleidea closed this Jan 19, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment