Quantcast

Setting a guest hostname

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Setting a guest hostname

polyvisual
Hi,

I've started writing a script which

1) deploys a guest from a template (it could be Linux or Windows)
2) set the guest's hostname
3) powers the guest on

1) and 3) are working fine but I'm stuck with 2)

Is setting a guest hostname before the guest is powered on even possible? Does it need to be set as part of the cloning procedure?

I've looked over http://pubs.vmware.com/vsphere-55/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc%2Fvim.vm.customization.Specification.html but I keep going round in circles.

It's likely I'm going about this in the wrong way, so any pointers in the right direction happily received. I'm fine with providing the code to the pyvmomi-community-samples github once it's working.

Cheers,
Matt
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Setting a guest hostname

hartsock
Administrator
> Is setting a guest hostname before the guest is powered on even possible?

It depends on what you mean. If you just wanted to set some data in
the vSphere representation of the VM, then you'll be able to do that.
There's a vSphere representation you can easily manipulate in the API.

If you mean setting it from a network perspective, then that's a
matter of doing things with a virtual NIC and its MAC address. That
can all be manipulated before first boot.

If you mean setting it in the guest OS itself... then depending on how
you're setting it the OS would need to be powered on. If you're
setting it via some bootp or dhcp mechanism then... yeah... that's not
in scope for pyVmomi. There's a few ways to achieve what you're after
depending on which tools make the most sense.

For example, if you have the vm tools or
https://github.com/vmware/open-vm-tools installed then when the guest
boots you can craft a run-level 1 script to read metadata we inject
into the VM's extra configs on boot. That's an interesting way of
tailoring the guest to deal with the virtual environment its embedded
in.

I know there's some special way to do this for Windows clients but
I've not messed with that section of the API very much myself.

Does that make sense?

On the sample side of things (always eager about getting more of those):

Do you have a partly working script you would be willing to post as a
https://gist.github.com/ ?

BTW: This sounds like one of those potential samples that gets
problematic because it requires some initial set up work. In a truly
useful form, we might have to document preconditions and setup.

On Wed, Sep 10, 2014 at 10:33 AM, Polyvisual [via pyvmomi]
<[hidden email]> wrote:

> Hi,
>
> I've started writing a script which
>
> 1) deploys a guest from a template (it could be Linux or Windows)
> 2) set the guest's hostname
> 3) powers the guest on
>
> 1) and 3) are working fine but I'm stuck with 2)
>
> Is setting a guest hostname before the guest is powered on even possible?
> Does it need to be set as part of the cloning procedure?
>
> I've looked over
> http://pubs.vmware.com/vsphere-55/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc%2Fvim.vm.customization.Specification.html
> but I keep going round in circles.
>
> It's likely I'm going about this in the wrong way, so any pointers in the
> right direction happily received. I'm fine with providing the code to the
> pyvmomi-community-samples github once it's working.
>
> Cheers,
> Matt
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://pyvmomi.2338814.n4.nabble.com/Setting-a-guest-hostname-tp3.html
> To start a new topic under pyvmomi, email
> [hidden email]
> To unsubscribe from pyvmomi, click here.
> NAML



--
# Shawn.Hartsock - twitter: @hartsock
Loading...