mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-04 17:47:00 +03:00
Merge branch 'master' of git.opennebula.org:one
This commit is contained in:
commit
303407ccc6
@ -48,6 +48,15 @@ public:
|
||||
return ds_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the DATASTORE_LOCATION for the hosts of the cluster. If not
|
||||
* defined that in oned.conf is returned.
|
||||
*
|
||||
* @param ds_location string to copy the DATASTORE_LOCATION to
|
||||
* @return DATASTORE_LOCATION
|
||||
*/
|
||||
string& get_ds_location(string &ds_location);
|
||||
|
||||
// *************************************************************************
|
||||
// Object Collections (Public)
|
||||
// *************************************************************************
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
const string& vmm,
|
||||
const string& vnm,
|
||||
const string& tmm,
|
||||
const string& ds_location,
|
||||
int ds_id,
|
||||
const string& vm_info);
|
||||
|
||||
@ -73,7 +74,7 @@ private:
|
||||
// DataBase implementation variables
|
||||
// ----------------------------------------
|
||||
static const char * table;
|
||||
|
||||
|
||||
static const char * db_names;
|
||||
|
||||
static const char * db_bootstrap;
|
||||
@ -93,6 +94,7 @@ private:
|
||||
string vnm_mad_name;
|
||||
string tm_mad_name;
|
||||
|
||||
string ds_location;
|
||||
int ds_id;
|
||||
|
||||
time_t stime;
|
||||
@ -122,6 +124,7 @@ private:
|
||||
// Remote paths
|
||||
string checkpoint_file;
|
||||
string rdeployment_file;
|
||||
string rsystem_dir;
|
||||
|
||||
/**
|
||||
* Writes the history record in the DB
|
||||
|
@ -48,17 +48,23 @@ protected:
|
||||
virtual void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) = 0;
|
||||
|
||||
bool vm_authorization(int id,
|
||||
bool vm_authorization(int id,
|
||||
ImageTemplate * tmpl,
|
||||
VirtualMachineTemplate* vtmpl,
|
||||
RequestAttributes& att,
|
||||
PoolObjectAuth * host_perms,
|
||||
RequestAttributes& att,
|
||||
PoolObjectAuth * host_perms,
|
||||
PoolObjectAuth * ds_perm,
|
||||
AuthRequest::Operation op);
|
||||
|
||||
int get_host_information(int hid, string& name, string& vmm, string& vnm,
|
||||
string& tm, int& ds_id, RequestAttributes& att,
|
||||
PoolObjectAuth& host_perms);
|
||||
int get_host_information(int hid,
|
||||
string& name,
|
||||
string& vmm,
|
||||
string& vnm,
|
||||
string& tm,
|
||||
string& ds_location,
|
||||
int& ds_id,
|
||||
RequestAttributes& att,
|
||||
PoolObjectAuth& host_perms);
|
||||
|
||||
int add_history(VirtualMachine * vm,
|
||||
int hid,
|
||||
@ -66,6 +72,7 @@ protected:
|
||||
const string& vmm_mad,
|
||||
const string& vnm_mad,
|
||||
const string& tm_mad,
|
||||
const string& ds_location,
|
||||
int ds_id,
|
||||
RequestAttributes& att);
|
||||
|
||||
|
@ -225,7 +225,10 @@ public:
|
||||
* disks for a running VM in the target host.
|
||||
* @return the remote system directory for the VM
|
||||
*/
|
||||
string get_remote_system_dir() const;
|
||||
const string& get_remote_system_dir() const
|
||||
{
|
||||
return history->rsystem_dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the local VM directory. The VM local dir is in the form:
|
||||
@ -246,6 +249,7 @@ public:
|
||||
const string& vmm_mad,
|
||||
const string& vnm_mad,
|
||||
const string& tm_mad,
|
||||
const string& ds_location,
|
||||
int ds_id);
|
||||
|
||||
/**
|
||||
@ -338,7 +342,7 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the datastore ID of the system DS for the previous host.
|
||||
* Returns the datastore ID of the system DS for the previous host.
|
||||
* The hasPreviousHistory() function MUST be called before this one.
|
||||
* @return the TM mad name
|
||||
*/
|
||||
@ -347,7 +351,7 @@ public:
|
||||
ostringstream oss;
|
||||
|
||||
oss << previous_history->ds_id;
|
||||
|
||||
|
||||
return oss.str();
|
||||
};
|
||||
|
||||
@ -490,7 +494,7 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets VM info (with monitoring info) in the history record
|
||||
* Sets VM info (with monitoring info) in the history record
|
||||
*/
|
||||
void set_vm_info()
|
||||
{
|
||||
@ -498,7 +502,7 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets VM info (with monitoring info) in the previous history record
|
||||
* Sets VM info (with monitoring info) in the previous history record
|
||||
*/
|
||||
void set_previous_vm_info()
|
||||
{
|
||||
@ -615,7 +619,7 @@ public:
|
||||
* @return 0 on success.
|
||||
*/
|
||||
int parse_template_attribute(const string& attribute, string& parsed);
|
||||
|
||||
|
||||
/**
|
||||
* Factory method for virtual machine templates
|
||||
*/
|
||||
@ -766,7 +770,7 @@ public:
|
||||
* @param img_id ID of the image this disk will be saved to (SAVE_AS).
|
||||
* @return 0 if success
|
||||
*/
|
||||
int save_disk(const string& disk_id,
|
||||
int save_disk(const string& disk_id,
|
||||
const string& source,
|
||||
int img_id);
|
||||
|
||||
@ -789,8 +793,8 @@ public:
|
||||
* @param ar the AuthRequest object
|
||||
* @param tmpl the virtual machine template
|
||||
*/
|
||||
static void set_auth_request(int uid,
|
||||
AuthRequest& ar,
|
||||
static void set_auth_request(int uid,
|
||||
AuthRequest& ar,
|
||||
VirtualMachineTemplate *tmpl);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -805,7 +809,7 @@ public:
|
||||
void get_disk_info(int& num_disks, set<string>& used_targets);
|
||||
|
||||
/**
|
||||
* Generate a DISK attributed to be attached to the VM.
|
||||
* Generate a DISK attributed to be attached to the VM.
|
||||
* @param tmpl Template containing a single DISK vector attribute.
|
||||
* @param used_targets targets in use by current DISKS
|
||||
* @param num_disks of the VM
|
||||
@ -843,7 +847,7 @@ public:
|
||||
VectorAttribute * delete_attach_disk();
|
||||
|
||||
/**
|
||||
* Adds a new disk to the virtual machine template. The disk should be
|
||||
* Adds a new disk to the virtual machine template. The disk should be
|
||||
* generated by the build_attach_disk
|
||||
* @param new_disk must be allocated in the heap
|
||||
*/
|
||||
@ -1111,9 +1115,9 @@ protected:
|
||||
// Constructor
|
||||
//**************************************************************************
|
||||
|
||||
VirtualMachine(int id,
|
||||
VirtualMachine(int id,
|
||||
int uid,
|
||||
int gid,
|
||||
int gid,
|
||||
const string& uname,
|
||||
const string& gname,
|
||||
VirtualMachineTemplate * _vm_template);
|
||||
@ -1123,7 +1127,7 @@ protected:
|
||||
// *************************************************************************
|
||||
// DataBase implementation
|
||||
// *************************************************************************
|
||||
|
||||
|
||||
static const char * table;
|
||||
|
||||
static const char * db_names;
|
||||
|
@ -1128,6 +1128,7 @@ ECO_LIB_FILES="src/cloud/ec2/lib/EC2QueryClient.rb \
|
||||
src/cloud/ec2/lib/ebs.rb \
|
||||
src/cloud/ec2/lib/instance.rb \
|
||||
src/cloud/ec2/lib/keypair.rb \
|
||||
src/cloud/ec2/lib/net_ssh_replacement.rb \
|
||||
src/cloud/ec2/lib/econe-server.rb"
|
||||
|
||||
ECO_LIB_CLIENT_FILES="src/cloud/ec2/lib/EC2QueryClient.rb"
|
||||
@ -1787,16 +1788,13 @@ if [ "$UNINSTALL" = "no" ] ; then
|
||||
for d in $MAKE_DIRS; do
|
||||
mkdir -p $DESTDIR$d
|
||||
done
|
||||
|
||||
# Remove old migrators
|
||||
rm $LIB_LOCATION/ruby/onedb/*.rb &> /dev/null
|
||||
fi
|
||||
|
||||
# --- Install/Uninstall files ---
|
||||
|
||||
do_file() {
|
||||
if [ "$UNINSTALL" = "yes" ]; then
|
||||
rm $2/`basename $1`
|
||||
rm $DESTDIR$2/`basename $1`
|
||||
else
|
||||
if [ "$LINK" = "yes" ]; then
|
||||
ln -s $SRC_DIR/$1 $DESTDIR$2
|
||||
|
@ -85,11 +85,14 @@ MAC_PREFIX = "02:00"
|
||||
#*******************************************************************************
|
||||
# DataStore Configuration
|
||||
#*******************************************************************************
|
||||
# DATASTORE_LOCATION: Path for Datastores in the hosts. It IS the same for all
|
||||
# the hosts in the cluster. DATASTORE_LOCATION IS ONLY FOR THE HOSTS AND *NOT*
|
||||
# THE FRONT-END. It defaults to /var/lib/one/datastores (or
|
||||
# DATASTORE_LOCATION: *Default* Path for Datastores in the hosts. It IS the
|
||||
# same for all the hosts in the cluster. DATASTORE_LOCATION IS ONLY FOR THE
|
||||
# HOSTS AND *NOT* THE FRONT-END. It defaults to /var/lib/one/datastores (or
|
||||
# $ONE_LOCATION/var/datastores in self-contained mode)
|
||||
#
|
||||
# You can define a different DATASTORE_LOCATION in each cluster by updating
|
||||
# its properties with onecluster update.
|
||||
#
|
||||
# DEFAULT_IMAGE_TYPE: This can take values
|
||||
# OS Image file holding an operating system
|
||||
# CDROM Image file holding a CDROM
|
||||
|
@ -15,7 +15,7 @@ end
|
||||
GROUPS={
|
||||
:quota => [SQLITE, 'sequel'],
|
||||
:sunstone => ['json', 'rack', 'sinatra', 'thin', 'sequel', SQLITE],
|
||||
:cloud => %w{amazon-ec2 rack sinatra thin uuidtools curb json net-ssh},
|
||||
:cloud => %w{amazon-ec2 rack sinatra thin uuidtools curb json},
|
||||
:ozones_client => %w{json},
|
||||
:ozones_server => %w{json sequel}+[
|
||||
SQLITE, 'mysql'
|
||||
|
@ -16,7 +16,7 @@
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
VERSION=${VERSION:-3.6.0}
|
||||
VERSION=${VERSION:-3.7.80}
|
||||
MAINTAINER=${MAINTAINER:-C12G Labs <support@c12g.com>}
|
||||
LICENSE=${LICENSE:-Apache 2.0}
|
||||
PACKAGE_NAME=${PACKAGE_NAME:-one-context}
|
||||
|
@ -554,7 +554,11 @@ EOT
|
||||
|
||||
template<<"#{section.upcase}=[\n"
|
||||
template<<" #{name.upcase}_UNAME=\"#{user}\",\n" if user
|
||||
template<<" #{name.upcase}=\"#{object}\"\n"
|
||||
if object.match(/^\d$/)
|
||||
template<<" #{name.upcase}_ID=#{object}\n"
|
||||
else
|
||||
template<<" #{name.upcase}=\"#{object}\"\n"
|
||||
end
|
||||
template<<"]\n"
|
||||
end if objects
|
||||
|
||||
|
@ -37,6 +37,19 @@ class OneClusterHelper < OpenNebulaHelper::OneHelper
|
||||
"onecluster.yaml"
|
||||
end
|
||||
|
||||
def element_size(ehash, ename)
|
||||
ids = ehash[ename]["ID"]
|
||||
|
||||
if ids.nil?
|
||||
return 0
|
||||
elsif ids.class == String
|
||||
return 1
|
||||
else
|
||||
return ids.size
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def format_pool(options)
|
||||
config_file = self.class.table_conf
|
||||
|
||||
@ -50,15 +63,15 @@ class OneClusterHelper < OpenNebulaHelper::OneHelper
|
||||
end
|
||||
|
||||
column :HOSTS, "Number of Hosts", :size=>5 do |d|
|
||||
d["HOSTS"]["ID"] ? d["HOSTS"]["ID"].size : 0
|
||||
@ext.element_size(d,"HOSTS")
|
||||
end
|
||||
|
||||
column :VNETS, "Number of Networks", :size=>5 do |d|
|
||||
d["VNETS"]["ID"] ? d["VNETS"]["ID"].size : 0
|
||||
@ext.element_size(d,"VNETS")
|
||||
end
|
||||
|
||||
column :DATASTORES, "Number of Datastores", :size=>10 do |d|
|
||||
d["DATASTORES"]["ID"] ? d["DATASTORES"]["ID"].size : 0
|
||||
@ext.element_size(d,"DATASTORES")
|
||||
end
|
||||
|
||||
default :ID, :NAME, :HOSTS, :VNETS, :DATASTORES
|
||||
|
@ -17,7 +17,7 @@
|
||||
require 'json'
|
||||
require 'openssl'
|
||||
require 'digest/md5'
|
||||
require 'net/ssh'
|
||||
require 'net_ssh_replacement'
|
||||
|
||||
module Keypair
|
||||
############################################################################
|
||||
|
112
src/cloud/ec2/lib/net_ssh_replacement.rb
Normal file
112
src/cloud/ec2/lib/net_ssh_replacement.rb
Normal file
@ -0,0 +1,112 @@
|
||||
# Some of these functions are taken from net-ssh gem.
|
||||
|
||||
=begin
|
||||
== LICENSE:
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2008 Jamis Buck
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
=end
|
||||
|
||||
require 'openssl'
|
||||
|
||||
module OpenSSL
|
||||
|
||||
module SSHUtils
|
||||
def self.convert_string(string)
|
||||
[string.length].pack('N*')+string
|
||||
end
|
||||
|
||||
def self.convert_bignum(bn)
|
||||
bn.to_ssh
|
||||
end
|
||||
end
|
||||
|
||||
# This class is originally defined in the OpenSSL module. As needed, methods
|
||||
# have been added to it by the Net::SSH module for convenience in dealing with
|
||||
# SSH functionality.
|
||||
class BN
|
||||
|
||||
# Converts a BN object to a string. The format used is that which is
|
||||
# required by the SSH2 protocol.
|
||||
def to_ssh
|
||||
if zero?
|
||||
return [0].pack("N")
|
||||
else
|
||||
buf = to_s(2)
|
||||
if buf.getbyte(0)[7] == 1
|
||||
return [buf.length+1, 0, buf].pack("NCA*")
|
||||
else
|
||||
return [buf.length, buf].pack("NA*")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
module PKey
|
||||
|
||||
# This class is originally defined in the OpenSSL module. As needed, methods
|
||||
# have been added to it by the Net::SSH module for convenience in dealing
|
||||
# with SSH functionality.
|
||||
class RSA
|
||||
|
||||
# Returns "ssh-rsa", which is the description of this key type used by the
|
||||
# SSH2 protocol.
|
||||
def ssh_type
|
||||
"ssh-rsa"
|
||||
end
|
||||
|
||||
# Converts the key to a blob, according to the SSH2 protocol.
|
||||
def to_blob
|
||||
#@blob ||= Net::SSH::Buffer.from(:string, ssh_type, :bignum, e, :bignum, n).to_s
|
||||
SSHUtils.convert_string(ssh_type)<<
|
||||
SSHUtils.convert_bignum(e)<<
|
||||
SSHUtils.convert_bignum(n)
|
||||
end
|
||||
end
|
||||
|
||||
# This class is originally defined in the OpenSSL module. As needed, methods
|
||||
# have been added to it by the Net::SSH module for convenience in dealing
|
||||
# with SSH functionality.
|
||||
class DSA
|
||||
|
||||
# Returns "ssh-dss", which is the description of this key type used by the
|
||||
# SSH2 protocol.
|
||||
def ssh_type
|
||||
"ssh-dss"
|
||||
end
|
||||
|
||||
# Converts the key to a blob, according to the SSH2 protocol.
|
||||
def to_blob
|
||||
#@blob ||= Net::SSH::Buffer.from(:string, ssh_type,
|
||||
# :bignum, p, :bignum, q, :bignum, g, :bignum, pub_key).to_s
|
||||
SSHUtils.convert_string(ssh_type)<<
|
||||
SSHUtils.convert_bignum(p)<<
|
||||
SSHUtils.convert_bignum(q)<<
|
||||
SSHUtils.convert_bignum(g)<<
|
||||
SSHUtils.convert_bignum(pub_key)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "Cluster.h"
|
||||
#include "GroupPool.h"
|
||||
#include "Nebula.h"
|
||||
|
||||
const char * Cluster::table = "cluster_pool";
|
||||
|
||||
@ -95,6 +96,23 @@ error_common:
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
string& Cluster::get_ds_location(string &ds_location)
|
||||
{
|
||||
obj_template->get("DATASTORE_LOCATION", ds_location);
|
||||
|
||||
if ( ds_location.empty() == true )
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
nd.get_configuration_attribute("DATASTORE_LOCATION", ds_location);
|
||||
}
|
||||
|
||||
return ds_location;
|
||||
}
|
||||
|
||||
/* ************************************************************************ */
|
||||
/* Cluster :: Database Access Functions */
|
||||
/* ************************************************************************ */
|
||||
|
@ -27,6 +27,14 @@ module Migrator
|
||||
end
|
||||
|
||||
def up
|
||||
|
||||
puts " > Please enter the DATASTORE_LOCATION set in your oned.conf,\n"<<
|
||||
" Press enter to use the default /var/lib/one/datastores/\n"
|
||||
print " DATASTORE_LOCATION: "
|
||||
ds_location = gets.chomp
|
||||
|
||||
ds_location = "/var/lib/one/datastores/" if ds_location.empty?
|
||||
|
||||
########################################################################
|
||||
# Feature #1522: Allow users to create Documents by default
|
||||
########################################################################
|
||||
@ -46,22 +54,30 @@ module Migrator
|
||||
|
||||
@db.run("UPDATE pool_control SET last_oid=#{last_oid + 1} WHERE tablename='acl';")
|
||||
|
||||
########################################################################
|
||||
# Bugs #1363: Make sure all VMs have CPU (float) & MEM (int)
|
||||
########################################################################
|
||||
|
||||
# NOTE: The VM memory and CPU are modified, but the sum in
|
||||
# HOST/HOST_SHARE is not. A onedb fsck is required
|
||||
|
||||
@db.run "ALTER TABLE vm_pool RENAME TO old_vm_pool;"
|
||||
@db.run "CREATE TABLE vm_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, last_poll INTEGER, state INTEGER, lcm_state INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER);"
|
||||
|
||||
@db.fetch("SELECT * FROM old_vm_pool") do |row|
|
||||
if ( row[:state] == 6 )
|
||||
body = row[:body]
|
||||
else
|
||||
vm_doc = Document.new(row[:body])
|
||||
vm_doc = Document.new(row[:body])
|
||||
|
||||
####################################################################
|
||||
# Feature #1393: DATASTORE_LOCATION for each system datastore
|
||||
####################################################################
|
||||
|
||||
vm_doc.root.each_element("HISTORY_RECORDS/HISTORY") { |e|
|
||||
e.add_element("DS_LOCATION").text = ds_location
|
||||
}
|
||||
|
||||
####################################################################
|
||||
# Bug #1363: Make sure all VMs have CPU (float) & MEM (int)
|
||||
####################################################################
|
||||
|
||||
# NOTE: The VM memory and CPU are modified, but the sum in
|
||||
# HOST/HOST_SHARE is not. A onedb fsck is required
|
||||
|
||||
# If state != DONE
|
||||
if ( row[:state] != 6 )
|
||||
memory = nil
|
||||
vm_doc.root.each_element("TEMPLATE/MEMORY") { |e|
|
||||
memory = e.text.to_i
|
||||
@ -90,14 +106,12 @@ module Migrator
|
||||
e.add_element("CPU").text = "0"
|
||||
}
|
||||
end
|
||||
|
||||
body = vm_doc.root.to_s
|
||||
end
|
||||
|
||||
@db[:vm_pool].insert(
|
||||
:oid => row[:oid],
|
||||
:name => row[:name],
|
||||
:body => body,
|
||||
:body => vm_doc.root.to_s,
|
||||
:uid => row[:uid],
|
||||
:gid => row[:gid],
|
||||
:last_poll => row[:last_poll],
|
||||
@ -110,6 +124,30 @@ module Migrator
|
||||
|
||||
@db.run "DROP TABLE old_vm_pool;"
|
||||
|
||||
|
||||
####################################################################
|
||||
# Feature #1393: DATASTORE_LOCATION for each system datastore
|
||||
####################################################################
|
||||
|
||||
@db.run "ALTER TABLE history RENAME TO old_history;"
|
||||
@db.run "CREATE TABLE history (vid INTEGER, seq INTEGER, body TEXT, stime INTEGER, etime INTEGER,PRIMARY KEY(vid,seq));"
|
||||
|
||||
@db.fetch("SELECT * FROM old_history") do |row|
|
||||
doc = Document.new(row[:body])
|
||||
|
||||
doc.root.add_element("DS_LOCATION").text = ds_location
|
||||
|
||||
@db[:history].insert(
|
||||
:vid => row[:vid],
|
||||
:seq => row[:seq],
|
||||
:body => doc.root.to_s,
|
||||
:stime => row[:stime],
|
||||
:etime => row[:etime])
|
||||
end
|
||||
|
||||
@db.run "DROP TABLE old_history;"
|
||||
|
||||
|
||||
########################################################################
|
||||
# Bug #1335: Add suspended VMs resoureces to Host usage
|
||||
########################################################################
|
||||
|
@ -77,7 +77,7 @@ bool RequestManagerVirtualMachine::vm_authorization(
|
||||
|
||||
if ( ds_perm != 0 )
|
||||
{
|
||||
ar.add_auth(AuthRequest::USE, *ds_perm);
|
||||
ar.add_auth(AuthRequest::USE, *ds_perm);
|
||||
}
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
@ -95,11 +95,12 @@ bool RequestManagerVirtualMachine::vm_authorization(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int RequestManagerVirtualMachine::get_host_information(int hid,
|
||||
string& name,
|
||||
int RequestManagerVirtualMachine::get_host_information(int hid,
|
||||
string& name,
|
||||
string& vmm,
|
||||
string& vnm,
|
||||
string& tm,
|
||||
string& ds_location,
|
||||
int& ds_id,
|
||||
RequestAttributes& att,
|
||||
PoolObjectAuth& host_perms)
|
||||
@ -149,11 +150,15 @@ int RequestManagerVirtualMachine::get_host_information(int hid,
|
||||
|
||||
ds_id = cluster->get_ds_id();
|
||||
|
||||
cluster->get_ds_location(ds_location);
|
||||
|
||||
cluster->unlock();
|
||||
}
|
||||
else
|
||||
{
|
||||
ds_id = DatastorePool::SYSTEM_DS_ID;
|
||||
|
||||
nd.get_configuration_attribute("DATASTORE_LOCATION", ds_location);
|
||||
}
|
||||
|
||||
ds = nd.get_dspool()->get(ds_id, true);
|
||||
@ -220,6 +225,7 @@ int RequestManagerVirtualMachine::add_history(VirtualMachine * vm,
|
||||
const string& vmm_mad,
|
||||
const string& vnm_mad,
|
||||
const string& tm_mad,
|
||||
const string& ds_location,
|
||||
int ds_id,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
@ -228,7 +234,7 @@ int RequestManagerVirtualMachine::add_history(VirtualMachine * vm,
|
||||
|
||||
VirtualMachinePool * vmpool = static_cast<VirtualMachinePool *>(pool);
|
||||
|
||||
vm->add_history(hid,hostname,vmm_mad,vnm_mad,tm_mad,ds_id);
|
||||
vm->add_history(hid, hostname, vmm_mad, vnm_mad, tm_mad, ds_location, ds_id);
|
||||
|
||||
rc = vmpool->update_history(vm);
|
||||
|
||||
@ -378,6 +384,7 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
string vmm_mad;
|
||||
string vnm_mad;
|
||||
string tm_mad;
|
||||
string ds_location;
|
||||
int ds_id;
|
||||
|
||||
int id = xmlrpc_c::value_int(paramList.getInt(1));
|
||||
@ -386,7 +393,8 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
bool auth = false;
|
||||
|
||||
if (get_host_information(
|
||||
hid,hostname,vmm_mad,vnm_mad,tm_mad, ds_id, att, host_perms) != 0)
|
||||
hid, hostname, vmm_mad, vnm_mad, tm_mad, ds_location, ds_id, att,
|
||||
host_perms) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -413,7 +421,8 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
return;
|
||||
}
|
||||
|
||||
if ( add_history(vm,hid,hostname,vmm_mad,vnm_mad,tm_mad,ds_id,att) != 0)
|
||||
if ( add_history(
|
||||
vm,hid,hostname,vmm_mad,vnm_mad,tm_mad,ds_location,ds_id,att) != 0)
|
||||
{
|
||||
vm->unlock();
|
||||
return;
|
||||
@ -442,6 +451,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
string vmm_mad;
|
||||
string vnm_mad;
|
||||
string tm_mad;
|
||||
string ds_location;
|
||||
int ds_id;
|
||||
|
||||
PoolObjectAuth aux_perms;
|
||||
@ -456,7 +466,8 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
bool auth = false;
|
||||
|
||||
if (get_host_information(
|
||||
hid,hostname,vmm_mad,vnm_mad,tm_mad,ds_id, att, host_perms) != 0)
|
||||
hid, hostname, vmm_mad, vnm_mad, tm_mad, ds_location, ds_id, att,
|
||||
host_perms) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -490,8 +501,8 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
vm->unlock();
|
||||
|
||||
if (get_host_information(
|
||||
current_hid,aux_st,aux_st,aux_st,
|
||||
aux_st,current_ds_id, att, aux_perms) != 0)
|
||||
current_hid, aux_st, aux_st, aux_st, aux_st, aux_st, current_ds_id,
|
||||
att, aux_perms) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -518,7 +529,8 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
return;
|
||||
}
|
||||
|
||||
if ( add_history(vm,hid,hostname,vmm_mad,vnm_mad,tm_mad,ds_id,att) != 0)
|
||||
if ( add_history(vm, hid, hostname, vmm_mad, vnm_mad, tm_mad, ds_location,
|
||||
ds_id, att) != 0)
|
||||
{
|
||||
vm->unlock();
|
||||
return;
|
||||
@ -572,11 +584,11 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis
|
||||
// -------------------------------------------------------------------------
|
||||
// Prepare and check the VM/DISK to be saved_as
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
if ( (vm = get_vm(id, att)) == 0 )
|
||||
{
|
||||
{
|
||||
failure_response(NO_EXISTS,
|
||||
get_error(object_name(PoolObjectSQL::VM), id),
|
||||
get_error(object_name(PoolObjectSQL::VM), id),
|
||||
att);
|
||||
return;
|
||||
}
|
||||
@ -589,7 +601,7 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis
|
||||
|
||||
if ( iid_orig == -1 )
|
||||
{
|
||||
failure_response(INTERNAL,
|
||||
failure_response(INTERNAL,
|
||||
request_error("Cannot use selected DISK", error_str),
|
||||
att);
|
||||
return;
|
||||
@ -604,7 +616,7 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis
|
||||
if ( img == 0 )
|
||||
{
|
||||
failure_response(NO_EXISTS,
|
||||
get_error(object_name(PoolObjectSQL::IMAGE), iid_orig),
|
||||
get_error(object_name(PoolObjectSQL::IMAGE), iid_orig),
|
||||
att);
|
||||
return;
|
||||
}
|
||||
@ -637,7 +649,7 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis
|
||||
|
||||
ds->get_permissions(ds_perms);
|
||||
ds->to_xml(ds_data);
|
||||
|
||||
|
||||
ds_disk_type = ds->get_disk_type();
|
||||
|
||||
ds->unlock();
|
||||
@ -697,17 +709,17 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis
|
||||
if ( quota_authorization(&img_usage, Quotas::DATASTORE, att) == false )
|
||||
{
|
||||
delete itemplate;
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Create the image
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
rc = ipool->allocate(att.uid,
|
||||
att.gid,
|
||||
att.uname,
|
||||
att.gname,
|
||||
rc = ipool->allocate(att.uid,
|
||||
att.gid,
|
||||
att.uname,
|
||||
att.gname,
|
||||
itemplate,
|
||||
ds_id,
|
||||
ds_name,
|
||||
@ -807,7 +819,7 @@ void VirtualMachineAttach::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
// -------------------------------------------------------------------------
|
||||
// Authorize the operation & check quotas
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
if ( vm_authorization(id, 0, tmpl, att, 0, 0, auth_op) == false )
|
||||
{
|
||||
delete tmpl;
|
||||
@ -817,7 +829,7 @@ void VirtualMachineAttach::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
if ( quota_authorization(tmpl, Quotas::IMAGE, att) == false )
|
||||
{
|
||||
delete tmpl;
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
rc = dm->attach(id, tmpl, error_str);
|
||||
@ -832,7 +844,7 @@ void VirtualMachineAttach::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
}
|
||||
else
|
||||
{
|
||||
success_response(id, att);
|
||||
success_response(id, att);
|
||||
}
|
||||
|
||||
delete tmpl;
|
||||
@ -857,7 +869,7 @@ void VirtualMachineDetach::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
// -------------------------------------------------------------------------
|
||||
// Authorize the operation
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
if ( vm_authorization(id, 0, 0, att, 0, 0, auth_op) == false )
|
||||
{
|
||||
return;
|
||||
@ -873,10 +885,10 @@ void VirtualMachineDetach::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
}
|
||||
else
|
||||
{
|
||||
success_response(id, att);
|
||||
success_response(id, att);
|
||||
}
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -18,8 +18,6 @@ require 'yaml'
|
||||
require 'json'
|
||||
|
||||
class SunstonePlugins
|
||||
USER_PLUGIN_POLICY = false # or true to enable them by default
|
||||
|
||||
attr_reader :plugins_conf
|
||||
|
||||
def initialize
|
||||
@ -37,26 +35,18 @@ class SunstonePlugins
|
||||
@installed_plugins = Array.new
|
||||
|
||||
# read user plugins
|
||||
modified = false
|
||||
Dir[base_path+'user-plugins/*.js'].each do |p_path|
|
||||
m = p_path.match(/^#{base_path}(.*)$/)
|
||||
if m and plugin = m[1]
|
||||
@installed_plugins << plugin
|
||||
if !plugins.include? plugin
|
||||
@plugins_conf << {plugin=>{:ALL => USER_PLUGIN_POLICY,
|
||||
:user => nil,
|
||||
:group => nil}}
|
||||
modified = true
|
||||
end
|
||||
if m && m[1]
|
||||
@installed_plugins << m[1]
|
||||
end
|
||||
end
|
||||
write_conf if modified
|
||||
|
||||
# read base plugins
|
||||
Dir[base_path+'plugins/*.js'].each do |p_path|
|
||||
m = p_path.match(/^#{base_path}(.*)$/)
|
||||
if m and plugin = m[1]
|
||||
@installed_plugins << plugin
|
||||
if m && m[1]
|
||||
@installed_plugins << m[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -99,12 +89,6 @@ class SunstonePlugins
|
||||
auth_plugins
|
||||
end
|
||||
|
||||
def write_conf
|
||||
File.open(PLUGIN_CONFIGURATION_FILE,'w') do |f|
|
||||
f.write(@plugins_conf.to_yaml)
|
||||
end
|
||||
end
|
||||
|
||||
def to_json
|
||||
@plugins_conf.to_json
|
||||
end
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
SRC=$1
|
||||
DST=$2
|
||||
VM_ID=$(basename `dirname $DST`)
|
||||
VM_ID=$3
|
||||
DS_ID=$4
|
||||
|
||||
if [ -z "${ONE_LOCATION}" ]; then
|
||||
|
@ -42,13 +42,7 @@ DST_HOST=`arg_host $DST`
|
||||
# Delete the device if it's a clone (LVM snapshot)
|
||||
DELETE_CMD=$(cat <<EOF
|
||||
DEV=\$(readlink $DST_PATH)
|
||||
LV=\$(basename \$DEV)
|
||||
VM=\$(echo \$LV|cut -d- -f4)
|
||||
DISK_ID=\$(echo \$LV|cut -d- -f5)
|
||||
|
||||
if [ -n "\$VM" -a -n "\$DISK_ID" ]; then
|
||||
$SUDO $LVREMOVE -f \$DEV
|
||||
fi
|
||||
$SUDO $LVREMOVE -f \$DEV
|
||||
EOF
|
||||
)
|
||||
|
||||
|
@ -51,11 +51,19 @@ TARGET_DEV=/dev/$VG_NAME/$LV_NAME
|
||||
|
||||
DUMP_CMD=$(cat <<EOF
|
||||
DEV=\$(readlink $SRC_PATH)
|
||||
LV=\$(basename \$DEV)
|
||||
VM=\$(echo \$LV|cut -d- -f4)
|
||||
DISK_ID=\$(echo \$LV|cut -d- -f5)
|
||||
|
||||
SOURCE_DEV=\$(echo \$DEV|sed 's/-[0-9]*-[0-9]*$//')
|
||||
SIZE=\$($SUDO $LVS \$SOURCE_DEV --noheadings|awk '{print \$4}'|tr -d m)
|
||||
|
||||
$SUDO $LVCREATE -L\${SIZE}M ${VG_NAME} -n ${LV_NAME}
|
||||
$SUDO $DD if=$SRC_PATH of=$TARGET_DEV bs=64k
|
||||
$SUDO $LVREMOVE -f \$DEV
|
||||
|
||||
if [ -n "\$VM" -a -n "\$DISK_ID" ]; then
|
||||
$SUDO $LVREMOVE -f \$DEV
|
||||
fi
|
||||
EOF
|
||||
)
|
||||
|
||||
|
@ -45,6 +45,7 @@ History::History(
|
||||
vmm_mad_name(""),
|
||||
vnm_mad_name(""),
|
||||
tm_mad_name(""),
|
||||
ds_location(""),
|
||||
ds_id(0),
|
||||
stime(0),
|
||||
etime(0),
|
||||
@ -67,6 +68,7 @@ History::History(
|
||||
const string& _vmm,
|
||||
const string& _vnm,
|
||||
const string& _tmm,
|
||||
const string& _ds_location,
|
||||
int _ds_id,
|
||||
const string& _vm_info):
|
||||
oid(_oid),
|
||||
@ -76,6 +78,7 @@ History::History(
|
||||
vmm_mad_name(_vmm),
|
||||
vnm_mad_name(_vnm),
|
||||
tm_mad_name(_tmm),
|
||||
ds_location(_ds_location),
|
||||
ds_id(_ds_id),
|
||||
stime(0),
|
||||
etime(0),
|
||||
@ -99,9 +102,7 @@ void History::non_persistent_data()
|
||||
ostringstream os;
|
||||
|
||||
string vm_lhome;
|
||||
string vm_rhome;
|
||||
string ds_location;
|
||||
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
// ----------- Local Locations ------------
|
||||
@ -128,16 +129,15 @@ void History::non_persistent_data()
|
||||
|
||||
os.str("");
|
||||
|
||||
nd.get_configuration_attribute("DATASTORE_LOCATION", ds_location);
|
||||
os << ds_location << "/" << ds_id << "/" << oid;
|
||||
|
||||
vm_rhome = os.str();
|
||||
rsystem_dir = os.str();
|
||||
|
||||
os << "/checkpoint";
|
||||
checkpoint_file = os.str();
|
||||
|
||||
os.str("");
|
||||
os << vm_rhome << "/deployment." << seq;
|
||||
os << rsystem_dir << "/deployment." << seq;
|
||||
|
||||
rdeployment_file = os.str();
|
||||
}
|
||||
@ -299,6 +299,7 @@ string& History::to_xml(string& xml, bool database) const
|
||||
"<VMMMAD>" << vmm_mad_name << "</VMMMAD>"<<
|
||||
"<VNMMAD>" << vnm_mad_name << "</VNMMAD>"<<
|
||||
"<TMMAD>" << tm_mad_name << "</TMMAD>" <<
|
||||
"<DS_LOCATION>" << ds_location << "</DS_LOCATION>" <<
|
||||
"<DS_ID>" << ds_id << "</DS_ID>" <<
|
||||
"<PSTIME>" << prolog_stime << "</PSTIME>"<<
|
||||
"<PETIME>" << prolog_etime << "</PETIME>"<<
|
||||
@ -329,22 +330,23 @@ int History::rebuild_attributes()
|
||||
int int_reason;
|
||||
int rc = 0;
|
||||
|
||||
rc += xpath(seq , "/HISTORY/SEQ", -1);
|
||||
rc += xpath(hostname , "/HISTORY/HOSTNAME", "not_found");
|
||||
rc += xpath(hid , "/HISTORY/HID", -1);
|
||||
rc += xpath(stime , "/HISTORY/STIME", 0);
|
||||
rc += xpath(etime , "/HISTORY/ETIME", 0);
|
||||
rc += xpath(vmm_mad_name , "/HISTORY/VMMMAD", "not_found");
|
||||
xpath(vnm_mad_name , "/HISTORY/VNMMAD", "dummy");
|
||||
rc += xpath(tm_mad_name , "/HISTORY/TMMAD", "not_found");
|
||||
rc += xpath(ds_id , "/HISTORY/DS_ID", 0);
|
||||
rc += xpath(prolog_stime , "/HISTORY/PSTIME", 0);
|
||||
rc += xpath(prolog_etime , "/HISTORY/PETIME", 0);
|
||||
rc += xpath(running_stime , "/HISTORY/RSTIME", 0);
|
||||
rc += xpath(running_etime , "/HISTORY/RETIME", 0);
|
||||
rc += xpath(epilog_stime , "/HISTORY/ESTIME", 0);
|
||||
rc += xpath(epilog_etime , "/HISTORY/EETIME", 0);
|
||||
rc += xpath(int_reason , "/HISTORY/REASON", 0);
|
||||
rc += xpath(seq , "/HISTORY/SEQ", -1);
|
||||
rc += xpath(hostname , "/HISTORY/HOSTNAME", "not_found");
|
||||
rc += xpath(hid , "/HISTORY/HID", -1);
|
||||
rc += xpath(stime , "/HISTORY/STIME", 0);
|
||||
rc += xpath(etime , "/HISTORY/ETIME", 0);
|
||||
rc += xpath(vmm_mad_name , "/HISTORY/VMMMAD", "not_found");
|
||||
xpath(vnm_mad_name , "/HISTORY/VNMMAD", "dummy");
|
||||
rc += xpath(tm_mad_name , "/HISTORY/TMMAD", "not_found");
|
||||
rc += xpath(ds_location , "/HISTORY/DS_LOCATION", "not_found");
|
||||
rc += xpath(ds_id , "/HISTORY/DS_ID", 0);
|
||||
rc += xpath(prolog_stime , "/HISTORY/PSTIME", 0);
|
||||
rc += xpath(prolog_etime , "/HISTORY/PETIME", 0);
|
||||
rc += xpath(running_stime , "/HISTORY/RSTIME", 0);
|
||||
rc += xpath(running_etime , "/HISTORY/RETIME", 0);
|
||||
rc += xpath(epilog_stime , "/HISTORY/ESTIME", 0);
|
||||
rc += xpath(epilog_etime , "/HISTORY/EETIME", 0);
|
||||
rc += xpath(int_reason , "/HISTORY/REASON", 0);
|
||||
|
||||
reason = static_cast<MigrationReason>(int_reason);
|
||||
|
||||
|
@ -842,6 +842,7 @@ void VirtualMachine::add_history(
|
||||
const string& vmm_mad,
|
||||
const string& vnm_mad,
|
||||
const string& tm_mad,
|
||||
const string& ds_location,
|
||||
int ds_id)
|
||||
{
|
||||
ostringstream os;
|
||||
@ -868,6 +869,7 @@ void VirtualMachine::add_history(
|
||||
vmm_mad,
|
||||
vnm_mad,
|
||||
tm_mad,
|
||||
ds_location,
|
||||
ds_id,
|
||||
vm_xml);
|
||||
|
||||
@ -896,6 +898,7 @@ void VirtualMachine::cp_history()
|
||||
history->vmm_mad_name,
|
||||
history->vnm_mad_name,
|
||||
history->tm_mad_name,
|
||||
history->ds_location,
|
||||
history->ds_id,
|
||||
vm_xml);
|
||||
|
||||
@ -927,6 +930,7 @@ void VirtualMachine::cp_previous_history()
|
||||
previous_history->vmm_mad_name,
|
||||
previous_history->vnm_mad_name,
|
||||
previous_history->tm_mad_name,
|
||||
previous_history->ds_location,
|
||||
previous_history->ds_id,
|
||||
vm_xml);
|
||||
|
||||
@ -1994,22 +1998,6 @@ int VirtualMachine::from_xml(const string &xml_str)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string VirtualMachine::get_remote_system_dir() const
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
string ds_location;
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
nd.get_configuration_attribute("DATASTORE_LOCATION", ds_location);
|
||||
oss << ds_location << "/" << history->ds_id << "/" << oid;
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string VirtualMachine::get_system_dir() const
|
||||
{
|
||||
ostringstream oss;
|
||||
|
Loading…
x
Reference in New Issue
Block a user