Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
apevec committed Apr 7, 2009
2 parents 718f258 + 9a83d3c commit 02b61a8
Show file tree
Hide file tree
Showing 20 changed files with 302 additions and 130 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_INIT([ovirt-server], [0.97], [[email protected]])
AC_INIT([ovirt-server], [0.98], [[email protected]])
AM_INIT_AUTOMAKE([-Wall -Werror foreign -Wno-portability tar-pax])
AC_PROG_CC
AC_CONFIG_HEADERS([config.h])
Expand Down
67 changes: 51 additions & 16 deletions installer/bin/ovirt-installer
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,28 @@ def prompt_for_answer(prompt, options={})
return answer
end

# prompt a user for a password, with confirmation
def prompt_for_password(prompt, confirm)
loop do
pass = prompt_for_answer(prompt, :password => true)
conf = prompt_for_answer(confirm, :password => true)
if pass == conf
return pass
end
@cli.say("Passwords do not match!")
end
end

def prompt_for_interface(prompt, interfaces, options={})
loop do
nic = prompt_for_answer(prompt,options)
if interfaces.has_key?(nic)
return nic
end
@cli.say("Please pick an active device from the list")
end
end

# Allow a user to enter a Yes/No
# And repeat the prompt until they do
def prompt_yes_no(prompt, options={})
Expand Down Expand Up @@ -84,6 +106,20 @@ welcome = "This installer will configure the ovirt installation based on a seri
of questions. When complete, you will be asked to install oVirt or\n\
do the installation manually. Would you like to continue?"

# verify hostname is not on the loopback line in /etc/hosts to prevent kerberos problems
hostname = `hostname`
hostsfile = File.new("/etc/hosts", "r")
while (line = hostsfile.gets)
if line =~ /127.0.0.1/ && line.include?(hostname.chomp)
if hostname !~ /localhost.localdomain/
@cli.say("\nHostname must not be on the loopback 127.0.0.1 line in /etc/hosts")
@cli.say("#{line}")
exit(0)
end
end
end
hostsfile.close

if (prompt_yes_no(welcome, :default => "y") == "n")
exit(0)
end
Expand Down Expand Up @@ -115,20 +151,23 @@ if dev_ct == 0
exit
else
puts ""
@cli.say("Below are the detected networking devices\n\n")
@cli.say("Below are the active networking devices, if there are any missing devices\n\n")
@cli.say("ensure they are active and have an ip address before running the installer")
@cli.say("mac address interface ip address")
interfaces = {}
net_devs.each_line do |dev|
dev = dev.chomp
interface = `hal-get-property --udi #{dev} --key net.interface`
mac = `hal-get-property --udi #{dev} --key net.address`
ip = `ifconfig #{interface}`
ipaddr = ip.scan(/\s*inet addr:([\d.]+)/)
puts (mac.chop + " : " + interface.chop + " : " + ipaddr.to_s) if interface.chop != "lo"
interfaces[interface.chop] = ipaddr.to_s if interface.chop != "lo"
puts (mac.chop + " : " + interface.chop + " : " + ipaddr.to_s) if interface.chop != "lo" and ipaddr.to_s != ""
end
end

guest_httpd_dev = prompt_for_answer("Enter the interface for the Guest network:", :default => "eth0")
admin_dev = prompt_for_answer("Enter the interface for the Admin network (this may be the same as the Guest network interface):", :default => "eth0")
guest_httpd_dev = prompt_for_interface("Enter the interface for the Guest network:", interfaces, :default => "eth0")
admin_dev = prompt_for_interface("Enter the interface for the Admin network (this may be the same as the Guest network interface):", interfaces, :default => "eth0")

#FIXME: correctly configure separate networks.
#For now, define admin and guest networks to be the same
Expand All @@ -146,12 +185,9 @@ File.open('/etc/resolv.conf').each_line{ |line|
}
dns_servers = prompt_yes_no("Use this systems's dns servers?")

