mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-15 05:57:23 +03:00
Feature #1224: add vmware drivers
This commit is contained in:
parent
1e23b81fe5
commit
4296c5e61d
@ -1,22 +1,41 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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 2010-2013, C12G Labs S.L #
|
||||
# #
|
||||
# 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. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
source $(dirname $0)/../../scripts_common.sh
|
||||
ONE_LOCATION=ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
|
||||
|
||||
log_error "Snapshotting is not yet supported for VMware."
|
||||
exit 1
|
||||
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 'vmware_driver'
|
||||
|
||||
deploy_id = ARGV[0]
|
||||
snapshot_id = ARGV[1]
|
||||
host = ARGV[3]
|
||||
|
||||
vmware_drv = VMwareDriver.new(host)
|
||||
|
||||
hypervisor_id = vmware_drv.snapshot_create(deploy_id, snapshot_id)
|
||||
|
||||
puts hypervisor_id
|
||||
exit 0
|
||||
|
@ -1,22 +1,38 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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 2010-2013, C12G Labs S.L #
|
||||
# #
|
||||
# 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. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
source $(dirname $0)/../../scripts_common.sh
|
||||
ONE_LOCATION=ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
|
||||
|
||||
log_error "Snapshotting is not yet supported for VMware."
|
||||
exit 1
|
||||
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 'vmware_driver'
|
||||
|
||||
deploy_id = ARGV[0]
|
||||
snapshot_id = ARGV[1]
|
||||
host = ARGV[3]
|
||||
|
||||
vmware_drv = VMwareDriver.new(host)
|
||||
|
||||
vmware_drv.snapshot_delete(deploy_id, snapshot_id)
|
||||
|
@ -1,22 +1,38 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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 2010-2013, C12G Labs S.L #
|
||||
# #
|
||||
# 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. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
source $(dirname $0)/../../scripts_common.sh
|
||||
ONE_LOCATION=ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
|
||||
|
||||
log_error "Snapshotting is not yet supported for VMware."
|
||||
exit 1
|
||||
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 'vmware_driver'
|
||||
|
||||
deploy_id = ARGV[0]
|
||||
snapshot_id = ARGV[1]
|
||||
host = ARGV[3]
|
||||
|
||||
vmware_drv = VMwareDriver.new(host)
|
||||
|
||||
vmware_drv.snapshot_revert(deploy_id, snapshot_id)
|
||||
|
@ -262,6 +262,42 @@ class VMwareDriver
|
||||
undefine_domain(deploy_id)
|
||||
end
|
||||
|
||||
# ------------------------------------------------------------------------ #
|
||||
# Creates a new system snapshot #
|
||||
# ------------------------------------------------------------------------ #
|
||||
def snapshot_create(deploy_id, snapshot_id = nil)
|
||||
rc, info = do_action(
|
||||
"virsh -c #{@uri} snapshot-create-as #{deploy_id} #{snapshot_id}")
|
||||
|
||||
exit info if rc == false
|
||||
|
||||
hypervisor_id = info.split[2]
|
||||
|
||||
return hypervisor_id
|
||||
end
|
||||
|
||||
# ------------------------------------------------------------------------ #
|
||||
# Delete a system snapshot #
|
||||
# ------------------------------------------------------------------------ #
|
||||
def snapshot_delete(deploy_id, snapshot_id)
|
||||
rc, info = do_action(
|
||||
"virsh -c #{@uri} snapshot-delete #{deploy_id} #{snapshot_id}")
|
||||
|
||||
exit info if rc == false
|
||||
end
|
||||
|
||||
# ------------------------------------------------------------------------ #
|
||||
# Revert to a system snapshot #
|
||||
# ------------------------------------------------------------------------ #
|
||||
def snapshot_revert(deploy_id, snapshot_id)
|
||||
action = "virsh -c #{@uri} snapshot-revert " <<
|
||||
"--force #{deploy_id} #{snapshot_id}")
|
||||
|
||||
rc, info = do_action(action)
|
||||
|
||||
exit info if rc == false
|
||||
end
|
||||
|
||||
# ######################################################################## #
|
||||
# DRIVER HELPER FUNCTIONS #
|
||||
# ######################################################################## #
|
||||
|
Loading…
x
Reference in New Issue
Block a user