ruby - 工头 - 从 vmware 模板克隆

标签 ruby vmware virtualization theforeman

我能够让工头运行,并且能够将 VM 自动部署到我的 vcenter,然后使用 puppet 配置它们。

无论如何,我得到了从模板克隆 VM 的要求。我遇到了以下似乎尚未实现的功能请求:http://projects.theforeman.org/issues/2438

我对 webgui 和整个实现非常满意 - 所以我很想获得解决此问题的提示 - 也许在某处调用脚本进行克隆而不是再次部署? 是否有可能在工头中自定义构建过程来完成这项工作? 或者可能已经有一个脚本可以部署到某处?

如果那根本不可能 - 您是否可以推荐其他工具?

非常感谢您的帮助!

最佳答案

那个feature request在foreman 1.5中已经实现了一半。您可以从另一个虚拟机克隆,但不能从模板克隆。

链接的问题添加了一个脚本,用于从模板克隆:

#!/usr/bin/ruby
require 'rubygems'
require 'fog'
require 'pp'

credentials = {
    :provider         => "vsphere",
    :vsphere_username => "myadminuser",
    :vsphere_password => "*********",
    :vsphere_server   => "vcenter.example.com",
    :vsphere_ssl      => true,
    :vsphere_expected_pubkey_hash => "89d0foof6e6aef34e1ed20ae04dffad48085355e6bfoo792e9435b5a4f1b3e9" 
}

connection = Fog::Compute.new(credentials)
puts "Connected to #{connection.vsphere_server} as #{connection.vsphere_username} (API version #{connection.vsphere_rev})" 

options = {
    'datacenter'    => 'Baltimore',
    'template_path' => '/centos_6_4',
    'power_on'      => true,
    'memoryMB'      => '1024',
    'network_label' => '172.18.2.x',
    'numCPUs'       => 2,
    'datastore'     => 'VM NFS Mount',
    'wait'          => true,
    'hostname'      => 'tester',
    'name'          => 'Tester',
    'customization_spec' => {
        'domain'     => 'example.com',
        'ipsettings' => {
            'ip'      => '172.18.2.10',
            'gateway' => ['172.18.2.1'],
            'subnetMask' => '255.255.255.0',
        },
     },
}

puts "Deploying new VM from template.  This may take a few minutes..." 
new_vm=connection.vm_clone(options)
pp new_vm

关于ruby - 工头 - 从 vmware 模板克隆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22632524/

相关文章:

html - 从 HTML 在 Ruby 函数中传递参数

PERL_LWP_SSL_VERIFY_HOSTNAME 设置为 0 不起作用

linux - Google Compute 引擎上 VM 的嵌套虚拟化

virtualization - 为 vmware 付费还是使用开源?

linux - 作为虚拟机运行的 Linux 是否会使用主机操作系统的驱动程序?

javascript - 带有 Ruby on Rails 的 Ajax 简单 View 刷新

ruby - 在 Linux Mint 中安装 gstreamer gem 时遇到问题

ruby - 如何在ruby中解析大的xml文件

powershell - 如何从 VMware ESXi 5.0 上运行的虚拟机获取文件

vmware - 如何从 HostSystem 对象确定 vCenter Server?