guest_httpd_ip = `ifconfig #{guest_httpd_dev}`
guest_httpd_ipaddr = guest_httpd_ip.scan(/\s*inet addr:([\d.]+)/)
guest_ip = `ifconfig #{guest_dev}`
guest_ipaddr = guest_ip.scan(/\s*inet addr:([\d.]+)/)
admin_ip = `ifconfig #{admin_dev}`
admin_ipaddr = admin_ip.scan(/\s*inet addr:([\d.]+)/)
guest_httpd_ipaddr = interfaces[guest_httpd_dev]
guest_ipaddr = interfaces[guest_dev]
admin_ipaddr = interfaces[admin_dev]

if dns_servers == "y"
guest_ipaddr_lookup = Socket.getaddrinfo(guest_ipaddr.to_s,nil)
Expand Down Expand Up @@ -179,7 +215,7 @@ if dhcp_setup == "n"
dhcp_start = prompt_for_answer("Enter the dhcp pool start address (example: 3):", :regex => OCTET)
dhcp_stop = prompt_for_answer("Enter the dhcp pool end addess (example: 100):", :regex => OCTET)
dhcp_domain = prompt_for_answer("Enter the dhcp domain you wish to use (example: example.com):", :default => dnsdomainname.chomp, :regex => IP_OR_FQDN)
admin_dns_server = admin_ip.scan(/\s*inet addr:([\d.]+)/)
admin_dns_server = interfaces[admin_dev]
admin_network_gateway = prompt_for_answer("Enter the network gateway for your Admin network (example: 192.168.50.254):", :default => default_gw.chomp, :regex => IP_OR_FQDN)
tftp_setup = prompt_yes_no("Provide pxe/tftp capability?")
end
Expand All @@ -195,17 +231,16 @@ elsif cobbler_setup == "n"
end

cobbler_user_name= prompt_for_answer("Enter your cobbler username:")
cobbler_user_password = prompt_for_answer("Enter your cobbler user password:", :password => true)
cobbler_user_password = prompt_for_password("Enter your cobbler user password:", "Confirm your cobbler user password:")

# Postgres Configuration
db_username = "ovirt"
db_password = prompt_for_answer("Enter a password for the ovirt postgres account:", :password => true)

db_password = prompt_for_password("Enter a password for the ovirt postgres account:", "Confirm your ovirt postgres password")
# FreeIPA Configuration
realm_name = prompt_for_answer("Enter your realm name (example: example.com):", :regex => FQDN)

freeipa_password = prompt_for_answer("NOTE: The following pasword will also be your ovirtadmin password for the web management login\n\
Enter an administrator password for FreeIPA:", :password => true)
@cli.say("NOTE: The following password will also be your ovirtadmin password for the web management login")
freeipa_password = prompt_for_password("Enter an administrator password for FreeIPA:", "Confirm your FreeIPA admin password:")
ldap_dn = ""
ldap_dn_temp = realm_name.split(".")
ldap_dn_temp.each do |i|
Expand Down
3 changes: 3 additions & 0 deletions ovirt-server.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,13 @@ touch %{buildroot}%{_localstatedir}/log/%{name}/db-omatic.log
# move configs to /etc, keeping symlinks for Rails
%{__mv} %{buildroot}%{app_root}/config/database.yml %{buildroot}%{_sysconfdir}/%{name}
%{__mv} %{buildroot}%{app_root}/config/ldap.yml %{buildroot}%{_sysconfdir}/%{name}
%{__mv} %{buildroot}%{app_root}/config/cobbler.yml %{buildroot}%{_sysconfdir}/%{name}
%{__mv} %{buildroot}%{app_root}/config/environments/development.rb %{buildroot}%{_sysconfdir}/%{name}
%{__mv} %{buildroot}%{app_root}/config/environments/production.rb %{buildroot}%{_sysconfdir}/%{name}
%{__mv} %{buildroot}%{app_root}/config/environments/test.rb %{buildroot}%{_sysconfdir}/%{name}
%{__ln_s} %{_sysconfdir}/%{name}/database.yml %{buildroot}%{app_root}/config
%{__ln_s} %{_sysconfdir}/%{name}/ldap.yml %{buildroot}%{app_root}/config
%{__ln_s} %{_sysconfdir}/%{name}/cobbler.yml %{buildroot}%{app_root}/config
%{__ln_s} %{_sysconfdir}/%{name}/development.rb %{buildroot}%{app_root}/config/environments
%{__ln_s} %{_sysconfdir}/%{name}/production.rb %{buildroot}%{app_root}/config/environments
%{__ln_s} %{_sysconfdir}/%{name}/test.rb %{buildroot}%{app_root}/config/environments
Expand Down Expand Up @@ -215,6 +217,7 @@ fi
%dir %{_sysconfdir}/%{name}/db
%config(noreplace) %{_sysconfdir}/%{name}/database.yml
%config(noreplace) %{_sysconfdir}/%{name}/ldap.yml
%config(noreplace) %{_sysconfdir}/%{name}/cobbler.yml
%config(noreplace) %{_sysconfdir}/%{name}/development.rb
%config(noreplace) %{_sysconfdir}/%{name}/production.rb
%config(noreplace) %{_sysconfdir}/%{name}/test.rb
Expand Down
6 changes: 3 additions & 3 deletions src/app/controllers/managed_node_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def error
def load_host
@host = Host.find_by_hostname(params[:host])

