opennebula 5.12.13 → 5.13.80.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/ActionManager.rb +1 -1
- data/lib/CommandManager.rb +1 -1
- data/lib/DriverExecHelper.rb +44 -28
- data/lib/OpenNebulaDriver.rb +8 -4
- data/lib/VirtualMachineDriver.rb +9 -2
- data/lib/cloud/CloudClient.rb +3 -3
- data/lib/datacenter.rb +1258 -0
- data/lib/datastore.rb +1025 -0
- data/lib/distributed_firewall.rb +280 -0
- data/lib/file_helper.rb +370 -0
- data/lib/host.rb +1517 -0
- data/lib/logical_port.rb +50 -0
- data/lib/logical_switch.rb +77 -0
- data/lib/memoize.rb +74 -0
- data/lib/models/role.rb +39 -8
- data/lib/models/service.rb +92 -31
- data/lib/models.rb +5 -5
- data/lib/network.rb +635 -0
- data/lib/nsx_client.rb +144 -0
- data/lib/nsx_component.rb +28 -0
- data/lib/nsx_constants.rb +149 -0
- data/lib/nsx_driver.rb +78 -0
- data/lib/nsx_error.rb +77 -0
- data/lib/nsx_rule.rb +193 -0
- data/lib/nsxt_client.rb +176 -0
- data/lib/nsxt_dfw.rb +196 -0
- data/lib/nsxt_logical_port.rb +94 -0
- data/lib/nsxt_rule.rb +188 -0
- data/lib/nsxt_tz.rb +38 -0
- data/lib/nsxv_client.rb +176 -0
- data/lib/nsxv_dfw.rb +202 -0
- data/lib/nsxv_logical_port.rb +107 -0
- data/lib/nsxv_rule.rb +172 -0
- data/lib/nsxv_tz.rb +41 -0
- data/lib/opaque_network.rb +134 -0
- data/lib/opennebula/acl.rb +1 -1
- data/lib/opennebula/acl_pool.rb +1 -1
- data/lib/opennebula/client.rb +1 -1
- data/lib/opennebula/cluster.rb +1 -1
- data/lib/opennebula/cluster_pool.rb +1 -1
- data/lib/opennebula/datastore.rb +1 -1
- data/lib/opennebula/datastore_pool.rb +1 -1
- data/lib/opennebula/document.rb +8 -29
- data/lib/opennebula/document_json.rb +42 -12
- data/lib/opennebula/document_pool.rb +1 -1
- data/lib/opennebula/document_pool_json.rb +1 -1
- data/lib/opennebula/error.rb +4 -1
- data/lib/opennebula/flow/grammar.rb +1195 -0
- data/lib/{models → opennebula/flow}/service_pool.rb +26 -2
- data/lib/{models → opennebula/flow}/service_template.rb +86 -17
- data/lib/opennebula/flow/service_template_ext.rb +84 -0
- data/lib/{models → opennebula/flow}/service_template_pool.rb +1 -1
- data/lib/opennebula/flow/validator.rb +499 -0
- data/lib/opennebula/flow.rb +23 -0
- data/lib/opennebula/group.rb +1 -1
- data/lib/opennebula/group_pool.rb +1 -1
- data/lib/opennebula/hook.rb +5 -12
- data/lib/opennebula/hook_log.rb +1 -1
- data/lib/opennebula/hook_pool.rb +1 -1
- data/lib/opennebula/host.rb +1 -1
- data/lib/opennebula/host_pool.rb +1 -1
- data/lib/opennebula/image.rb +17 -14
- data/lib/opennebula/image_pool.rb +1 -1
- data/lib/opennebula/ldap_auth.rb +1 -1
- data/lib/opennebula/ldap_auth_spec.rb +1 -1
- data/lib/opennebula/lockable_ext.rb +163 -0
- data/lib/opennebula/marketplace.rb +1 -1
- data/lib/opennebula/marketplace_pool.rb +1 -1
- data/lib/opennebula/marketplaceapp.rb +9 -119
- data/lib/opennebula/marketplaceapp_ext.rb +522 -0
- data/lib/opennebula/marketplaceapp_pool.rb +1 -1
- data/lib/opennebula/oneflow_client.rb +4 -3
- data/lib/opennebula/pool.rb +4 -3
- data/lib/opennebula/pool_element.rb +1 -1
- data/lib/opennebula/security_group.rb +1 -1
- data/lib/opennebula/security_group_pool.rb +1 -1
- data/lib/opennebula/server_cipher_auth.rb +1 -1
- data/lib/opennebula/server_x509_auth.rb +1 -1
- data/lib/opennebula/ssh_auth.rb +1 -1
- data/lib/opennebula/system.rb +1 -1
- data/lib/opennebula/template.rb +4 -13
- data/lib/opennebula/template_ext.rb +325 -0
- data/lib/opennebula/template_pool.rb +1 -1
- data/lib/opennebula/user.rb +26 -2
- data/lib/opennebula/user_pool.rb +1 -1
- data/lib/opennebula/utils.rb +1 -1
- data/lib/opennebula/vdc.rb +1 -1
- data/lib/opennebula/vdc_pool.rb +1 -1
- data/lib/opennebula/virtual_machine.rb +25 -207
- data/lib/opennebula/virtual_machine_ext.rb +469 -0
- data/lib/opennebula/virtual_machine_pool.rb +1 -5
- data/lib/opennebula/virtual_network.rb +4 -10
- data/lib/opennebula/virtual_network_pool.rb +1 -1
- data/lib/opennebula/virtual_router.rb +4 -12
- data/lib/opennebula/virtual_router_pool.rb +1 -1
- data/lib/opennebula/vm_group.rb +4 -11
- data/lib/opennebula/vm_group_pool.rb +1 -1
- data/lib/opennebula/vntemplate.rb +4 -13
- data/lib/opennebula/vntemplate_pool.rb +1 -1
- data/lib/opennebula/wait_ext.rb +222 -0
- data/lib/opennebula/x509_auth.rb +1 -1
- data/lib/opennebula/xml_element.rb +1 -1
- data/lib/opennebula/xml_pool.rb +1 -1
- data/lib/opennebula/xml_utils.rb +1 -1
- data/lib/opennebula/zone.rb +1 -1
- data/lib/opennebula/zone_pool.rb +1 -1
- data/lib/opennebula.rb +5 -2
- data/lib/rest_client.rb +201 -0
- data/lib/scripts_common.rb +180 -0
- data/lib/transport_zone.rb +43 -0
- data/lib/vcenter_driver.rb +9 -22
- data/lib/vcenter_importer.rb +616 -0
- data/lib/vi_client.rb +281 -0
- data/lib/vi_helper.rb +312 -0
- data/lib/virtual_machine.rb +3477 -0
- data/lib/virtual_wire.rb +158 -0
- data/lib/vm_device.rb +80 -0
- data/lib/vm_disk.rb +202 -0
- data/lib/vm_folder.rb +69 -0
- data/lib/vm_helper.rb +30 -0
- data/lib/vm_monitor.rb +303 -0
- data/lib/vm_nic.rb +70 -0
- data/lib/vm_template.rb +1961 -0
- data/lib/vmm_importer.rb +121 -0
- metadata +101 -35
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -14,6 +14,7 @@
|
|
14
14
|
# limitations under the License. #
|
15
15
|
#--------------------------------------------------------------------------- #
|
16
16
|
|
17
|
+
require 'opennebula/lockable_ext'
|
17
18
|
require 'opennebula/pool_element'
|
18
19
|
|
19
20
|
module OpenNebula
|
@@ -123,6 +124,9 @@ module OpenNebula
|
|
123
124
|
DISK_RESIZE_POWEROFF
|
124
125
|
DISK_RESIZE_UNDEPLOYED
|
125
126
|
HOTPLUG_NIC_POWEROFF
|
127
|
+
HOTPLUG_RESIZE
|
128
|
+
HOTPLUG_SAVEAS_UNDEPLOYED
|
129
|
+
HOTPLUG_SAVEAS_STOPPED
|
126
130
|
}
|
127
131
|
|
128
132
|
SHORT_VM_STATES={
|
@@ -204,7 +208,10 @@ module OpenNebula
|
|
204
208
|
"DISK_RESIZE" => "drsz",
|
205
209
|
"DISK_RESIZE_POWEROFF" => "drsz",
|
206
210
|
"DISK_RESIZE_UNDEPLOYED" => "drsz",
|
207
|
-
"HOTPLUG_NIC_POWEROFF" => "hotp"
|
211
|
+
"HOTPLUG_NIC_POWEROFF" => "hotp",
|
212
|
+
"HOTPLUG_RESIZE" => "hotp",
|
213
|
+
"HOTPLUG_SAVEAS_UNDEPLOYED" => "hotp",
|
214
|
+
"HOTPLUG_SAVEAS_STOPPED" => "hotp"
|
208
215
|
}
|
209
216
|
|
210
217
|
HISTORY_ACTION=%w{none migrate live-migrate shutdown shutdown-hard
|
@@ -271,6 +278,8 @@ module OpenNebula
|
|
271
278
|
|
272
279
|
# Class constructor
|
273
280
|
def initialize(xml, client)
|
281
|
+
LockableExt.make_lockable(self, VM_METHODS)
|
282
|
+
|
274
283
|
super(xml,client)
|
275
284
|
end
|
276
285
|
|
@@ -701,9 +710,9 @@ module OpenNebula
|
|
701
710
|
end
|
702
711
|
end
|
703
712
|
|
704
|
-
|
705
|
-
|
706
|
-
|
713
|
+
# Changes the attributes of a VM in power off, failure and undeploy
|
714
|
+
# states
|
715
|
+
# @param new_conf, string describing the new attributes. Each attribute
|
707
716
|
# will replace the existing ones or delete it if empty. Attributes that
|
708
717
|
# can be updated are: INPUT/{TYPE, BUS}; RAW/{TYPE, DATA, DATA_VMX},
|
709
718
|
# OS/{BOOT, BOOTLOADER, ARCH, MACHINE, KERNEL, INITRD},
|
@@ -711,20 +720,10 @@ module OpenNebula
|
|
711
720
|
# and GRAPHICS/{TYPE, LISTEN, PASSWD, KEYMAP}
|
712
721
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
713
722
|
# otherwise
|
714
|
-
|
723
|
+
def updateconf(new_conf)
|
715
724
|
return call(VM_METHODS[:updateconf], @pe_id, new_conf)
|
716
725
|
end
|
717
726
|
|
718
|
-
# Lock a VM
|
719
|
-
def lock(level)
|
720
|
-
return call(VM_METHODS[:lock], @pe_id, level)
|
721
|
-
end
|
722
|
-
|
723
|
-
# Unlock a VM
|
724
|
-
def unlock()
|
725
|
-
return call(VM_METHODS[:unlock], @pe_id)
|
726
|
-
end
|
727
|
-
|
728
727
|
########################################################################
|
729
728
|
# Helpers to get VirtualMachine information
|
730
729
|
########################################################################
|
@@ -771,205 +770,24 @@ module OpenNebula
|
|
771
770
|
self['DEPLOY_ID']
|
772
771
|
end
|
773
772
|
|
774
|
-
|
775
|
-
|
776
|
-
#
|
777
|
-
# @param name [String] Name for the new Template
|
778
|
-
# @param name [true,false,nil] Optional, true to make the saved images
|
779
|
-
# persistent, false make them non-persistent
|
780
|
-
#
|
781
|
-
# @return [Integer, OpenNebula::Error] the new Template ID in case of
|
782
|
-
# success, error otherwise
|
783
|
-
REMOVE_VNET_ATTRS = %w{AR_ID BRIDGE CLUSTER_ID IP MAC TARGET NIC_ID
|
784
|
-
NETWORK_ID VN_MAD SECURITY_GROUPS VLAN_ID}
|
785
|
-
|
786
|
-
REMOVE_IMAGE_ATTRS = %w{DEV_PREFIX SOURCE ORIGINAL_SIZE SIZE
|
787
|
-
DISK_SNAPSHOT_TOTAL_SIZE DRIVER IMAGE_STATE SAVE CLONE READONLY
|
788
|
-
PERSISTENT TARGET ALLOW_ORPHANS CLONE_TARGET CLUSTER_ID DATASTORE
|
789
|
-
DATASTORE_ID DISK_ID DISK_TYPE IMAGE_ID IMAGE IMAGE_UNAME IMAGE_UID
|
790
|
-
LN_TARGET TM_MAD TYPE OPENNEBULA_MANAGED}
|
791
|
-
|
792
|
-
def save_as_template(name,description, persistent=nil)
|
793
|
-
img_ids = []
|
794
|
-
new_tid = nil
|
795
|
-
begin
|
796
|
-
rc = info()
|
797
|
-
raise if OpenNebula.is_error?(rc)
|
798
|
-
|
799
|
-
tid = self['TEMPLATE/TEMPLATE_ID']
|
800
|
-
if tid.nil? || tid.empty?
|
801
|
-
rc = Error.new('VM has no template to be saved')
|
802
|
-
raise
|
803
|
-
end
|
804
|
-
|
805
|
-
if state_str() != "POWEROFF"
|
806
|
-
rc = Error.new("VM state must be POWEROFF, "<<
|
807
|
-
"current state is #{state_str()}, #{lcm_state_str()}")
|
808
|
-
raise
|
809
|
-
end
|
810
|
-
|
811
|
-
# Clone the source template
|
812
|
-
rc = OpenNebula::Template.new_with_id(tid, @client).clone(name)
|
813
|
-
raise if OpenNebula.is_error?(rc)
|
814
|
-
|
815
|
-
new_tid = rc
|
773
|
+
def wait_state(state, timeout=120)
|
774
|
+
extend OpenNebula::WaitExt
|
816
775
|
|
817
|
-
|
818
|
-
replace = ""
|
819
|
-
if !description.nil?
|
820
|
-
replace << "DESCRIPTION = \"#{description}\"\n"
|
821
|
-
end
|
822
|
-
cpu = self['TEMPLATE/CPU']
|
823
|
-
if !cpu.nil? && !cpu.empty?
|
824
|
-
replace << "CPU = #{cpu}\n"
|
825
|
-
end
|
776
|
+
rc = wait2(state, 'LCM_INIT', timeout)
|
826
777
|
|
827
|
-
|
828
|
-
if !vcpu.nil? && !vcpu.empty?
|
829
|
-
replace << "VCPU = #{vcpu}\n"
|
830
|
-
end
|
831
|
-
|
832
|
-
mem = self['TEMPLATE/MEMORY']
|
833
|
-
if !mem.nil? && !mem.empty?
|
834
|
-
replace << "MEMORY = #{mem}\n"
|
835
|
-
end
|
778
|
+
return Error.new("Timeout expired for state #{state}.") unless rc
|
836
779
|
|
837
|
-
|
838
|
-
# While the previous snapshot is still in progress, we wait
|
839
|
-
# indefinitely
|
840
|
-
rc = info()
|
841
|
-
raise if OpenNebula.is_error?(rc)
|
842
|
-
|
843
|
-
steps = 0
|
844
|
-
while lcm_state_str() == "HOTPLUG_SAVEAS_POWEROFF"
|
845
|
-
if steps < 30
|
846
|
-
sleep 1
|
847
|
-
else
|
848
|
-
sleep 15
|
849
|
-
end
|
850
|
-
|
851
|
-
rc = info()
|
852
|
-
raise if OpenNebula.is_error?(rc)
|
853
|
-
|
854
|
-
steps += 1
|
855
|
-
end
|
856
|
-
|
857
|
-
# If the VM is not busy with a previous disk snapshot, we wait
|
858
|
-
# but this time with a timeout
|
859
|
-
rc = wait_state("POWEROFF")
|
860
|
-
raise if OpenNebula.is_error?(rc)
|
861
|
-
|
862
|
-
disk_id = disk["DISK_ID"]
|
863
|
-
if disk_id.nil? || disk_id.empty?
|
864
|
-
rc = Error.new('The DISK_ID is missing from the VM template')
|
865
|
-
raise
|
866
|
-
end
|
867
|
-
|
868
|
-
image_id = disk["IMAGE_ID"]
|
869
|
-
opennebula_managed = disk["OPENNEBULA_MANAGED"]
|
870
|
-
type = disk["TYPE"]
|
871
|
-
|
872
|
-
REMOVE_IMAGE_ATTRS.each do |attr|
|
873
|
-
disk.delete_element(attr)
|
874
|
-
end
|
875
|
-
|
876
|
-
if !image_id.nil? && !image_id.empty?
|
877
|
-
if type == 'CDROM'
|
878
|
-
replace << "DISK = [ IMAGE_ID = #{image_id}"
|
879
|
-
if opennebula_managed
|
880
|
-
replace << ", OPENNEBULA_MANAGED=#{opennebula_managed}"
|
881
|
-
end
|
882
|
-
replace << " ]\n"
|
883
|
-
else
|
884
|
-
rc = disk_saveas(disk_id.to_i,"#{name}-disk-#{disk_id}","",-1)
|
885
|
-
|
886
|
-
raise if OpenNebula.is_error?(rc)
|
887
|
-
|
888
|
-
if persistent == true
|
889
|
-
OpenNebula::Image.new_with_id(rc.to_i, @client).persistent()
|
890
|
-
end
|
891
|
-
|
892
|
-
img_ids << rc.to_i
|
893
|
-
|
894
|
-
disk_template = disk.template_like_str(".").tr("\n", ",\n")
|
895
|
-
|
896
|
-
if disk_template.empty?
|
897
|
-
replace << "DISK = [ IMAGE_ID = #{rc} ] \n"
|
898
|
-
else
|
899
|
-
replace << "DISK = [ IMAGE_ID = #{rc}, " <<
|
900
|
-
disk_template << " ] \n"
|
901
|
-
end
|
902
|
-
end
|
903
|
-
else
|
904
|
-
# Volatile disks cannot be saved, so the definition is copied
|
905
|
-
replace << self.template_like_str(
|
906
|
-
"TEMPLATE", true, "DISK[DISK_ID=#{disk_id}]") << "\n"
|
907
|
-
end
|
908
|
-
end
|
909
|
-
|
910
|
-
self.each('TEMPLATE/NIC') do |nic|
|
911
|
-
nic_id = nic["NIC_ID"]
|
912
|
-
|
913
|
-
if nic_id.nil? || nic_id.empty?
|
914
|
-
rc = Error.new('The NIC_ID is missing from the VM template')
|
915
|
-
raise
|
916
|
-
end
|
917
|
-
|
918
|
-
REMOVE_VNET_ATTRS.each do |attr|
|
919
|
-
# Remove every automatically generated value
|
920
|
-
# The vnet will be referenced via NAME + UNAME (if defined)
|
921
|
-
nic.delete_element(attr)
|
922
|
-
end
|
923
|
-
|
924
|
-
replace << "NIC = [ " << nic.template_like_str(".").tr("\n", ",\n") << " ] \n"
|
925
|
-
end
|
926
|
-
|
927
|
-
# Required by the Sunstone Cloud View
|
928
|
-
replace << "SAVED_TEMPLATE_ID = #{tid}\n"
|
929
|
-
|
930
|
-
new_tmpl = OpenNebula::Template.new_with_id(new_tid, @client)
|
931
|
-
|
932
|
-
rc = new_tmpl.update(replace, true)
|
933
|
-
raise if OpenNebula.is_error?(rc)
|
934
|
-
|
935
|
-
return new_tid
|
936
|
-
|
937
|
-
rescue
|
938
|
-
# Rollback. Delete the template and the images created
|
939
|
-
if !new_tid.nil?
|
940
|
-
new_tmpl = OpenNebula::Template.new_with_id(new_tid, @client)
|
941
|
-
new_tmpl.delete()
|
942
|
-
end
|
943
|
-
|
944
|
-
img_ids.each do |id|
|
945
|
-
img = OpenNebula::Image.new_with_id(id, @client)
|
946
|
-
img.delete()
|
947
|
-
end
|
948
|
-
|
949
|
-
return rc
|
950
|
-
end
|
780
|
+
true
|
951
781
|
end
|
952
782
|
|
953
|
-
def
|
954
|
-
|
955
|
-
lcm_state = ""
|
783
|
+
def wait_state2(state, lcm_state, timeout=120)
|
784
|
+
extend OpenNebula::WaitExt
|
956
785
|
|
957
|
-
timeout
|
958
|
-
rc = info()
|
959
|
-
return rc if OpenNebula.is_error?(rc)
|
960
|
-
|
961
|
-
vm_state = state_str()
|
962
|
-
lcm_state = lcm_state_str()
|
963
|
-
|
964
|
-
if vm_state == state
|
965
|
-
return true
|
966
|
-
end
|
786
|
+
rc = wait2(state, lcm_state, timeout)
|
967
787
|
|
968
|
-
|
969
|
-
end
|
788
|
+
return Error.new("Timeout expired for state #{state}.") unless rc
|
970
789
|
|
971
|
-
|
972
|
-
"VM is in state #{vm_state}, #{lcm_state}")
|
790
|
+
true
|
973
791
|
end
|
974
792
|
|
975
793
|
private
|