mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-23 21:27:10 +09:00
Merge branch 'feature-4913' of github.com:OpenNebula/one into feature-4913
This commit is contained in:
commit
3220c468bc
10 files changed
+60
-80
No files matched your search
@@ -739,7 +739,8 @@ class ExecDriver < VirtualMachineDriver
|
||||
id,
|
||||
host,
|
||||
ACTION[:snapshot_create],
|
||||
:script_name => "snapshot_create")
|
||||
:script_name => "snapshot_create",
|
||||
:stdin => xml_data)
|
||||
end
|
||||
|
||||
#
|
||||
@@ -895,7 +896,7 @@ class ExecDriver < VirtualMachineDriver
|
||||
{
|
||||
:driver => :vmm,
|
||||
:action => :attach_nic,
|
||||
:parameters => [:deploy_id, mac, source, model, vn_mad, target, xml_data]
|
||||
:parameters => [:deploy_id, mac, source, model, vn_mad, target]
|
||||
},
|
||||
# Execute post-boot networking setup
|
||||
{
|
||||
|
||||
@@ -16,5 +16,4 @@
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
||||
exit 0
|
||||
+23
-17
@@ -1,20 +1,26 @@
|
||||
#!/usr/bin/env ruby
|
||||
#!/bin/bash
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2016, OpenNebula Project, OpenNebula Systems #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2016, OpenNebula Project, OpenNebula Systems #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
exit(0)
|
||||
script_name=$(basename $0)
|
||||
|
||||
source $(dirname $0)/../../scripts_common.sh
|
||||
|
||||
error_message "$script_name: Operation not supported"
|
||||
|
||||
exit 1
|
||||
|
||||
@@ -1007,12 +1007,12 @@ class VirtualMachine
|
||||
end
|
||||
|
||||
# Create a snapshot for the VM
|
||||
def create_snapshot(snapshot_name, vm_ref)
|
||||
def create_snapshot(snap_id, snap_name)
|
||||
snapshot_hash = {
|
||||
:name => snapshot_name,
|
||||
:description => "OpenNebula Snapshot of VM #{vm_ref}",
|
||||
:memory => true,
|
||||
:quiesce => true
|
||||
:name => snap_id,
|
||||
:description => snap_name,
|
||||
:memory => true,
|
||||
:quiesce => true
|
||||
}
|
||||
|
||||
begin
|
||||
@@ -1021,14 +1021,14 @@ class VirtualMachine
|
||||
raise "Cannot create snapshot for VM: #{e.message}\n#{e.backtrace}"
|
||||
end
|
||||
|
||||
return snapshot_name
|
||||
return snap_id
|
||||
end
|
||||
|
||||
# Revert to a VM snapshot
|
||||
def revert_snapshot(snapshot_name)
|
||||
def revert_snapshot(snap_id)
|
||||
|
||||
snapshot_list = self["snapshot.rootSnapshotList"]
|
||||
snapshot = find_snapshot_in_list(snapshot_list, snapshot_name)
|
||||
snapshot = find_snapshot_in_list(snapshot_list, snap_id)
|
||||
|
||||
return nil if !snapshot
|
||||
|
||||
@@ -1041,10 +1041,10 @@ class VirtualMachine
|
||||
end
|
||||
|
||||
# Delete VM snapshot
|
||||
def delete_snapshot(snapshot_name)
|
||||
def delete_snapshot(snap_id)
|
||||
|
||||
snapshot_list = self["snapshot.rootSnapshotList"]
|
||||
snapshot = find_snapshot_in_list(snapshot_list, snapshot_name)
|
||||
snapshot = find_snapshot_in_list(snapshot_list, snap_id)
|
||||
|
||||
return nil if !snapshot
|
||||
|
||||
@@ -1059,12 +1059,12 @@ class VirtualMachine
|
||||
end
|
||||
end
|
||||
|
||||
def find_snapshot_in_list(list, snapshot_name)
|
||||
def find_snapshot_in_list(list, snap_id)
|
||||
list.each do |i|
|
||||
if i.name == snapshot_name
|
||||
if i.name == snap_id.to_s
|
||||
return i.snapshot
|
||||
elsif !i.childSnapshotList.empty?
|
||||
snap = find_snapshot(i.childSnapshotList, snapshot_name)
|
||||
snap = find_snapshot(i.childSnapshotList, snap_id)
|
||||
return snap if snap
|
||||
end
|
||||
end rescue nil
|
||||
|
||||
@@ -33,11 +33,12 @@ vm_ref = ARGV[0]
|
||||
mac = ARGV[1]
|
||||
bridge = ARGV[2]
|
||||
model = ARGV[3]
|
||||
xml_data = ARGV[4]
|
||||
vc_cluster_name = ARGV[-1]
|
||||
|
||||
drv_action = OpenNebula::XMLElement.new
|
||||
drv_action.initialize_xml(xml_data, 'VM')
|
||||
drv_action.initialize_xml(Base64.decode64(STDIN.read), 'VMM_DRIVER_ACTION_DATA')
|
||||
|
||||
vm_xml = drv_action.retrieve_xmlelements("VM").first
|
||||
|
||||
host = VCenterDriver::VIHelper.find_by_name(OpenNebula::HostPool, vc_cluster_name)
|
||||
host_id = host['ID']
|
||||
@@ -47,13 +48,13 @@ begin
|
||||
|
||||
vm = VCenterDriver::VirtualMachine.new_from_ref(vm_ref, vi_client)
|
||||
|
||||
# Setting one_item with info with xml_data including NIC to be added
|
||||
vm.one_item = drv_action
|
||||
# Setting one_item with info with the vm_xml including NIC to be added
|
||||
vm.one_item = vm_xml
|
||||
|
||||
nic = {
|
||||
"MAC" => mac,
|
||||
"MAC" => mac,
|
||||
"BRIDGE" => bridge,
|
||||
"MODEL" => model
|
||||
"MODEL" => model
|
||||
}
|
||||
|
||||
vm.attach_nic(nic)
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2017, OpenNebula Project, OpenNebula Systems #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
ONE_LOCATION=ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
|
||||
|
||||
if !ONE_LOCATION
|
||||
RUBY_LIB_LOCATION="/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION)
|
||||
else
|
||||
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" if !defined?(RUBY_LIB_LOCATION)
|
||||
end
|
||||
|
||||
$: << RUBY_LIB_LOCATION
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'vcenter_driver2'
|
||||
|
||||
# Not supported
|
||||
STDERR.puts "Migrate action is not supportef for vCenter"
|
||||
exit -1
|
||||
+1
@@ -0,0 +1 @@
|
||||
../common/not_supported.sh
|
||||
@@ -0,0 +1 @@
|
||||
../common/dummy.sh
|
||||
@@ -30,18 +30,23 @@ $: << File.dirname(__FILE__)
|
||||
require 'vcenter_driver2'
|
||||
|
||||
vm_ref = ARGV[0]
|
||||
snapshot_name = ARGV[1]
|
||||
snap_id = ARGV[1]
|
||||
vc_cluster_name = ARGV[3]
|
||||
|
||||
drv_action = OpenNebula::XMLElement.new
|
||||
drv_action.initialize_xml(Base64.decode64(STDIN.read), 'VMM_DRIVER_ACTION_DATA')
|
||||
|
||||
host = VCenterDriver::VIHelper.find_by_name(OpenNebula::HostPool, vc_cluster_name)
|
||||
host_id = host['ID']
|
||||
|
||||
snap_name = drv_action["VM/TEMPLATE/SNAPSHOT[ACTIVE='YES']/NAME"]
|
||||
|
||||
begin
|
||||
vi_client = VCenterDriver::VIClient.new_from_host(host_id)
|
||||
|
||||
vm = VCenterDriver::VirtualMachine.new_from_ref(vm_ref, vi_client)
|
||||
|
||||
vm.create_snapshot(snapshot_name, vm_ref)
|
||||
vm.create_snapshot(snap_id, snap_name)
|
||||
|
||||
rescue Exception => e
|
||||
STDERR.puts "Snapshot of VM #{vm_ref} on vCenter cluster "\
|
||||
|
||||
@@ -30,7 +30,7 @@ $: << File.dirname(__FILE__)
|
||||
require 'vcenter_driver2'
|
||||
|
||||
vm_ref = ARGV[0]
|
||||
snapshot_name = ARGV[1]
|
||||
snap_id = ARGV[1]
|
||||
vc_cluster_name = ARGV[3]
|
||||
|
||||
host = VCenterDriver::VIHelper.find_by_name(OpenNebula::HostPool, vc_cluster_name)
|
||||
@@ -41,7 +41,7 @@ begin
|
||||
|
||||
vm = VCenterDriver::VirtualMachine.new_from_ref(vm_ref, vi_client)
|
||||
|
||||
vm.delete_snapshot(snapshot_name)
|
||||
vm.delete_snapshot(snap_id)
|
||||
|
||||
rescue Exception => e
|
||||
STDERR.puts "Snapshot of VM #{vm_ref} on vCenter cluster "\
|
||||
|
||||
@@ -30,7 +30,7 @@ $: << File.dirname(__FILE__)
|
||||
require 'vcenter_driver2'
|
||||
|
||||
vm_ref = ARGV[0]
|
||||
snapshot_name = ARGV[1]
|
||||
snap_id = ARGV[1]
|
||||
vc_cluster_name = ARGV[3]
|
||||
|
||||
host = VCenterDriver::VIHelper.find_by_name(OpenNebula::HostPool, vc_cluster_name)
|
||||
@@ -41,7 +41,7 @@ begin
|
||||
|
||||
vm = VCenterDriver::VirtualMachine.new_from_ref(vm_ref, vi_client)
|
||||
|
||||
vm.revert_snapshot(snapshot_name)
|
||||
vm.revert_snapshot(snap_id)
|
||||
|
||||
rescue Exception => e
|
||||
STDERR.puts "Snapshot of VM #{vm_ref} on vCenter cluster "\
|
||||
|
||||
Reference in new issue
Block a user