render :nothing => true, :status => :error unless @host
render :nothing => true unless @host
end

def load_macs
Expand All @@ -54,10 +54,10 @@ def load_macs
if mac_text != nil
mac_text.scan(/([^,]+)\,?/).each do |line|
key, value = line.first.split("=")
@macs[key] = value
@macs[key.upcase] = value
end
end

render :nothing => true, :status => :error if @macs.empty?
render :nothing => true if @macs.empty?
end
end
40 changes: 40 additions & 0 deletions src/app/models/bonding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,46 @@ class Bonding < ActiveRecord::Base
:greater_than_or_equal_to => 0,
:unless => Proc.new { |bonding| bonding.arp_interval.nil? }

# Returns whether networking is defined for this interface.
def networking?
# there is network if there's a vlan defined.
(vlan.nil? == false)
end

# Returns the boot protocol for the interface, or +nil+ if networking
# is not defined.
def boot_protocol
return vlan.boot_type.proto if networking?
return nil
end

# Returns the ip address assigned to this bonded interface, or +nil+
# if no networking is defined.
def ip_address
return ip_addresses.first.address if networking? && !ip_addresses.empty?
return nil
end

# Returns the netmask assigned to this bonded interface, or +nil+
# if no networking is defined.
def netmask
return vlan.ip_addresses.first.netmask if networking? && !vlan.ip_addresses.empty?
return nil
end

# Returns the broadcast address assigned to this bonded interface,
# or +nil if no networking is defined.
def broadcast
return vlan.ip_addresses.first.broadcast if networking? && !vlan.ip_addresses.empty?
return nil
end

# Returns the gateway address for the bonded interface if networking is defined.
def gateway
return vlan.ip_addresses.first.gateway if networking? && !vlan.ip_addresses.empty?
return nil
end

protected
def validate
if ! vlan.nil? and
Expand Down
39 changes: 39 additions & 0 deletions src/app/models/nic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,45 @@ class Nic < ActiveRecord::Base
:scope => :host_id,
:unless => Proc.new { |nic| nic.physical_network_id.nil? }

# Returns whether the nic has networking defined.
def networking?
(physical_network != nil)
end

# Returns the boot protocol for the nic if networking is defined.
def boot_protocol
return physical_network.boot_type.proto if networking?
end

# Returns whether the nic is enslaved by a bonded interface.
def bonded?
!bondings.empty?
end

# Returns the ip address for the nic if networking is defined.
def ip_address
return ip_addresses.first.address if networking? && !ip_addresses.empty?
return nil
end

# Returns the netmask for the nic if networking is defined.
def netmask
return physical_network.ip_addresses.first.netmask if networking? && !physical_network.ip_addresses.empty?
return nil
end

# Returns the broadcast address for the nic if networking is defined.
def broadcast
return physical_network.ip_addresses.first.broadcast if networking? && !physical_network.ip_addresses.empty?
return nil
end

# Returns the gateway address fo rthe nic if networking is defined.
def gateway
return physical_network.ip_addresses.first.gateway if networking? && !physical_network.ip_addresses.empty?
return nil
end

# validate 'bridge' or 'usage_type' attribute ?

