mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Provider options cpu and memory added. Those are used while creating
a new domain.
This commit is contained in:
35
README.md
35
README.md
@@ -33,8 +33,8 @@ $ vagrant plugin install vagrant-libvirt
|
||||
|
||||
### Possible problems with plugin installation
|
||||
|
||||
In case of problems with building nokogiri gem, install missing development
|
||||
libraries for libxslt, libxml2 and libvirt.
|
||||
In case of problems with building nokogiri and ruby-libvirt gem, install
|
||||
missing development libraries for libxslt, libxml2 and libvirt.
|
||||
|
||||
In Ubuntu, Debian, ...
|
||||
```
|
||||
@@ -77,7 +77,7 @@ end
|
||||
|
||||
```
|
||||
|
||||
### Configuration Options
|
||||
### Libvirt Configuration Options
|
||||
|
||||
This provider exposes quite a few provider-specific configuration options:
|
||||
|
||||
@@ -89,6 +89,28 @@ This provider exposes quite a few provider-specific configuration options:
|
||||
* `storage_pool_name` - Libvirt storage pool name, where box image and
|
||||
instance snapshots will be stored.
|
||||
|
||||
### Domain Specific Options
|
||||
|
||||
* `memory` - Amount of memory in MBytes. Defaults to 512 if not set.
|
||||
* `cpus` - Number of virtual cpus. Defaults to 1 if not set.
|
||||
|
||||
Specific domain settings can be set for each domain separately in multi-VM
|
||||
environment. Example below shows a part of Vagrantfile, where specific options
|
||||
are set for dbserver domain.
|
||||
|
||||
```ruby
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.define :dbserver do |dbserver|
|
||||
dbserver.vm.box = "centos64"
|
||||
dbserver.vm.provider :libvirt do |domain|
|
||||
domain.memory = 2048
|
||||
domain.cpus = 2
|
||||
end
|
||||
end
|
||||
|
||||
...
|
||||
```
|
||||
|
||||
## Create Project - Vagrant up
|
||||
|
||||
In prepared project directory, run following command:
|
||||
@@ -111,10 +133,9 @@ Vagrant goes through steps below when creating new project:
|
||||
remote Libvirt storage pool as new volume.
|
||||
3. Create COW diff image of base box image for new Libvirt domain.
|
||||
4. Create and start new domain on Libvirt host.
|
||||
5. Check for DHCP lease from dnsmasq server. Store IP address into
|
||||
machines *data_dir* for later use, when lease information is not
|
||||
available. Then wait till SSH is available.
|
||||
6. Sync folders via `rsync` and run Vagrant provisioner on new domain if
|
||||
5. Check for DHCP lease from dnsmasq server.
|
||||
6. Wait till SSH is available.
|
||||
7. Sync folders via `rsync` and run Vagrant provisioner on new domain if
|
||||
setup in Vagrantfile.
|
||||
|
||||
## Networks
|
||||
|
||||
@@ -13,11 +13,13 @@ module VagrantPlugins
|
||||
end
|
||||
|
||||
def call(env)
|
||||
# Get config.
|
||||
config = env[:machine].provider_config
|
||||
|
||||
# Gather some info about domain
|
||||
# TODO from Vagrantfile
|
||||
@name = env[:domain_name]
|
||||
@cpus = 1
|
||||
@memory_size = 512*1024
|
||||
@cpus = config.cpus
|
||||
@memory_size = config.memory*1024
|
||||
|
||||
# TODO get type from driver config option
|
||||
@domain_type = 'kvm'
|
||||
|
||||
@@ -22,6 +22,10 @@ module VagrantPlugins
|
||||
# be stored.
|
||||
attr_accessor :storage_pool_name
|
||||
|
||||
# Domain specific settings used while creating new domain.
|
||||
attr_accessor :memory
|
||||
attr_accessor :cpus
|
||||
|
||||
def initialize
|
||||
@driver = UNSET_VALUE
|
||||
@host = UNSET_VALUE
|
||||
@@ -29,15 +33,23 @@ module VagrantPlugins
|
||||
@username = UNSET_VALUE
|
||||
@password = UNSET_VALUE
|
||||
@storage_pool_name = UNSET_VALUE
|
||||
|
||||
# Domain specific settings.
|
||||
@memory = UNSET_VALUE
|
||||
@cpus = UNSET_VALUE
|
||||
end
|
||||
|
||||
def finalize!
|
||||
@driver = 'qemu' if @driver == UNSET_VALUE
|
||||
@host = nil if @host == UNSET_VALUE
|
||||
@driver = 'qemu' if @driver == UNSET_VALUE
|
||||
@host = nil if @host == UNSET_VALUE
|
||||
@connect_via_ssh = false if @connect_via_ssh == UNSET_VALUE
|
||||
@username = nil if @username == UNSET_VALUE
|
||||
@password = nil if @password == UNSET_VALUE
|
||||
@storage_pool_name = 'default' if @storage_pool_name == UNSET_VALUE
|
||||
|
||||
# Domain specific settings.
|
||||
@memory = 512 if @memory == UNSET_VALUE
|
||||
@cpus = 1 if @cpus == UNSET_VALUE
|
||||
end
|
||||
|
||||
def validate(machine)
|
||||
|
||||
Reference in New Issue
Block a user