Skip to content
This repository has been archived by the owner on Oct 21, 2021. It is now read-only.

Commit

Permalink
Updated to use config.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
proffalken committed Apr 27, 2011
1 parent 3eb2e27 commit 86e6de1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 28 deletions.
8 changes: 8 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cobbler:
server: localhost
port: 80
libvirt:
driver: qemu # can be any of the libvirt drivers documented at libvirt.org
host: # the host to connect to (leave blank for localhost)
type: system # can be "system" or "user"
storage_pool: default
59 changes: 31 additions & 28 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,49 @@
require 'ping'
require 'socket'
require 'timeout'
require 'yaml'

# setup the globals
Before do
#cobbler server:
@cobbler_server = "localhost"
@cobbler_port = "80"
# load in the YAML config
config_file = YAML::load(File.open('config.yml'))
#cobbler server:
@cobbler_server = config_file['cobbler']['server']
@cobbler_port = config_file['cobbler']['port']

#Libvirt
@libvirt_driver = "qemu" # can be any of qemu, vbox, xen, openvz, one, esx, gsx as detailed on the libvirt wiki
@libvirt_host = ""
@libvirt_type = "system"
@libvirt_storage_pool = "default"
#Libvirt
@libvirt_driver = config_file['libvirt']['driver']
@libvirt_host = config_file['libvirt']['host']
@libvirt_type = config_file['libvirt']['type']
@libvirt_storage_pool = config_file['libvirt']['storage_pool']


## VM Connection
@vmconn = Libvirt::open("#{@libvirt_driver}://#{@libvirt_host}/#{@libvirt_type}")
### VM Storage
@vm_stor = @vmconn.lookup_storage_pool_by_name(@libvirt_storage_pool)
## VM Connection
@vmconn = Libvirt::open("#{@libvirt_driver}://#{@libvirt_host}/#{@libvirt_type}")
### VM Storage
@vm_stor = @vmconn.lookup_storage_pool_by_name(@libvirt_storage_pool)


## Cobbler API
@cblr_api = XMLRPC::Client.new(@cobbler_server,"/cobbler_api",@cobbler_port)
## Cobbler API
@cblr_api = XMLRPC::Client.new(@cobbler_server,"/cobbler_api",@cobbler_port)

### define the port-checker code
def is_port_open(ip, port)
begin
Timeout::timeout(1) do
### define the port-checker code
def is_port_open(ip, port)
begin
s = TCPSocket.new(ip, port)
s.close
return true
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
return false
Timeout::timeout(1) do
begin
s = TCPSocket.new(ip, port)
s.close
return true
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
return false
end
end
rescue Timeout::Error
end
end
rescue Timeout::Error
end

return false
end
return false
end


end

0 comments on commit 86e6de1

Please sign in to comment.