-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support KVM or LXC containers instead of / in addition to OpenVZ ? #25
Comments
I was wondering the same! |
Any updates on this, facing the same problem. I´ll try changing proxmox.vm_type = :openvz to proxmox.vm_type = :lxc. Maybe that works. |
sorry to pile-on, I want Proxmox 4 kvm and lxc too let us know if there are areas needing patches etc |
Hi, action.rb file elsif env1[:machine].provider_config.vm_type == :lxc
b1.use Call, UploadTemplateFile do |env2, b2|
if env2[:result] == :ok
b2.use CreateVm
b2.use StartVm
b2.use SyncFolders
elsif env2[:result] == :file_not_found
b2.use MessageFileNotFound
elsif env2[:result] == :server_upload_error
b2.use MessageUploadServerError
end
end /action/create_vm.rb file module VagrantPlugins
module Proxmox
module Action
# This action creates a new virtual machine on the Proxmox server and
# stores its node and vm_id env[:machine].id
class CreateVm < ProxmoxAction
def initialize app, env
@app = app
@logger = Log4r::Logger.new 'vagrant_proxmox::action::create_vm'
end
def call env
env[:ui].info I18n.t('vagrant_proxmox.creating_vm')
config = env[:machine].provider_config
node = env[:proxmox_selected_node]
vm_id = nil
begin
vm_id = connection(env).get_free_vm_id
params = create_params_openvz(config, env, vm_id) if config.vm_type == :openvz
params = create_params_lxc(config, env, vm_id) if config.vm_type == :lxc
params = create_params_qemu(config, env, vm_id) if config.vm_type == :qemu
exit_status = connection(env).create_vm node: node, vm_type: config.vm_type, params: params
exit_status == 'OK' ? exit_status : raise(VagrantPlugins::Proxmox::Errors::ProxmoxTaskFailed, proxmox_exit_status: exit_status)
rescue StandardError => e
raise VagrantPlugins::Proxmox::Errors::VMCreateError, proxmox_exit_status: e.message
end
env[:machine].id = "#{node}/#{vm_id}"
env[:ui].info I18n.t('vagrant_proxmox.done')
next_action env
end
private
def create_params_qemu(config, env, vm_id)
network = "#{config.qemu_nic_model},bridge=#{config.qemu_bridge}"
network = "#{config.qemu_nic_model}=#{get_machine_macaddress(env)},bridge=#{config.qemu_bridge}" if get_machine_macaddress(env)
{vmid: vm_id,
name: env[:machine].config.vm.hostname || env[:machine].name.to_s,
ostype: config.qemu_os,
ide2: "#{config.qemu_iso},media=cdrom",
sata0: "#{config.qemu_storage}:#{config.qemu_disk_size},format=qcow2",
sockets: config.qemu_sockets,
cores: config.qemu_cores,
memory: config.vm_memory,
net0: network,
description: "#{config.vm_name_prefix}#{env[:machine].name}"}
end
private
def create_params_openvz(config, env, vm_id)
{vmid: vm_id,
ostemplate: config.openvz_os_template,
hostname: env[:machine].config.vm.hostname || env[:machine].name.to_s,
password: 'vagrant',
memory: config.vm_memory,
description: "#{config.vm_name_prefix}#{env[:machine].name}"}
.tap do |params|
params[:ip_address] = get_machine_ip_address(env) if get_machine_ip_address(env)
end
end
def create_params_lxc(config, env, vm_id)
{vmid: vm_id,
ostemplate: config.openvz_os_template,
hostname: env[:machine].config.vm.hostname || env[:machine].name.to_s,
password: 'vagrant',
memory: config.vm_memory,
description: "#{config.vm_name_prefix}#{env[:machine].name}"}
.tap do |params|
params[:net0] = "name=eth0,ip=#{get_machine_ip_address(env)}/24,gw=10.150.170.1,bridge=vmbr0" if get_machine_ip_address(env)
end
end
end
end
end
end This is my setup just change the line with "params[:net0]" at the end to match your needs, |
thanks @antoiner77 |
Thanks! |
Hi Bye |
Fixed in PR #26? |
Has this change been committed to master yet? |
It was merged into master on 22 Mar 2016. |
Appearently, the support for OpenVZ will be removed in the next version of Proxmox (which is version 4).
Are there any plans to support other containers like KVM or LXC?
The text was updated successfully, but these errors were encountered: