Skip to content

Commit

Permalink
Merge pull request #647 from stephenfin/feat/cleanup
Browse files Browse the repository at this point in the history
Cleanup some files
  • Loading branch information
infernix committed Sep 7, 2016
2 parents 945e84f + 46cc251 commit 802e666
Show file tree
Hide file tree
Showing 8 changed files with 484 additions and 305 deletions.
715 changes: 447 additions & 268 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/vagrant-libvirt/action/create_domain.rb
Expand Up @@ -12,7 +12,7 @@ def initialize(app, _env)
end

def _disk_name(name, disk)
"#{name}-#{disk[:device]}.#{disk[:type]}" # disk name
"#{name}-#{disk[:device]}.#{disk[:type]}" # disk name
end

def _disks_print(disks)
Expand Down
6 changes: 3 additions & 3 deletions lib/vagrant-libvirt/action/create_network_interfaces.rb
Expand Up @@ -17,8 +17,8 @@ class CreateNetworkInterfaces
def initialize(app, env)
@logger = Log4r::Logger.new('vagrant_libvirt::action::create_network_interfaces')
@management_network_name = env[:machine].provider_config.management_network_name
config = env[:machine].provider_config
@nic_model_type = config.nic_model_type
config = env[:machine].provider_config
@nic_model_type = config.nic_model_type
@nic_adapter_count = config.nic_adapter_count
@app = app
end
Expand Down Expand Up @@ -69,7 +69,7 @@ def call(env)
@network_name = iface_configuration[:network_name]
@mac = iface_configuration.fetch(:mac, false)
@model_type = iface_configuration.fetch(:model_type, @nic_model_type)
@device_name = iface_configuration.fetch(:iface_name, false)
@device_name = iface_configuration.fetch(:iface_name, false)
template_name = 'interface'
# Configuration for public interfaces which use the macvtap driver
if iface_configuration[:iface_type] == :public_network
Expand Down
4 changes: 2 additions & 2 deletions lib/vagrant-libvirt/action/forward_ports.rb
Expand Up @@ -111,7 +111,7 @@ def redirect_port(machine, host_ip, host_port, guest_ip, guest_port,
@env[:ui].info 'Requesting sudo for host port(s) <= 1024'
r = system('sudo -v')
if r
ssh_cmd << 'sudo ' # add sudo prefix
ssh_cmd << 'sudo ' # add sudo prefix
end
end
end
Expand Down Expand Up @@ -175,7 +175,7 @@ def call(env)
kill_cmd = ''

if tag[:port] <= 1024
kill_cmd << 'sudo ' # add sudo prefix
kill_cmd << 'sudo ' # add sudo prefix
end

kill_cmd << "kill #{tag[:pid]}"
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-libvirt/action/prepare_nfs_settings.rb
Expand Up @@ -39,7 +39,7 @@ def using_nfs?
#
# @param [Machine] machine
# @return [String]
def read_host_ip(ip)
def read_host_ip(ip)
UDPSocket.open do |s|
if(ip.kind_of?(Array))
s.connect(ip.last, 1)
Expand Down
16 changes: 8 additions & 8 deletions lib/vagrant-libvirt/config.rb
Expand Up @@ -173,10 +173,10 @@ def initialize
@nic_adapter_count = UNSET_VALUE

# Boot order
@boot_order = []
@boot_order = []
# Storage
@disks = []
@cdroms = []
@cdroms = []

# Inputs
@inputs = UNSET_VALUE
Expand All @@ -198,15 +198,15 @@ def initialize
end

def boot(device)
@boot_order << device # append
@boot_order << device # append
end

def _get_device(disks)
# skip existing devices and also the first one (vda)
exist = disks.collect {|x| x[:device]}+[1.vdev.to_s]
skip = 1 # we're 1 based, not 0 based...
skip = 1 # we're 1 based, not 0 based...
while true do
dev = skip.vdev # get lettered device
dev = skip.vdev # get lettered device
if !exist.include?(dev)
return dev
end
Expand Down Expand Up @@ -363,7 +363,7 @@ def _handle_disk_storage(options={})
options = {
:device => _get_device(@disks),
:type => 'qcow2',
:size => '10G', # matches the fog default
:size => '10G', # matches the fog default
:path => nil,
:bus => 'virtio'
}.merge(options)
Expand All @@ -378,7 +378,7 @@ def _handle_disk_storage(options={})
:allow_existing => options[:allow_existing],
}

