Project

General

Profile

Actions

Feature #1361

closed

Allow subnet information to be accessed from provisioning templates & add gateway, dns to subnets

Added by Trey Dockendorf over 12 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
Normal
Category:
Unattended installations
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

I've attached a patch that does two things.

  1. Add 2 new fields to the Subnets form. Gateway and DNS
  2. Allow subnet items (gateway, dns, mask) to be used in provisioning templates.

This has been tested using Foreman-0.4.

I'm still very new to Ruby so these code changes may not adhere to coding best practices for Ruby.

The primary use case this was created for is to allow for a static IP to be assigned to a new host on install while booting it using DHCP.

An example of how to use

network --bootproto static --hostname <%= @host.name %> --ip=<%= @host.ip %> \
--netmask=<%= subnet[:mask] %> --gateway=<%= subnet[:gateway] %> --nameserver=<%= subnet[:dns] %>

Files


Related issues 3 (0 open3 closed)

Related to Foreman - Feature #1354: Add vlan id and default gateway to subnet configurationResolved11/24/2011Actions
Related to Foreman - Bug #1432: subnet gateway infos only saved when fill gateway and dns fieldsClosedFlorian Koch01/05/2012Actions
Has duplicate Foreman - Feature #1557: Add more information for static ip configurationDuplicate03/28/2012Actions
Actions #1

Updated by Ohad Levy over 12 years ago

  • Assignee changed from Ohad Levy to Trey Dockendorf
  • Target version set to 1.0

this patch would only work with one dns server, is that sufficient?

thanks

Actions #2

Updated by Markus Nussdorfer over 12 years ago

Ohad Levy wrote:

this patch would only work with one dns server, is that sufficient?

thanks

Up until RHEL 6.1 you can only define 1 primary nameserver
But according to the Installation Guide for 6 Beta there can be now two

--nameserver= — Primary nameserver, as an IP address. Multiple nameservers must each be separated by a comma.
Actions #3

Updated by Trey Dockendorf over 12 years ago

Updated the patch to add secondary DNS and fix a bug with the migrate file. Tested migration successfully

Example usage:

network --bootproto static --hostname <%= @host.name %> --ip=<%= @host.ip %> \
--netmask=<%= subnet[:mask] %> --gateway=<%= subnet[:gateway] %> \
--nameserver=<%= subnet[:dns_primary] %>,<%= subnet[:dns_secondary] %>

Attached is an updated patch file. Could someone remove the previous patch file as it won't work when using db:migrate.

Actions #4

Updated by Trey Dockendorf over 12 years ago

This looks related to Issue #1354.

Actions #5

Updated by Ohad Levy over 12 years ago

  • Status changed from New to Assigned

thanks for the patch, I'm willing to merge it, just one question, what is the usage of the subnet help?

you could simply do
@host.subnet.gateway in your templates?

Actions #6

Updated by Ohad Levy over 12 years ago

bump?

Actions #7

Updated by Trey Dockendorf over 12 years ago

Ohad Levy wrote:

thanks for the patch, I'm willing to merge it, just one question, what is the usage of the subnet help?

you could simply do
@host.subnet.gateway in your templates?

Sorry for the delay. The campus I support had a fiber outage so we've been busy moving servers all over the place.

Accessing subnet values with @host.subnet.gateway is much cleaner, and works. I think the use of the helper method was a lack of understanding on my part of how to use methods in Ruby Rails. You can ignore the changes to app/helpers/unattended_helper.rb. Though make sure to use the patch from my update, not the patches in the original post. It fixes mistakes I made with the DB migration.

Actions #8

Updated by Trey Dockendorf over 12 years ago

Correction, I can't use this is the PXELinux templates...

default linux
label linux
kernel <%= @kernel %>
append initrd=<%= @initrd %> ks=<%= foreman_url("provision")%> ksdevice=eth0 network kssendmac ip=<%= ip %> netmask=<%= subnet[:mask] %> gateway=<%= subnet[:gateway] %> dns=<%= subnet[:dns_primary] %>

