fog / fog-xenserver

Module for the 'fog' gem to support XENSERVER
MIT License
16 stars 22 forks source link

servers.create with template_name creates an empty vm #48

Closed fmbiete closed 9 years ago

fmbiete commented 9 years ago

Hi,

When using servers.create to create a new server, using template_name from a template, I end with a template withouth VIFs or VBDs.

That should not create a server (not a template), with cloned vifs and disks?

irb(main):020:0> vm_new = xenserver.servers.create(affinity: xenserver.hosts.first, name: 'NEW-MACHINE-FROM-TEMPLATE', template_name: template.name)
=>   <Fog::Compute::XenServer::Models::Server
    reference="OpaqueRef:11a02f0e-cc3a-6735-6fd5-30814e2e950a",
    actions_after_crash="restart",
    actions_after_reboot="restart",
    actions_after_shutdown="destroy",
    allowed_operations=["changing_dynamic_range", "changing_shadow_memory", "changing_static_range", "provision", "destroy", "export", "clone", "copy"],
    blobs={},
    blocked_operations={},
    bios_strings={},
    current_operations={},
    domarch="",
    domid="-1",
    description="",
    generation_id="0:0",
    ha_always_run=false,
    ha_restart_priority="",
    hvm_boot_params={},
    hvm_boot_policy="",
    hvm_shadow_multiplier=1.0,
    is_a_snapshot=false,
    is_a_template=true,
    is_control_domain=false,
    is_snapshot_from_vmpp=false,
    last_booted_record="",
    last_boot_cpu_flags={},
    memory_dynamic_max="536870912",
    memory_dynamic_min="536870912",
    memory_overhead="6291456",
    memory_static_max="536870912",
    memory_static_min="536870912",
    memory_target="0",
    name="NEW-MACHINE-FROM-TEMPLATE",
    order="0",
    other_config={"mac_seed"=>"56d6cb2d-55ce-5b21-d3af-0e55927075d7"},
    pci_bus="",
    platform={"nx"=>"true", "acpi"=>"true", "apic"=>"true", "pae"=>"true", "viridian"=>"true"},
    power_state="Halted",
    pv_args="-- quiet console=hvc0",
    pv_bootloader="pygrub",
    pv_bootloader_args="",
    pv_kernel="",
    pv_legacy_args="",
    pv_ramdisk="",
    recommendations="",
    shutdown_delay="0",
    snapshot_info={},
    snapshot_metadata="",
    snapshot_time=1970-01-01 00:00:00 UTC,
    start_delay="0",
    tags=[],
    transportable_snapshot_id="",
    user_version="0",
    uuid="933b5d7b-9336-26f1-d791-f4f0c4314ca5",
    vcpus_at_startup="1",
    vcpus_max="1",
    vcpus_params={},
    version="0",
    xenstore_data={}
  >
irb(main):021:0> vm_new.vifs.count                                                                                                                
=> 0
irb(main):022:0> vm_new.vbds.count
=> 0
irb(main):025:0> template.is_a_template
=> true
irb(main):026:0> template.vifs.count
=> 1
irb(main):027:0> template.vbds.count
=> 2
plribeiro3000 commented 9 years ago

Ok. Thats the biggest change in the api. That template_name attribute was not a real attribute of XENSERVER but rather just a "boolean" attribute that would change completely the behavior of the VM creation and thus a lot of headaches to support it.

So this option was completely removed. That attribute does not exist anymore. You gotta dance as the XENSERVERapi now :smile: . No magic behind the scenes.

If you want to create a server from a template, just load the template and clone it:

@template = @conn.templates.find ....
@server = @template.clone
@server.provision

If you want to create a server from scratch, you gotta do a little more, like creating the disk, the vif, and installing the operational system.

plribeiro3000 commented 9 years ago

Be sure to use fog-xenserver and not fog because i think it does not accept template_name as an attribute anymore.

LMK if you have further problems but i think that you should start looking at the API documentation here. The current implementation tries to be the more compliant as possible to the api.