@disks << disk # append
@disks << disk # append
end

# code to generate URI from a config moved out of the connect action
Expand All @@ -397,7 +397,7 @@ def _generate_uri
raise "Require specify driver #{uri}"
end
if uri == 'kvm'
uri = 'qemu' # use qemu uri for kvm domain type
uri = 'qemu' # use qemu uri for kvm domain type
end

if @connect_via_ssh
Expand Down
16 changes: 8 additions & 8 deletions lib/vagrant-libvirt/templates/interface.xml.erb
@@ -1,13 +1,13 @@
<interface type='network'>
<source network='<%= @network_name %>'/>
<% if @mac %>
<mac address='<%= @mac %>'/>
<% end %>
<% if @device_name %>
<target dev='<%= @device_name %>'/>
<% else %>
<target dev='vnet<%= @iface_number %>'/>
<% end %>
<% if @mac %>
<mac address='<%= @mac %>'/>
<% end %>
<% if @device_name %>
<target dev='<%= @device_name %>'/>
<% else %>
<target dev='vnet<%= @iface_number %>'/>
<% end %>
<alias name='net<%= @iface_number %>'/>
<model type='<%=@model_type%>'/>
</interface>
Expand Down
28 changes: 14 additions & 14 deletions tools/prepare_redhat_for_box.sh
Expand Up @@ -12,39 +12,39 @@

# We need to set a hostname.
if [ $# -ne 1 ]; then
echo "Usage: $0 <hostname>"
echo "Hostname should be in format vagrant-[os-name], e.g. vagrant-redhat63."
exit 1
echo "Usage: $0 <hostname>"
echo "Hostname should be in format vagrant-[os-name], e.g. vagrant-redhat63."
exit 1
fi


# On which version of RedHet are we running?
RHEL_MAJOR_VERSION=$(sed 's/.*release \([0-9]\)\..*/\1/' /etc/redhat-release)
if [ $? -ne 0 ]; then
echo "Is this a RedHat distro?"
exit 1
echo "Is this a RedHat distro?"
exit 1
fi
echo "* Found RedHat ${RHEL_MAJOR_VERSION} version."


# Setup hostname vagrant-something.
FQDN="$1.vagrantup.com"
if grep '^HOSTNAME=' /etc/sysconfig/network > /dev/null; then
sed -i 's/HOSTNAME=\(.*\)/HOSTNAME='${FQDN}'/' /etc/sysconfig/network
sed -i 's/HOSTNAME=\(.*\)/HOSTNAME='${FQDN}'/' /etc/sysconfig/network
else
echo "HOSTNAME=${FQDN}" >> /etc/sysconfig/network
echo "HOSTNAME=${FQDN}" >> /etc/sysconfig/network
fi


# Enable EPEL repository.
yum -y install wget
cd ~root
if [ $RHEL_MAJOR_VERSION -eq 5 ]; then
wget http://ftp.astral.ro/mirrors/fedora/pub/epel/5/i386/epel-release-5-4.noarch.rpm
EPEL_PKG="epel-release-5-4.noarch.rpm"
wget http://ftp.astral.ro/mirrors/fedora/pub/epel/5/i386/epel-release-5-4.noarch.rpm
EPEL_PKG="epel-release-5-4.noarch.rpm"
else
wget http://ftp.astral.ro/mirrors/fedora/pub/epel/6/i386/epel-release-6-8.noarch.rpm
EPEL_PKG="epel-release-6-8.noarch.rpm"
wget http://ftp.astral.ro/mirrors/fedora/pub/epel/6/i386/epel-release-6-8.noarch.rpm
EPEL_PKG="epel-release-6-8.noarch.rpm"
fi
rpm -i ~root/${EPEL_PKG}
rm -f ~root/${EPEL_PKG}
Expand All @@ -60,9 +60,9 @@ chkconfig sshd on
echo 'vagrant' | passwd --stdin root
grep 'vagrant' /etc/passwd > /dev/null
if [ $? -ne 0 ]; then
echo '* Creating user vagrant.'
useradd vagrant
echo 'vagrant' | passwd --stdin vagrant
echo '* Creating user vagrant.'
useradd vagrant
echo 'vagrant' | passwd --stdin vagrant
fi
grep '^admin:' /etc/group > /dev/null || groupadd admin
usermod -G admin vagrant
Expand Down

0 comments on commit 802e666

Please sign in to comment.