I can however use the following

default linux
label linux
kernel <%= @kernel %>
append initrd=<%= @initrd %> ks=<%= foreman_url("provision")%> ksdevice=eth0 network kssendmac ip=<%= ip %> netmask=<%= @host.subnet.mask %> gateway=<%= @host.subnet.gateway %> dns=<%= @host.subnet.dns_primary %>

The error I get when using the first attempt is this (hostnames/ip changed)

Processing HostsController#update (for ...... at 2012-01-05 10:19:27) [PUT]
  Parameters: {"commit"=>"Submit", "action"=>"update", "_method"=>"put", "authenticity_token"=>"FV/8/chFOEddPnsMHlK7O3jxmASVvSfHXlp1BlGAPiY=", "id"=>"client.tamu.edu", "controller"=>"hosts", "host"=>{"architecture_id"=>"1", "subnet_id"=>"2", "puppetproxy_id"=>"1", "name"=>"client", "sp_mac"=>"", "sp_name"=>"", "managed"=>"1", "puppetmaster_name"=>"puppetca.tamu.edu", "root_pass"=>"[FILTERED]", "hostgroup_id"=>"1", "mac"=>"52:.....", "domain_id"=>"1", "enabled"=>"1", "medium_id"=>"6", "ptable_id"=>"9", "disk"=>"", "ip"=>"........", "puppetclass_ids"=>["", "6", "7", "29", "125", "180", "172", "89", "96"], "environment_id"=>"1", "comment"=>"", "sp_subnet_id"=>"", "sp_ip"=>"", "model_id"=>"5", "operatingsystem_id"=>"7"}}
Add the TFTP configuration for client.tamu.edu
Failed to generate PXELinux template: undefined method `subnet' for nil:NilClass
Fetching required TFTP boot files for client.tamu.edu
Rolling back due to a problem: 
Delete the TFTP configuration for client.tamu.edu
Failed to save: Failed to generate PXELinux template: undefined method `subnet' for nil:NilClass
Rendering template within layouts/application
Rendering hosts/edit
Completed in 1098ms (View: 969, DB: 189) | 200 OK [https://foreman.tamu.edu/hosts/client.tamu.edu]

I will get back in a day or two if I found out how to fix...I don't see how it works in Kickstart but not PXELinux as they are all "config_templates".

Actions #9

Updated by Ohad Levy over 12 years ago

tftp templates are kind of special, just drop the "@host." and it should work..

Actions #10

Updated by Trey Dockendorf over 12 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100
Actions #11

Updated by jaffa wify almost 12 years ago

The terminals were connected to the terminal hosts through serial interfaces and perhaps circuit switched networks, but not connected to any IP based network, and were not assigned IP addresses. Today's IP hosts may, however, lack ability to serve as terminal hosts. Thanks a lot.
Regards,
make my thesis

Actions #12

Updated by jaffa wify over 11 years ago

The academic field and the engineering practice of computer programming are both largely concerned with discovering and implementing the most efficient algorithms for a given class of problem. Thanks for sharing.
Regards,
architectural conservation

Actions #13

Updated by nitin khare over 11 years ago

From now on I will meet anyone like this unless I commend him to this blog! It is fantastic and I had never found so much useful information on one website. Congratulations. "Austin Home Builder
":http://www.joshwillishomes.com

Actions #14

Updated by nitin khare over 11 years ago

The site is favourable and precisely what he or she stated.Along with Marc Jacobs Bags the actual improvement involving e-business, buying Marc Jacobs Purses on the internet. "technical writing services
":http://www.technicalwritingservices.biz/

Actions #15

Updated by nitin khare over 11 years ago

mba application resume Excellent weblog, many thanks a lot for your awesome posts!

Actions

Also available in: Atom PDF