fog-xenserver 0.0.1.alpha2 → 0.0.1.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. checksums.yaml +4 -4
  2. data/.hound.yml +27 -0
  3. data/.travis.yml +19 -0
  4. data/CONTRIBUTING.md +6 -6
  5. data/Gemfile +1 -1
  6. data/LICENSE.md +1 -1
  7. data/README.md +3 -1
  8. data/Rakefile +10 -1
  9. data/fog-xenserver.gemspec +6 -4
  10. data/gemfiles/Gemfile.1.8.7 +7 -0
  11. data/gemfiles/Gemfile.1.9.2+ +6 -0
  12. data/lib/fog.rb +1 -1
  13. data/lib/fog/collection.rb +37 -0
  14. data/lib/fog/compute/xen_server.rb +132 -0
  15. data/lib/fog/compute/xen_server/mock.rb +27 -0
  16. data/lib/fog/compute/xen_server/models.rb +78 -0
  17. data/lib/fog/compute/xen_server/models/blob.rb +24 -0
  18. data/lib/fog/compute/xen_server/models/blobs.rb +11 -0
  19. data/lib/fog/compute/xen_server/models/bond.rb +26 -0
  20. data/lib/fog/compute/xen_server/models/bonds.rb +11 -0
  21. data/lib/fog/compute/xen_server/models/console.rb +23 -0
  22. data/lib/fog/compute/xen_server/models/consoles.rb +11 -0
  23. data/lib/fog/compute/xen_server/models/crash_dump.rb +22 -0
  24. data/lib/fog/compute/xen_server/models/crash_dumps.rb +11 -0
  25. data/lib/fog/compute/xen_server/models/dr_task.rb +20 -0
  26. data/lib/fog/compute/xen_server/models/dr_tasks.rb +11 -0
  27. data/lib/fog/compute/xen_server/models/gpu_group.rb +25 -0
  28. data/lib/fog/compute/xen_server/models/gpu_groups.rb +11 -0
  29. data/lib/fog/compute/xen_server/models/guest_metrics.rb +28 -0
  30. data/lib/fog/compute/xen_server/models/guests_metrics.rb +11 -0
  31. data/lib/fog/compute/xen_server/models/host.rb +121 -0
  32. data/lib/fog/compute/xen_server/models/host_cpu.rb +31 -0
  33. data/lib/fog/compute/xen_server/models/host_cpus.rb +11 -0
  34. data/lib/fog/compute/xen_server/models/host_crash_dump.rb +23 -0
  35. data/lib/fog/compute/xen_server/models/host_crash_dumps.rb +11 -0
  36. data/lib/fog/compute/xen_server/models/host_metrics.rb +28 -0
  37. data/lib/fog/compute/xen_server/models/host_patch.rb +28 -0
  38. data/lib/fog/compute/xen_server/models/host_patchs.rb +11 -0
  39. data/lib/fog/compute/xen_server/models/hosts.rb +11 -0
  40. data/lib/fog/compute/xen_server/models/hosts_metrics.rb +11 -0
  41. data/lib/fog/compute/xen_server/models/network.rb +65 -0
  42. data/lib/fog/compute/xen_server/models/networks.rb +11 -0
  43. data/lib/fog/compute/xen_server/models/pbd.rb +30 -0
  44. data/lib/fog/compute/xen_server/models/pbds.rb +11 -0
  45. data/lib/fog/compute/xen_server/models/pci.rb +25 -0
  46. data/lib/fog/compute/xen_server/models/pcis.rb +11 -0
  47. data/lib/fog/compute/xen_server/models/pgpu.rb +23 -0
  48. data/lib/fog/compute/xen_server/models/pgpus.rb +11 -0
  49. data/lib/fog/compute/xen_server/models/pif.rb +49 -0
  50. data/lib/fog/compute/xen_server/models/pif_metrics.rb +30 -0
  51. data/lib/fog/compute/xen_server/models/pifs.rb +11 -0
  52. data/lib/fog/compute/xen_server/models/pifs_metrics.rb +9 -0
  53. data/lib/fog/compute/xen_server/models/pool.rb +47 -0
  54. data/lib/fog/compute/xen_server/models/pool_patch.rb +27 -0
  55. data/lib/fog/compute/xen_server/models/pool_patchs.rb +11 -0
  56. data/lib/fog/compute/xen_server/models/pools.rb +11 -0
  57. data/lib/fog/compute/xen_server/models/role.rb +22 -0
  58. data/lib/fog/compute/xen_server/models/roles.rb +11 -0
  59. data/lib/fog/compute/xen_server/models/server.rb +203 -0
  60. data/lib/fog/compute/xen_server/models/server_appliance.rb +24 -0
  61. data/lib/fog/compute/xen_server/models/server_appliances.rb +11 -0
  62. data/lib/fog/compute/xen_server/models/server_metrics.rb +29 -0
  63. data/lib/fog/compute/xen_server/models/servers.rb +38 -0
  64. data/lib/fog/compute/xen_server/models/servers_metrics.rb +11 -0
  65. data/lib/fog/compute/xen_server/models/storage_manager.rb +30 -0
  66. data/lib/fog/compute/xen_server/models/storage_managers.rb +11 -0
  67. data/lib/fog/compute/xen_server/models/storage_repositories.rb +11 -0
  68. data/lib/fog/compute/xen_server/models/storage_repository.rb +77 -0
  69. data/lib/fog/compute/xen_server/models/tunnel.rb +23 -0
  70. data/lib/fog/compute/xen_server/models/tunnels.rb +11 -0
  71. data/lib/fog/compute/xen_server/models/vbd.rb +64 -0
  72. data/lib/fog/compute/xen_server/models/vbd_metrics.rb +27 -0
  73. data/lib/fog/compute/xen_server/models/vbds.rb +11 -0
  74. data/lib/fog/compute/xen_server/models/vbds_metrics.rb +11 -0
  75. data/lib/fog/compute/xen_server/models/vdi.rb +75 -0
  76. data/lib/fog/compute/xen_server/models/vdis.rb +11 -0
  77. data/lib/fog/compute/xen_server/models/vif.rb +53 -0
  78. data/lib/fog/compute/xen_server/models/vif_metrics.rb +22 -0
  79. data/lib/fog/compute/xen_server/models/vifs.rb +11 -0
  80. data/lib/fog/compute/xen_server/models/vifs_metrics.rb +11 -0
  81. data/lib/fog/compute/xen_server/models/vlan.rb +65 -0
  82. data/lib/fog/compute/xen_server/models/vlans.rb +11 -0
  83. data/lib/fog/compute/xen_server/models/vmpp.rb +38 -0
  84. data/lib/fog/compute/xen_server/models/vmpps.rb +11 -0
  85. data/lib/fog/compute/xen_server/models/vtpm.rb +21 -0
  86. data/lib/fog/compute/xen_server/models/vtpms.rb +11 -0
  87. data/lib/fog/compute/xen_server/real.rb +36 -0
  88. data/lib/fog/compute/xen_server/requests/builtin_templates.rb +21 -0
  89. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/clone_server.rb +1 -5
  90. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/create_network.rb +1 -6
  91. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/create_server.rb +1 -14
  92. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/create_sr.rb +1 -7
  93. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/create_vbd.rb +1 -6
  94. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/create_vdi.rb +1 -6
  95. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/create_vif.rb +1 -6
  96. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/create_vlan.rb +1 -6
  97. data/lib/fog/compute/xen_server/requests/custom_templates.rb +21 -0
  98. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/destroy_network.rb +1 -6
  99. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/destroy_server.rb +1 -6
  100. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/destroy_sr.rb +1 -6
  101. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/destroy_vdi.rb +1 -6
  102. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/destroy_vif.rb +1 -6
  103. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/destroy_vlan.rb +1 -6
  104. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/disable_host.rb +1 -7
  105. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/eject_vbd.rb +1 -6
  106. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/enable_host.rb +1 -7
  107. data/lib/fog/compute/xen_server/requests/get_record.rb +41 -0
  108. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/get_records.rb +1 -9
  109. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/insert_vbd.rb +1 -6
  110. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/provision_server.rb +1 -5
  111. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/reboot_host.rb +2 -8
  112. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/reboot_server.rb +2 -8
  113. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/scan_sr.rb +1 -6
  114. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/set_affinity.rb +1 -9
  115. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/set_attribute.rb +1 -9
  116. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/shutdown_host.rb +2 -8
  117. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/shutdown_server.rb +2 -8
  118. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/snapshot_revert.rb +1 -6
  119. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/snapshot_server.rb +1 -6
  120. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/start_server.rb +1 -7
  121. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/start_vm.rb +2 -8
  122. data/lib/fog/compute/xen_server/requests/templates.rb +21 -0
  123. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/unplug_pbd.rb +1 -6
  124. data/lib/fog/{xenserver/requests/compute → compute/xen_server/requests}/unplug_vbd.rb +1 -6
  125. data/lib/fog/model.rb +48 -0
  126. data/lib/fog/parsers/xen_server.rb +15 -0
  127. data/lib/fog/{xenserver/parser.rb → parsers/xen_server/base.rb} +1 -3
  128. data/lib/fog/{xenserver/parsers → parsers/xen_server}/get_hosts.rb +1 -4
  129. data/lib/fog/{xenserver/parsers → parsers/xen_server}/get_networks.rb +1 -4
  130. data/lib/fog/{xenserver/parsers → parsers/xen_server}/get_pools.rb +1 -4
  131. data/lib/fog/{xenserver/parsers → parsers/xen_server}/get_records.rb +1 -4
  132. data/lib/fog/{xenserver/parsers → parsers/xen_server}/get_storage_repositories.rb +1 -4
  133. data/lib/fog/{xenserver/parsers → parsers/xen_server}/get_vbds.rb +2 -5
  134. data/lib/fog/{xenserver/parsers → parsers/xen_server}/get_vifs.rb +2 -5
  135. data/lib/fog/{xenserver/parsers → parsers/xen_server}/get_vms.rb +1 -5
  136. data/lib/fog/{xenserver/utilities.rb → utilities.rb} +0 -0
  137. data/lib/fog/{xenserver/core.rb → xen_server/connection.rb} +2 -40
  138. data/lib/fog/xen_server/invalid_login.rb +5 -0
  139. data/lib/fog/xen_server/nokogiri_stream_parser.rb +20 -0
  140. data/lib/fog/xen_server/not_found.rb +5 -0
  141. data/lib/fog/xen_server/request_failed.rb +5 -0
  142. data/lib/fog/xen_server/version.rb +5 -0
  143. data/lib/fog/xenserver.rb +27 -1
  144. data/lib/fog/xenserver/compute.rb +0 -176
  145. data/test/fog/compute/xen_server/models/blob_test.rb +40 -0
  146. data/test/fog/compute/xen_server/models/bond_test.rb +42 -0
  147. data/test/fog/compute/xen_server/models/console_test.rb +38 -0
  148. data/test/fog/compute/xen_server/models/crash_dump_test.rb +39 -0
  149. data/test/fog/compute/xen_server/models/dr_task_test.rb +35 -0
  150. data/test/fog/compute/xen_server/models/gpu_group_test.rb +45 -0
  151. data/test/fog/compute/xen_server/models/guest_metrics_test.rb +44 -0
  152. data/test/fog/compute/xen_server/models/host_cpu_test.rb +46 -0
  153. data/test/fog/compute/xen_server/models/host_crash_dump_test.rb +37 -0
  154. data/test/fog/compute/xen_server/models/host_metrics_test.rb +38 -0
  155. data/test/fog/compute/xen_server/models/host_patch_test.rb +45 -0
  156. data/test/fog/compute/xen_server/models/host_test.rb +102 -0
  157. data/test/fog/compute/xen_server/models/network_test.rb +51 -0
  158. data/test/fog/compute/xen_server/models/pbd_test.rb +40 -0
  159. data/test/fog/compute/xen_server/models/pci_test.rb +40 -0
  160. data/test/fog/compute/xen_server/models/pgpu_test.rb +41 -0
  161. data/test/fog/compute/xen_server/models/pif_metrics_test.rb +45 -0
  162. data/test/fog/compute/xen_server/models/pif_test.rb +81 -0
  163. data/test/fog/compute/xen_server/models/pool_patch_test.rb +43 -0
  164. data/test/fog/compute/xen_server/models/pool_test.rb +69 -0
  165. data/test/fog/compute/xen_server/models/role_test.rb +38 -0
  166. data/test/fog/compute/xen_server/models/server_appliance_test.rb +41 -0
  167. data/test/fog/compute/xen_server/models/server_metrics_test.rb +48 -0
  168. data/test/fog/compute/xen_server/models/server_test.rb +149 -0
  169. data/test/fog/compute/xen_server/models/storage_manger_test.rb +46 -0
  170. data/test/fog/compute/xen_server/models/storage_repository_test.rb +56 -0
  171. data/test/fog/compute/xen_server/models/tunnel_test.rb +40 -0
  172. data/test/fog/compute/xen_server/models/vbd_metrics_test.rb +37 -0
  173. data/test/fog/compute/xen_server/models/vbd_test.rb +58 -0
  174. data/test/fog/compute/xen_server/models/vdi_test.rb +71 -0
  175. data/test/fog/compute/xen_server/models/vif_metrics_test.rb +37 -0
  176. data/test/fog/compute/xen_server/models/vif_test.rb +59 -0
  177. data/test/fog/compute/xen_server/models/vlan_test.rb +40 -0
  178. data/test/fog/compute/xen_server/models/vmpp_test.rb +55 -0
  179. data/test/fog/compute/xen_server/models/vtpm_test.rb +36 -0
  180. data/test/minitest_helper.rb +28 -0
  181. metadata +239 -120
  182. data/lib/fog/compute.rb +0 -7
  183. data/lib/fog/xenserver/examples/README.md +0 -11
  184. data/lib/fog/xenserver/examples/chage_default_storage_repository.md +0 -99
  185. data/lib/fog/xenserver/examples/creating_servers.md +0 -168
  186. data/lib/fog/xenserver/examples/getting_started.md +0 -163
  187. data/lib/fog/xenserver/examples/networks-and-vlans.rb +0 -45
  188. data/lib/fog/xenserver/examples/storage_repositories.md +0 -94
  189. data/lib/fog/xenserver/models/compute/blob.rb +0 -22
  190. data/lib/fog/xenserver/models/compute/blobs.rb +0 -25
  191. data/lib/fog/xenserver/models/compute/bond.rb +0 -23
  192. data/lib/fog/xenserver/models/compute/bonds.rb +0 -25
  193. data/lib/fog/xenserver/models/compute/console.rb +0 -29
  194. data/lib/fog/xenserver/models/compute/consoles.rb +0 -25
  195. data/lib/fog/xenserver/models/compute/crash_dump.rb +0 -19
  196. data/lib/fog/xenserver/models/compute/crash_dumps.rb +0 -25
  197. data/lib/fog/xenserver/models/compute/dr_task.rb +0 -17
  198. data/lib/fog/xenserver/models/compute/dr_tasks.rb +0 -25
  199. data/lib/fog/xenserver/models/compute/gpu_group.rb +0 -22
  200. data/lib/fog/xenserver/models/compute/gpu_groups.rb +0 -25
  201. data/lib/fog/xenserver/models/compute/guest_metrics.rb +0 -29
  202. data/lib/fog/xenserver/models/compute/host.rb +0 -159
  203. data/lib/fog/xenserver/models/compute/host_cpu.rb +0 -38
  204. data/lib/fog/xenserver/models/compute/host_crash_dump.rb +0 -20
  205. data/lib/fog/xenserver/models/compute/host_crash_dumps.rb +0 -25
  206. data/lib/fog/xenserver/models/compute/host_metrics.rb +0 -29
  207. data/lib/fog/xenserver/models/compute/host_patch.rb +0 -25
  208. data/lib/fog/xenserver/models/compute/host_patchs.rb +0 -25
  209. data/lib/fog/xenserver/models/compute/hosts.rb +0 -29
  210. data/lib/fog/xenserver/models/compute/network.rb +0 -92
  211. data/lib/fog/xenserver/models/compute/networks.rb +0 -33
  212. data/lib/fog/xenserver/models/compute/pbd.rb +0 -40
  213. data/lib/fog/xenserver/models/compute/pbds.rb +0 -33
  214. data/lib/fog/xenserver/models/compute/pci.rb +0 -22
  215. data/lib/fog/xenserver/models/compute/pcis.rb +0 -25
  216. data/lib/fog/xenserver/models/compute/pgpu.rb +0 -20
  217. data/lib/fog/xenserver/models/compute/pgpus.rb +0 -25
  218. data/lib/fog/xenserver/models/compute/pif.rb +0 -57
  219. data/lib/fog/xenserver/models/compute/pif_metrics.rb +0 -28
  220. data/lib/fog/xenserver/models/compute/pifs.rb +0 -33
  221. data/lib/fog/xenserver/models/compute/pifs_metrics.rb +0 -25
  222. data/lib/fog/xenserver/models/compute/pool.rb +0 -79
  223. data/lib/fog/xenserver/models/compute/pool_patch.rb +0 -24
  224. data/lib/fog/xenserver/models/compute/pool_patchs.rb +0 -25
  225. data/lib/fog/xenserver/models/compute/pools.rb +0 -33
  226. data/lib/fog/xenserver/models/compute/role.rb +0 -19
  227. data/lib/fog/xenserver/models/compute/roles.rb +0 -25
  228. data/lib/fog/xenserver/models/compute/server.rb +0 -250
  229. data/lib/fog/xenserver/models/compute/server_appliance.rb +0 -21
  230. data/lib/fog/xenserver/models/compute/server_appliances.rb +0 -25
  231. data/lib/fog/xenserver/models/compute/servers.rb +0 -68
  232. data/lib/fog/xenserver/models/compute/storage_manager.rb +0 -28
  233. data/lib/fog/xenserver/models/compute/storage_managers.rb +0 -25
  234. data/lib/fog/xenserver/models/compute/storage_repositories.rb +0 -31
  235. data/lib/fog/xenserver/models/compute/storage_repository.rb +0 -93
  236. data/lib/fog/xenserver/models/compute/tunnel.rb +0 -20
  237. data/lib/fog/xenserver/models/compute/tunnels.rb +0 -25
  238. data/lib/fog/xenserver/models/compute/vbd.rb +0 -91
  239. data/lib/fog/xenserver/models/compute/vbd_metrics.rb +0 -27
  240. data/lib/fog/xenserver/models/compute/vbds.rb +0 -33
  241. data/lib/fog/xenserver/models/compute/vdi.rb +0 -105
  242. data/lib/fog/xenserver/models/compute/vdis.rb +0 -29
  243. data/lib/fog/xenserver/models/compute/vif.rb +0 -60
  244. data/lib/fog/xenserver/models/compute/vifs.rb +0 -29
  245. data/lib/fog/xenserver/models/compute/vlan.rb +0 -81
  246. data/lib/fog/xenserver/models/compute/vlans.rb +0 -39
  247. data/lib/fog/xenserver/models/compute/vmpp.rb +0 -35
  248. data/lib/fog/xenserver/models/compute/vmpps.rb +0 -25
  249. data/lib/fog/xenserver/models/compute/vtpm.rb +0 -18
  250. data/lib/fog/xenserver/models/compute/vtpms.rb +0 -25
  251. data/lib/fog/xenserver/requests/compute/get_record.rb +0 -29
  252. data/lib/fog/xenserver/version.rb +0 -5
