[one-users] DHCP

Ruben S. Montero rsmontero at opennebula.org
Wed Jul 30 04:36:49 PDT 2014


Hi Kerry,

It seems that you are confused about not seeing the IP assigned by
OpenNebula matching the IP assigned by the DHCP server:

1. If the IP addresses are managed by the DHCP server, then you can just
ignore the IP assigned by OpenNebula. It is derived from the MAC and it is
not used in this case by OpenNebula.

if you need to populate the IP of the VM to the VM Template to be queried
through  Sunstone or CLI that could be done by onegate or a custom monitor
probe.

2. If OpenNebula manages the IPs you can integrate the DHCP server as
explained by Valentin

3. In 4.8 you can define the network as type Ethernet, to express that the
IP is manged externally and get rid of the IP inconsistency you may be
seeing.

Hope it  helps

Cheers

Ruben
On Jul 24, 2014 9:37 PM, "kerryhall ." <kerryhall at gmail.com> wrote:

> Valentin,
>
> Thank you for the help!
>
> Yes, AFAIK the DNS server is configured with a dynamic zone that is
> updated from the DHCP server.
>
> It sounds like the DHCP server in use is Microsoft DHCP. I would like to
> avoid using the DHCP API if possible, just because I have no experience in
> that area, and seems like a messy solution.
>
> Thinking about this more, here are the desired steps:
> 1. User spins up vm via web interface.
> 2. Contextualization sets "DHCP_HOSTNAME" to vm name.
> 3. DHCP server gives vm an IP address.
> 4. Sunstone sets the correct IP information in its database.
>
> I can basically do all this manually by
> 1. Spin up vm
> 2. edit ifcfg-eth0, setting BOOTPROTO and DHCP_HOSTNAME
> 3. restart networking
>
> So it sounds like I can write a bash script that takes care of 2. and 3.,
> something that runs when the vm is spun up.
>
> However, I don't know how to manually tell Sunstone what the new, correct
> IP is. Do you know how I could accomplish that?
>
> I can write a bash or perl script that fixes this manually in MySQL....but
> that seems like a Really Bad Idea. :)
>
> I'm surprised that OpenNebula doesn't support DHCP out of the box. Seems
> like a common use case. I wonder if I should make a feature request.
>
> Thanks!
> Kerry
>
>
>
> On Wed, Jul 23, 2014 at 10:03 PM, Valentin Bud <valentin.bud at gmail.com>
> wrote:
>
>> Hello Kerry,
>>
>> When you say "DNS and DHCP are tied into one system on my network" you
>> mean
>> your DNS server is configured with a dynamic zone that is updated from
>> the DHCP
>> server?
>>
>> If that is so, I guess you want a VM to acquire a lease from the DHCP
>> server equal
>> to the IP given by OpenNebula to that specific VM. This way it maintains
>> consistency.
>>
>> If you populate CONTEXT with NETWORK="YES", the contextualization
>> packages
>> will do the job of configuring the network. As far as I know it's not
>> possible to "tell"
>> the contextualization packages to leave the network unconfigured. So
>> using this approach
>> would not get you where you want.
>>
>> One way of achieving what you desire is to program a hook that inserts a
>> host in the
>> DHCP server via OMAPI [1]. From the hook you have access to the entire
>> template.
>> I am assuming you are using ISC DHCP. This would solve the consistency
>> issue.
>>
>> Now the VM needs to be configured for DHCP as you mentioned in your
>> previous E-Mail.
>>
>> For that you can define SET_HOSTNAME in the CONTEXT to have it available
>> in the
>> VM, create a simple (bash) program that reads it and sets ifcfg-eth0
>> accordingly. Put the
>> script in the files datastore and update the context to use it via
>> FILES_DS and INIT_SCRIPTS.
>>
>> For example you name your super script set_dhcp.sh. You can insert in the
>> files datastore [2]
>> using `oneimage create -d files --name set_dhcp.sh --type CONTEXT
>> /path/to/set_dhcp.sh`.
>>
>> Update the template to use it.
>>
>> CONTEXT=[
>> FILES_DS="$FILE[IMAGE=\"set_dhcp.sh\",
>> INIT_SCRIPTS="set_dhcp.sh"]
>>
>> This way the vmcontext init.d script from the contextualization packages
>> would skip the
>> network configuration, note NETWORK="YES" is missing and it would run the
>> set_dhcp.sh
>> script.
>>
>> One more thing that comes to mind, SET_HOSTNAME would instruct the
>> vmcontext init
>> script to set the hostname and maybe that's not what you want, maybe you
>> want your VM
>> to set it's hostname from DHCP. In this case use another variable, like
>> DHCP_HOSTNAME
>> in CONTEXT and process it in set_dhcp.sh to configure ifcfg-eth0.
>>
>> You can set DHCP_HOSTNAME=$NAME inside the template. This way the name you
>> give the VM in Sunstone would end up being used.
>>
>> Take the above with a grain of salt, I am sure there are other (better)
>> ways of achieving
>> what you desire.
>>
>> @Diego could you please point me where have you find DHCP in the VNET
>> template?
>> I have looked over the docs and couldn't find it.
>>
>> [1]: http://ipamworldwide.com/dhcp-api.html
>> [2]: http://docs.opennebula.org/4.6/administration/storage/file_ds.html
>>
>> Best,
>> Valentin
>>
>> On Wed, Jul 23, 2014 at 10:45 PM, kerryhall . <kerryhall at gmail.com>
>> wrote:
>>
>>> I have managed to figure out how to edit my template (onetemplate update
>>> TEMPLATE_ID) so I can now set the hostname. However, DNS and DHCP are tied
>>> into one system on my network, so I can't perform a dig on my new server
>>> and get the IP back.
>>>
>>> I just need to know what lines to add to my template file to get my vms
>>> to use DHCP only. I'm sure it's something really simple, I just can't find
>>> any info here:
>>> http://docs.opennebula.org/4.6/user/virtual_machine_setup/cong.html
>>>
>>> If you know how to get DHCP working, please let me know.
>>>
>>> Thank you!!
>>>
>>>
>>> On Tue, Jul 22, 2014 at 3:48 PM, kerryhall . <kerryhall at gmail.com>
>>> wrote:
>>>
>>>> Hi folks,
>>>>
>>>> I want to configure Open Nebula to contextualize two items for
>>>> ifcfg-eth0.
>>>>
>>>> BOOTPROTO=dhcp
>>>> and
>>>> DHCP_HOSTNAME=<parameter passed in via ONE web interface, even just
>>>> vm-name would work>
>>>>
>>>> I need no other networking settings. DHCP on my network handles the
>>>> rest. I have tried manually setting these two parameters in ifcfg-eth0 and
>>>> it looks like it works. (Although the new IP given via DHCP doesn't match
>>>> the original IP)
>>>>
>>>> Is this possible to do in ONE? If so, where do I start?
>>>>
>>>> Thanks!
>>>> Kerry
>>>>
>>>
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.opennebula.org
>>> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>>>
>>>
>>
>
> _______________________________________________
> Users mailing list
> Users at lists.opennebula.org
> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20140730/4c661ec9/attachment-0001.htm>


More information about the Users mailing list