document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import XenAPI
  2. session=XenAPI.Session("http://172.20.25.172")
  3. session.xenapi.login_with_password("root","123")
  4. hh=session.xenapi.host.get_by_name_label("xenserver2")
  5. record_hh=session.xenapi.host.get_record(hh[0])
  6. pbds=record_hh["PBDs"]
  7. for p in pbds:
  8.     aa=session.xenapi.SR.get_by_name_label("Local storage")
  9.     for a in aa:
  10.         record=session.xenapi.SR.get_record(a)
  11.         pp=record["PBDs"]
  12.         for px in pp:
  13.             if p==px:
  14.                 vdisk={\'name_label\':"Disco",
  15.                        \'name_description\':"",
  16.                        \'SR\':aa[1],
  17.                        \'virtual_size\':"2555555555",
  18.                        \'type\':"user",
  19.                        \'sharable\':True,
  20.                        \'read_only\':True,
  21.                        \'other_config\':{}}
  22.                 vdi_ref=session.xenapi.VDI.create(vdisk)
  23.                 platfrm={}
  24.                 vmprop={\'name_label\':"testVM",
  25.                         \'name_description\':"",
  26.                         \'user_version\':"1",
  27.                         \'affinity\':"",
  28.                         \'is_a_template\':False,
  29.                         \'auto_power_on\':False,
  30.                         \'memory_static_max\':"268435456",
  31.                         \'memory_static_min\':"268435456",
  32.                         \'memory_dynamic_max\':"268435456",
  33.                         \'memory_dynamic_min\':"268435456",
  34.                         \'VCPUs_max\':"1",
  35.                         \'VCPUs_at_startup\':"1",
  36.                         \'VCPUs_params\':{},
  37.                         \'actions_after_shutdown\':"destroy",
  38.                         \'actions_after_reboot\':"restart",
  39.                         \'actions_after_crash\':"restart",
  40.                         \'PV_kernel\':"",
  41.                         \'PV_ramdisk\':"",
  42.                         \'PV_bootloader\':"",
  43.                         \'PV_bootloader_args\':"",
  44.                         \'PV_legacy_args\':"",
  45.                         \'HVM_boot_policy\':"BIOS order",
  46.                         \'HVM_boot_params\':{\'order\':\'dc\'},
  47.                         \'platform\':platfrm,
  48.                         \'PCI_bus\':"",
  49.                         \'other_config\':{},
  50.                         \'recommendations\':"",
  51.                         \'PV_args\':""}
  52.                 VM_ref=session.xenapi.VM.create(vmprop)
  53.                 vbdconnect={\'VDI\':vdi_ref,
  54.                             \'VM\':VM_ref,
  55.                             \'userdevice\':"0",
  56.                             \'mode\':"RW",
  57.                             \'type\':"Disk",
  58.                             \'bootable\':True,
  59.                             \'unpluggable\':True,
  60.                             \'empty\':False,
  61.                             \'other_config\':{},
  62.                             \'qos_algorithm_type\':\'\',
  63.                             \'qos_algorithm_params\':{}}
  64.                 vbdref=session.xenapi.VBD.create(vbdconnect)
');