protected
Expand Down
3 changes: 2 additions & 1 deletion src/app/views/layouts/_tree.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
$.ajax({
url: this.href,
dataType: 'html',
data: {ajax:true},
success: handleTabsAndContent,
error: function(xhr) {$.jGrowl(xhr.status + ' ' + xhr.statusText);}
});
Expand Down Expand Up @@ -100,7 +101,7 @@
<!-- Output elements -->
<% selected = "current" if controller.controller_name == "dashboard" && params[:action] == "index" %>
<div class="nav-dashboard <%= selected %>">
<%= link_to "Dashboard", dashboard_url, { :id => "dashboard"} %>
<%= link_to "Dashboard", {:controller => "dashboard"} %>
</div>
<% network_selected = "current" if controller.controller_name == "network" %>

Expand Down
1 change: 0 additions & 1 deletion src/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
# You can have the root of your site routed by hooking up ''
# -- just remember to delete public/index.html.
map.default '', :controller => 'dashboard'
map.dashboard '/dashboard?ajax=true', :controller => 'dashboard'

map.login '/login', :controller => 'resources', :action => 'list'
map.logout '/logout', :controller => 'resources', :action => 'list'
Expand Down
20 changes: 19 additions & 1 deletion src/db-omatic/db_omatic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,26 @@ def update_domain_state(domain, state_override = nil)
end

@logger.info "Updating VM #{domain['name']} to state #{state}"

if state == Vm::STATE_STOPPED
@logger.info "VM has moved to stopped, clearing VM attributes."
qmf_vm = @session.object(:class => "domain", 'uuid' => vm.uuid)
if qmf_vm
@logger.info "Deleting VM #{vm.description}."
result = qmf_vm.undefine
if result.status == 0
@logger.info "Delete of VM #{vm.description} successful, syncing DB."
vm.host_id = nil
vm.memory_used = nil
vm.num_vcpus_used = nil
vm.state = Vm::STATE_STOPPED
vm.needs_restart = nil
vm.vnc_port = nil
end
end
end
vm.state = state
vm.save
vm.save!

domain[:synced] = true
end
Expand Down
36 changes: 18 additions & 18 deletions src/host-browser/host-browser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def write_host_info(host_info)
Cpu.delete_all(['host_id = ?', host.id])

puts "Saving new CPU records"
cpu_info.collect do |cpu|
cpu_info.each do |cpu|
detail = Cpu.new(
"cpu_number" => cpu['CPUNUM'].to_i,
"core_number" => cpu['CORENUM]'].to_i,
Expand All @@ -271,37 +271,37 @@ def write_host_info(host_info)

puts "Updating NIC records for the node"
nics = Array.new
nics_to_delete = Array.new

host.nics.collect do |nic|
host.nics.each do |nic|
found = false

nic_info.collect do |detail|
nic_info.each do |detail|
# if we have a match, then update the database and remove
# the received data to avoid creating a dupe later
if detail['MAC'] == nic.mac
nic_info.delete(detail)

updated_nic = Nic.find_by_id(nic.id)

updated_nic.bandwidth = detail['BANDWIDTH'].to_i
updated_nic.interface_name = detail['IFACE_NAME']

updated_nic.save!
found=true
nic_info.delete detail
puts "Searching for existing record for: #{detail['MAC'].upcase}"
if detail['MAC'].upcase == nic.mac
puts "Updating details for: #{detail['IFACE_NAME']} [#{nic.mac}]}"
nic.bandwidth = detail['BANDWIDTH'].to_i
nic.interface_name = detail['IFACE_NAME']
nic.save!
found = true
nic_info.delete(detail)
end
end

# if the record wasn't found, then remove it from the database
unless found
host.nics.delete(nic)
nic.destroy
puts "Marking NIC for removal: #{nic.interface_name} [#{nic.mac}]"
nics_to_delete << nic
end
end

nics_to_delete.each { |nic| puts "Removing NIC: #{nic.interface_name} []#{nic.mac}]"; host.nics.delete(nic) }

# iterate over any nics left and create new records for them.
nic_info.collect do |nic|
puts "Creating a new nic..."
nic_info.each do |nic|
puts "Creating a new nic: #{nic['IFACE_NAME']} [#{nic['MAC']}]"
detail = Nic.new(
'mac' => nic['MAC'].upcase,
'bandwidth' => nic['BANDWIDTH'].to_i,
Expand Down
Loading

0 comments on commit 02b61a8

Please sign in to comment.