data/lib/fog/compute.rb DELETED
@@ -1,7 +0,0 @@
1
- require "fog/xenserver/version"
2
-
3
- module Fog
4
- module Compute
5
- autoload :XenServer, 'fog/xenserver/compute'
6
- end
7
- end
@@ -1,11 +0,0 @@
1
- # fog/xenserver compute examples
2
-
3
- fog/xenserver examples contributed by BVox World S.L.U.
4
- Original examples from https://github.com/bvox/fog-xenserver-examples
5
-
6
- Maintainer: Sergio Rubio <rubiojr@bvox.net>
7
-
8
- A general introduction to Fog is available at:
9
-
10
- http://fog.io
11
-
@@ -1,99 +0,0 @@
1
- # How To Change the Default Storage Repository to File-based VHD-on-EXT3
2
-
3
- **NOTE: Requires fog > 1.8 (currently in development as of this writing)**
4
-
5
- This tutorial explains how to convert a local Logical Volume Manager (LVM)
6
- based storage repository into a file-based (VHD) storage repository.
7
-
8
- It's the fog/xenserver version of the original Citrix KB article:
9
-
10
- http://support.citrix.com/article/ctx116324
11
-
12
- To create this tutorial, I've used a vanilla XCP 1.6 ISO install in VirtualBox.
13
-
14
- ## Create the connection
15
-
16
- ```ruby
17
- require 'fog'
18
-
19
- conn = Fog::Compute.new({
20
- :provider => 'XenServer',
21
- :xenserver_url => '192.168.1.39',
22
- :xenserver_username => 'root',
23
- :xenserver_password => 'secret'
24
- })
25
- ```
26
-
27
- ## Remove the LVM-backed storage repository (SR).
28
-
29
- Find the default LVM storage repository:
30
-
31
- ```ruby
32
- #
33
- # Equivalent to:
34
- # xe sr-list type=lvm
35
- #
36
- lvm_sr = nil
37
- conn.storage_repositories.each do |sr|
38
- lvm_sr = sr if sr.type == 'lvm'
39
- end
40
- ```
41
-
42
- Determine the UUID for your default SR's physical block device:
43
-
44
- ```ruby
45
- #
46
- # Equivalent to:
47
- # xe pbd-list sr-uuid=your SR UUID
48
- #
49
- if lvm_sr
50
- conn.pbds.each do |pbd|
51
- # Unplug it if found
52
- # Equivalent to:
53
- # xe pbd-unplug uuid=your PBD UUID
54
- #
55
- pbd.unplug if pbd.storage_repository.uuid == lvm_sr.uuid
56
- end
57
- # Destroy the SR
58
- lvm_sr.destroy
59
- end
60
- ```
61
-
62
- Create a new VHD-backed SR:
63
-
64
- ```ruby
65
- #
66
- # Equivalent to:
67
- #
68
- # xe sr-create content-type="local SR" \
69
- # host-uuid=5d189b7a-cd5e-4029-9940-d4daaa34633d \
70
- # type=ext device-config-device=/dev/sda3 shared=false \
71
- # name-label="Local File SR"
72
- #
73
- sr = conn.storage_repositories.create :name => 'Local File SR',
74
- :host => conn.hosts.first,
75
- :type => 'ext',
76
- :content_type => 'local SR',
77
- :device_config => { :device => '/dev/sda3' },
78
- :shared => false
79
- ```
80
-
81
- Set your SR as the default SR on the system:
82
-
83
- ```ruby
84
- #
85
- # Equivalent command:
86
- # xe pool-param-set suspend-image-SR='YOUR NEW SR UUID' uuid=bleh
87
- #
88
- conn.pools.first.default_storage_repository = sr
89
- ```
90
-
91
- Set your SR as the default location for suspended VM images:
92
-
93
- ```ruby
94
- #
95
- # Equivalent command:
96
- # xe pool-param-set suspend-image-SR= YOUR NEW SR UUID uuid=bleh
97
- #
98
- conn.pools.first.suspend_image_sr = sr
99
- ```
@@ -1,168 +0,0 @@
1
- # Creating servers (VMs) and templates
2
-
3
- The basic server creation steps are detailed in the getting started tutorial.
4
-
5
- Now let's do something a little bit more complex and probably more useful in
6
- day-to-day operations. That is:
7
-
8
- 1. Uploading a VHD image.
9
- 2. Create a new template with it.
10
- 3. Spin a new server using the recently added template.
11
-
12
- ## Part I: Upload the VHD
13
-
14
- Assuming we have an image file 'ubuntu.vhd' ready to be uploaded, let's create
15
- the connection to the XenServer host and upload the image to the storage repository,
16
- using SSH. The code also assumes that you have a file storage repository mounted
17
- somewhere in /var/run/sr-mount/#{sr-UUID} (the standard XenServer base directory
18
- for mounted storage repositories).
19
-
20
- require 'fog'
21
- require 'net/scp'
22
- require 'uuidtools'
23
-
24
- #
25
- # Create the connection to the XenServer host
26
- #
27
- xenserver = Fog::Compute.new({
28
- :provider => 'XenServer',
29
- :xenserver_url => 'xenserver-test',
30
- :xenserver_username => 'root',
31
- :xenserver_password => 'secret',
32
- })
33
-
34
-
35
- We'll be uploading the image to the "Local File SR" storage repository, so
36
- we need the reference to this SR (Storage Repository):
37
-
38
- sr = xenserver.storage_repositories.find { |sr| sr.name == "Local File SR" }
39
-
40
- XenServer uses UUIDs to store images in the storage repositories, so we will
41
- emulate that behavior, creating a new UUID for our image and uploading it.
42
-
43
- #
44
- # Use the excelent uuidtools gem to create the new UUID
45
- # for the image
46
- #
47
- image_uuid = UUIDTools::UUID.random_create.to_s
48
-
49
-
50
- To upload the new image using SCP, we need the destination directory, where the
51
- SR is mounted. In our case, the storage repository mount point is
52
- /var/run/sr-mount/#{sr.uuid} (where sr.uuid is the UUID of the storage
53
- repository). We will upload the new image there:
54
-
55
- sr_mount_point = "/var/run/sr-mount/#{sr.uuid}"
56
- # Target image file path. We will upload the local image to the destination
57
- # using SCP
58
- destination = File.join(sr_mount_point, "#{image_uuid}.vhd")
59
- # source image, located in the current directory
60
- source = 'ubuntu.vhd'
61
- # Use the XenServer root credentials to upload
62
- Net::SSH.start('xenserver-test', 'root', :password => 'secret') do |ssh|
63
- ssh.scp.upload!(source, destination) do |ch, name, sent, total|
64
- # print progress
65
- p = (sent.to_f * 100 / total.to_f).to_i.to_s
66
- print "\rProgress: #{p}% completed"
67
- end
68
- end
69
-
70
- We need to let the XenServer know, that there's a new image:
71
-
72
- sr.scan
73
-
74
- Now that XenServer is aware of the new image, get its reference
75
- and set the image name attribute to 'ubuntu-template'
76
-
77
- ubuntu_vdi = xenserver.vdis.find { |vdi| vdi.uuid == image_uuid }
78
- ubuntu_vdi.set_attribute 'name_label', 'ubuntu-template'
79
-
80
- Good! the image is ready to be used.
81
-
82
- ## Part II: create the server template
83
-
84
- We have the image ready to be used by our new template.
85
-
86
- Templates are regular servers, so let's create one with 512 MB of RAM, 1 CPU
87
- and a network card. The main difference with a regular server from an API
88
- point of view is that we will not start it.
89
-
90
- We will also create the template as PV (paravirtual):
91
-
92
- server_mem = (512 * 1024 * 1024).to_s
93
- server = xenserver.servers.new :name => "ubuntu-template",
94
- # Required when using Server.new
95
- :affinity => xenserver.hosts.first,
96
- :other_config => {},
97
- :pv_bootloader => 'pygrub', # PV related
98
- :hvm_boot_policy => '', # PV related
99
- :pv_args => '-- console=hvc0', # PV related
100
- :memory_static_max => mem,
101
- :memory_static_min => mem,
102
- :memory_dynamic_max => mem,
103
- :memory_dynamic_min => mem
104
- server.save
105
-
106
- We need to attach the disk image to a VBD and to the server
107
-
108
- xenserver.vbds.create :server => server, :vdi => ubuntu_vdi
109
-
110
- Note that we're using Server.new here, instead of Server.create.
111
- Server.create would start the server, and that's not what we want here.
112
-
113
- Let's add the NIC (VIF or virtual interface) to the server.
114
-
115
- I have a network in my XenServer named "Pool-wide network associated with eth0"
116
- bridged to the physical eth0 NIC and I will attach the new NIC to that network.
117
-
118
- Don't be scared by the VIF creation code. There are easier ways to create a
119
- VIF, and we'll be dealing with that and some other cases in the networking
120
- tutorial (TODO).
121
-
122
- First, let's find the network since we'll need the reference.
123
-
124
- net = xenserver.networks.find { |n| n.name == 'Pool-wide network associated with eth0' }
125
-
126
- To create the VM VIF, we need to set some attributes and use the
127
- create_vif_custom request:
128
-
129
- vif_attr = {
130
- 'MAC_autogenerated' => 'True',
131
- 'VM' => server.reference, # we need the VM reference here
132
- 'network' => net.reference, # we need the Network reference here
133
- 'MAC' => '', # ignored, since we use autogeneration
134
- 'device' => '0',
135
- 'MTU' => '0',
136
- 'other_config' => {},
137
- 'qos_algorithm_type' => 'ratelimit',
138
- 'qos_algorithm_params' => {}
139
- }
140
- xenserver.create_vif_custom vif_attr
141
-
142
-
143
- The template is now ready to be used and we can list it!
144
-
145
- xenserver.servers.custom_templates.find { |t| puts t.name }
146
-
147
- ## Party III: spin a new server using the brand new template
148
-
149
- Now that we have the template in place, it's easy to create as many servers
150
- as you want. All of them will share hardware specs with the template. That is,
151
- 512 MB of RAM, 1 CPU, 1 NIC attached to the 'Pool-wide network...':
152
-
153
- xenserver.servers.create :name => 'my-brand-new-server',
154
- :template_name => 'ubuntu-template'
155
-
156
-
157
- # The End
158
-
159
- Pretty similar code is used by knife-xenserver (http://github.com/bvox/knife-xenserver)
160
- to upload new templates. Have a look at it if you're interested, it's full of
161
- examples and fog/xenserver tricks to manage XenServer/XCP hosts.
162
-
163
- The full source code used in this tutorial is available at:
164
-
165
- https://github.com/bvox/fog-xenserver-examples/blob/master/upload_template_and_create.rb
166
-
167
- Enjoy!
168
-
@@ -1,163 +0,0 @@
1
- # Getting started: the compute service
2
-
3
- ## Connecting, retrieving and managing server objects
4
-
5
- First, create a connection to the XenServer host:
6
-
7
- require 'fog'
8
- require 'pp'
9
-
10
- #
11
- # http://rubydoc.info/github/fog/fog/Fog/Compute/XenServer/Real
12
- #
13
- conn = Fog::Compute.new({
14
- :provider => 'XenServer',
15
- :xenserver_url => 'xenserver-test',
16
- :xenserver_username => 'root',
17
- :xenserver_password => 'changeme',
18
- :xenserver_defaults => {
19
- :template => "squeeze-test"
20
- }
21
- })
22
-
23
- ## Listing servers (VMs) and templates
24
-
25
- We try to follow fog naming conventions and behavior as much as we can, so the
26
- terminology used in fog/xenserver is a little bit different from the one
27
- used in XAPI/XenServer documents. In particular:
28
-
29
- * A Fog::Compute::XenServer::Server is a XenServer VM or DomU
30
-
31
- * A Fog::Compute::XenServer::Host is a Hypervisor or Dom0
32
-
33
- Having that in mind, we can start doing things with out XenServer host.
34
-
35
- Listing all the servers (VMs):
36
-
37
- conn.servers.all
38
-
39
- This will return a list of Fog::Compute::XenServer::Server.
40
-
41
- List all the servers whose name matches Ubuntu:
42
-
43
- conn.servers.all :name_matches => "Ubuntu"
44
-
45
- Listing the first server running (templates aren't included by default
46
- in the list):
47
-
48
- server = conn.servers.first
49
-
50
- Listing custom templates, that is, the ones created by the user:
51
-
52
- custom = conn.servers.custom_templates
53
-
54
- Listing built-in templates (the templates available after a fresh install):
55
-
56
- built_in = conn.servers.builtin_templates
57
-
58
- Templates are regular Fog::Compute::XenServer::Server objects too, so you can
59
- inspect some of their attributes. The relevant XAPI documentation:
60
-
61
- http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/?c=VM
62
-
63
- Fog::Compute::XenServer::Server attributes and operations usually map to the
64
- ones found in the official Citrix documentation, and they are available at:
65
-
66
- http://rubydoc.info/github/fog/fog/Fog/Compute/XenServer/Server
67
-
68
- and
69
-
70
- https://github.com/fog/fog/blob/master/lib/fog/xenserver/models/compute/server.rb
71
-
72
- ## Server operations and attributes
73
-
74
- Getting server VIFs (virtual network interfaces):
75
-
76
- # http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/?c=VIF
77
- server.networks
78
- # or server.vifs
79
-
80
- Listing the server VBDs (virtual block devices):
81
-
82
- # http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/?c=VBD
83
- server.vbds
84
-
85
-
86
- Get VDIs objects (virtual disk images) attached to the server:
87
-
88
- server.vbds.each do |vbd|
89
- # http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/?c=VDI
90
- vdi = vbd.vdi
91
- # In bytes
92
- puts vdi.virtual_size
93
- puts vdi.physical_utilisation
94
- end
95
-
96
- ## Server creation and life-cycle management
97
-
98
- Creating a new server/VM:
99
-
100
- server = conn.servers.create :name => 'foobar',
101
- :template_name => 'squeeze-test'
102
-
103
- The server is automatically started after that.
104
-
105
- Note that template_name is optional if you have specified the ':template'
106
- parameter when when creating the connection.
107
-
108
- If you don't want to automatically start the server, use 'new' instead of 'create':
109
-
110
- server = conn.servers.new :name => 'foobar',
111
- :template_name => 'squeeze-test'
112
-
113
- and set auto_start to false when saving it:
114
-
115
- server.save :auto_start => false
116
-
117
- Shutting down the server, By forcing it
118
-
119
- server.stop 'hard'
120
- # server.hard_shutdown is equivalent
121
-
122
- Doing a clean shutdown
123
-
124
- server.stop 'clean'
125
- # server.clean_shutdown is equivalent
126
-
127
- And finally, destroy it (it will force a shutdown first if running):
128
-
129
- server.destroy
130
-
131
- # XenServer Host (Dom0) operations
132
-
133
- The are some operations that can be performed on the host, without retrieving
134
- and/or manipulating servers:
135
-
136
- Listing all the VBDs (virtual block devices):
137
-
138
- # http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/?c=VBD
139
- conn.vbds.all
140
-
141
- This will retrieve the list of every single VBD available in the XenServer.
142
-
143
- Same thing applies to the virtual disk images:
144
-
145
- conn.vdis.all
146
-
147
- Listing Storage Repositories (Xen SRs), where the disk images are stored:
148
-
149
- # http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/?c=SR
150
- conn.storage_repositories
151
-
152
-
153
- XenServer Pools:
154
-
155
- # http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/?c=pool
156
- conn.pools
157
-
158
-
159
- Retrieve the default storage repository in a pool:
160
-
161
- conn.pools.first.default_storage_repository
162
- # or the equivalent conn.pools.first.default_sr
163
-