mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Merge branch 'master' into feature-862
Conflicts: src/cloud/occi/lib/ui/public/js/plugins/network.js
This commit is contained in:
commit
1c13262736
13
install.sh
13
install.sh
@ -230,6 +230,7 @@ VAR_DIRS="$VAR_LOCATION/remotes \
|
||||
$VAR_LOCATION/remotes/vnm/ebtables \
|
||||
$VAR_LOCATION/remotes/vnm/fw \
|
||||
$VAR_LOCATION/remotes/vnm/ovswitch \
|
||||
$VAR_LOCATION/remotes/vnm/vmware \
|
||||
$VAR_LOCATION/remotes/vmm/xen \
|
||||
$VAR_LOCATION/remotes/vmm/vmware \
|
||||
$VAR_LOCATION/remotes/hooks \
|
||||
@ -391,6 +392,7 @@ INSTALL_FILES=(
|
||||
NETWORK_EBTABLES_FILES:$VAR_LOCATION/remotes/vnm/ebtables
|
||||
NETWORK_FW_FILES:$VAR_LOCATION/remotes/vnm/fw
|
||||
NETWORK_OVSWITCH_FILES:$VAR_LOCATION/remotes/vnm/ovswitch
|
||||
NETWORK_VMWARE_FILES:$VAR_LOCATION/remotes/vnm/vmware
|
||||
EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples
|
||||
INSTALL_NOVNC_SHARE_FILE:$SHARE_LOCATION
|
||||
INSTALL_GEMS_SHARE_FILE:$SHARE_LOCATION
|
||||
@ -745,6 +747,11 @@ NETWORK_OVSWITCH_FILES="src/vnm_mad/remotes/ovswitch/clean \
|
||||
src/vnm_mad/remotes/ovswitch/pre \
|
||||
src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb"
|
||||
|
||||
NETWORK_VMWARE_FILES="src/vnm_mad/remotes/vmware/clean \
|
||||
src/vnm_mad/remotes/vmware/post \
|
||||
src/vnm_mad/remotes/vmware/pre \
|
||||
src/vnm_mad/remotes/vmware/VMware.rb"
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Transfer Manager commands, to be installed under $LIB_LOCATION/tm_commands
|
||||
@ -1196,7 +1203,7 @@ SUNSTONE_PUBLIC_IMAGES_FILES="src/sunstone/public/images/ajax-loader.gif \
|
||||
src/sunstone/public/images/green_bullet.png \
|
||||
src/sunstone/public/images/vnc_off.png \
|
||||
src/sunstone/public/images/vnc_on.png"
|
||||
|
||||
|
||||
SUNSTONE_PUBLIC_LOCALE_EN_US="\
|
||||
src/sunstone/public/locale/en_US/en_US.js \
|
||||
"
|
||||
@ -1268,7 +1275,7 @@ OZONES_PUBLIC_JS_FILES="src/ozones/Server/public/js/ozones.js \
|
||||
src/sunstone/public/js/sunstone.js \
|
||||
src/sunstone/public/js/sunstone-util.js \
|
||||
src/sunstone/public/js/locale.js"
|
||||
|
||||
|
||||
OZONES_PUBLIC_CSS_FILES="src/ozones/Server/public/css/application.css \
|
||||
src/ozones/Server/public/css/layout.css \
|
||||
src/ozones/Server/public/css/login.css"
|
||||
@ -1322,7 +1329,7 @@ SELF_SERVICE_PUBLIC_CSS_FILES="src/cloud/occi/lib/ui/public/css/application.css
|
||||
src/cloud/occi/lib/ui/public/css/layout.css \
|
||||
src/cloud/occi/lib/ui/public/css/login.css"
|
||||
|
||||
SELF_SERVICE_PUBLIC_CUSTOMIZE_FILES="src/cloud/occi/lib/ui/public/customize/custom.js"
|
||||
SELF_SERVICE_PUBLIC_CUSTOMIZE_FILES="src/cloud/occi/lib/ui/public/customize/custom.js"
|
||||
|
||||
|
||||
SELF_SERVICE_PUBLIC_VENDOR_DATATABLES=$SUNSTONE_PUBLIC_VENDOR_DATATABLES
|
||||
|
@ -45,7 +45,7 @@ body {
|
||||
}
|
||||
|
||||
|
||||
div#logo_sunstone {
|
||||
div#logo_selfservice {
|
||||
position: relative;
|
||||
height: 100px;
|
||||
width: 600px;
|
||||
|
@ -23,9 +23,9 @@ var $network_count = '<span class="network_count" />';
|
||||
|
||||
|
||||
|
||||
//Login logo 591x43px - not implemented
|
||||
//Login logo 591x43px
|
||||
var logo_big = "images/opennebula-selfservice-big.png";
|
||||
//Top left logo 179x14px - not implemented
|
||||
//Top left logo 179x14px
|
||||
var logo_small = "images/opennebula-selfservice-small.png";
|
||||
|
||||
|
||||
|
@ -55,6 +55,8 @@ function authenticate(){
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
$('div#logo_selfservice').css("background","url("+logo_big+") no-repeat center");
|
||||
|
||||
$("#login_form").submit(function (){
|
||||
authenticate();
|
||||
return false;
|
||||
@ -62,7 +64,7 @@ $(document).ready(function(){
|
||||
|
||||
//compact login elements according to screen height
|
||||
if (screen.height <= 600){
|
||||
$('div#logo_sunstone').css("top","15px");
|
||||
$('div#logo_selfservice').css("top","15px");
|
||||
$('div#login').css("top","10px");
|
||||
$('.error_message').css("top","10px");
|
||||
};
|
||||
|
@ -235,7 +235,6 @@ var OCCI = {
|
||||
$.ajax({
|
||||
url: resource.toLowerCase() + "/" + id,
|
||||
type: "DELETE",
|
||||
dataType: "xml ONEjson",
|
||||
success: function(){
|
||||
return callback ? callback(request) : null;
|
||||
},
|
||||
|
@ -93,9 +93,9 @@ var create_vm_tmpl ='<form id="create_vm_form" action="">\
|
||||
<input type="text" name="vm_n_times" id="vm_n_times" value="1">\
|
||||
</fieldset>\
|
||||
<div class="form_buttons">\
|
||||
<button class="vm_close_dialog_link"/>\
|
||||
<button class="button" id="create_vm" value="VM.create" />\
|
||||
<button class="button" type="reset" id="reset_vm" value="reset" />\
|
||||
<button class="vm_close_dialog_link">'+tr("Close")+'</button>\
|
||||
<button class="button" id="create_vm" value="VM.create">'+tr("Create")+'</button>\
|
||||
<!--<button class="button" type="reset" id="reset_vm" value="reset">Reset</button>-->\
|
||||
</div>\
|
||||
</div>\
|
||||
</form>';
|
||||
@ -666,19 +666,21 @@ function popUpCreateVMDialog(){
|
||||
icons: {
|
||||
primary: "ui-icon-check"
|
||||
},
|
||||
text: false
|
||||
text: true
|
||||
});
|
||||
/*
|
||||
$('#reset_vm',dialog).button({
|
||||
icons: {
|
||||
primary: "ui-icon-scissors"
|
||||
},
|
||||
text: false
|
||||
text: true
|
||||
});
|
||||
*/
|
||||
$('.vm_close_dialog_link',dialog).button({
|
||||
icons: {
|
||||
primary: "ui-icon-closethick"
|
||||
},
|
||||
text: false
|
||||
text: true
|
||||
});
|
||||
|
||||
var net_select = makeSelectOptions(dataTable_vNetworks,
|
||||
@ -706,13 +708,13 @@ function popUpCreateVMDialog(){
|
||||
});
|
||||
|
||||
$('#network_box option,#disk_box option',dialog).click(function(){
|
||||
var clicked = $(this).attr("clicked");
|
||||
var clicked = $(this).attr('clicked');
|
||||
if (clicked){//unbold, unmark
|
||||
$(this).text($(this).text().replace(/\*/g,''));
|
||||
$(this).text($(this).text().replace(/✓/g,''));
|
||||
$(this).removeAttr('clicked');
|
||||
}
|
||||
else {//bold,mark
|
||||
$(this).text("*"+$(this).text()+"*");
|
||||
$(this).text("✓"+$(this).text());
|
||||
$(this).attr('clicked','clicked');
|
||||
}
|
||||
return false;
|
||||
|
@ -59,4 +59,6 @@ $(document).ready(function(){
|
||||
hideDialog();
|
||||
});
|
||||
|
||||
$('div#logo img').attr('src',logo_small);
|
||||
|
||||
});
|
@ -53,9 +53,9 @@ var create_vn_tmpl =
|
||||
<div class="clear"></div>\
|
||||
</fieldset>\
|
||||
<div class="form_buttons">\
|
||||
<button class="vnet_close_dialog_link"/>\
|
||||
<button class="button" id="create_vn" value="vn/create" />\
|
||||
<button class="button" type="reset" id="reset_vn" value="reset" />\
|
||||
<button class="vnet_close_dialog_link">'+tr("Close")+'</button>\
|
||||
<button class="button" id="create_vn" value="Network.create">'+tr("Create")+'</button>\
|
||||
<!--<button class="button" type="reset" id="reset_vn" value="reset" />-->\
|
||||
</div>\
|
||||
</form>\
|
||||
</div>\
|
||||
@ -342,19 +342,21 @@ function popUpCreateVnetDialog() {
|
||||
icons: {
|
||||
primary: "ui-icon-check"
|
||||
},
|
||||
text: false
|
||||
text: true
|
||||
});
|
||||
/*
|
||||
$('#reset_vn',dialog).button({
|
||||
icons: {
|
||||
primary: "ui-icon-scissors"
|
||||
},
|
||||
text: false
|
||||
});
|
||||
*/
|
||||
$('.vnet_close_dialog_link',dialog).button({
|
||||
icons: {
|
||||
primary: "ui-icon-closethick"
|
||||
},
|
||||
text: false
|
||||
text: true
|
||||
});
|
||||
|
||||
$('#create_vn_form_easy',dialog).submit(function(){
|
||||
|
@ -73,11 +73,10 @@ var create_image_tmpl =
|
||||
<div class="tip">'+tr("Type of file system to be built. This can be any value understood by mkfs unix command.")+'</div>\
|
||||
</div>\
|
||||
<div class="img_param" id="upload_div">\
|
||||
<label for="file-uploader" style="width: 60px">'+tr("Upload image")+':</label>\
|
||||
<div id="file-uploader">\
|
||||
<label for="file-uploader" style="width:300px;height:2em;">'+tr("Select image to upload")+':</label><br /><div class="clear"/>\
|
||||
<div id="file-uploader" style="padding:0 1em;">\
|
||||
</div><div class="clear" />\
|
||||
<label for="upload-progress">'+tr("Upload progress")+':</label>\
|
||||
<div id="upload-progress"></div>\
|
||||
<div id="upload-progress" style="margin-left:1em;"></div>\
|
||||
</div>\
|
||||
<!--\
|
||||
<div class="img_param">\
|
||||
@ -93,9 +92,9 @@ var create_image_tmpl =
|
||||
<div class="img_param">\
|
||||
-->\
|
||||
<div class="form_buttons">\
|
||||
<button class="image_close_dialog_link"/>\
|
||||
<button class="button" id="create_image" value="Image.create" />\
|
||||
<button class="button" type="reset" id="reset_image" value="reset" />\
|
||||
<button class="image_close_dialog_link">'+tr("Close")+'</button>\
|
||||
<button class="button" id="create_image" value="Image.create">'+tr("Create")+'</button>\
|
||||
<!--<button class="button" type="reset" id="reset_image" value="reset"-->\
|
||||
</div>\
|
||||
</form>\
|
||||
</div>\
|
||||
@ -414,19 +413,21 @@ function popUpCreateImageDialog(){
|
||||
icons: {
|
||||
primary: "ui-icon-check"
|
||||
},
|
||||
text: false
|
||||
text: true
|
||||
});
|
||||
/*
|
||||
$('#reset_image',dialog).button({
|
||||
icons: {
|
||||
primary: "ui-icon-scissors"
|
||||
},
|
||||
text: false
|
||||
});
|
||||
*/
|
||||
$('.image_close_dialog_link',dialog).button({
|
||||
icons: {
|
||||
primary: "ui-icon-closethick"
|
||||
},
|
||||
text: false
|
||||
text: true
|
||||
});
|
||||
|
||||
setupTips(dialog);
|
||||
@ -460,7 +461,7 @@ function popUpCreateImageDialog(){
|
||||
border: "1px solid #AAAAAA",
|
||||
position: "relative",
|
||||
// bottom: "29px",
|
||||
width: "210px",
|
||||
width: "258px",
|
||||
// left: "133px",
|
||||
height: "15px",
|
||||
display: "inline-block",
|
||||
@ -506,6 +507,7 @@ function popUpCreateImageDialog(){
|
||||
};
|
||||
|
||||
$('#file-uploader input').removeAttr("style");
|
||||
$('#file-uploader input').attr('style','margin:0;width:256px!important');
|
||||
|
||||
var processCreateImageForm = function(){
|
||||
var dialog = $create_image_dialog;
|
||||
|
@ -13,6 +13,7 @@ locale={
|
||||
"Canvas not supported.":"",
|
||||
"CD-ROM":"",
|
||||
"Changing language":"",
|
||||
"Close":"",
|
||||
"Community":"",
|
||||
"Compute":"",
|
||||
"Compute resource":"",
|
||||
@ -21,6 +22,7 @@ locale={
|
||||
"Configuration":"",
|
||||
"Confirmation of action":"",
|
||||
"CPU":"",
|
||||
"Create":"",
|
||||
"Create network":"",
|
||||
"Create new compute resource":"",
|
||||
"Create new network resource":"",
|
||||
@ -98,6 +100,7 @@ locale={
|
||||
"See more":"",
|
||||
"Select a template":"",
|
||||
"Select disk":"",
|
||||
"Select image to upload":"",
|
||||
"Self-Service UI Configuration":"",
|
||||
"Shutdown":"",
|
||||
"Sign out":"",
|
||||
@ -132,8 +135,6 @@ locale={
|
||||
"Unpublish":"",
|
||||
"Update":"",
|
||||
"Update template":"",
|
||||
"Upload image":"",
|
||||
"Upload progress":"",
|
||||
"Useful links":"",
|
||||
"Virtual Machine information":"",
|
||||
"virtual machines":"",
|
||||
|
@ -1,4 +1,4 @@
|
||||
//Translated by
|
||||
//Translated by Hector Sanjuan
|
||||
lang="es_ES"
|
||||
datatable_lang="es_datatable.txt"
|
||||
locale={
|
||||
@ -13,6 +13,7 @@ locale={
|
||||
"Canvas not supported.":"Canvas no soportado",
|
||||
"CD-ROM":"CD-ROM",
|
||||
"Changing language":"Cambiando el lenguaje",
|
||||
"Close":"Cerrar",
|
||||
"Community":"Comunidad",
|
||||
"Compute":"Máquinas Virtuales",
|
||||
"Compute resource":"máquina virtual",
|
||||
@ -21,6 +22,7 @@ locale={
|
||||
"Configuration":"Configuración",
|
||||
"Confirmation of action":"Confirmar operación",
|
||||
"CPU":"CPU",
|
||||
"Create":"Crear",
|
||||
"Create network":"Crear red",
|
||||
"Create new compute resource":"Crear nueva máquina virtual",
|
||||
"Create new network resource":"Crear nueva red",
|
||||
@ -89,7 +91,7 @@ locale={
|
||||
"Please select":"Por favor escoja",
|
||||
"Previous action":"Acción anterior",
|
||||
"Public":"Público",
|
||||
"Public scope of the image":"",
|
||||
"Public scope of the image":"Imagen pública",
|
||||
"Publish":"Publicar",
|
||||
"Refresh list":"Refrescar lista",
|
||||
"Resume":"Reanudar",
|
||||
@ -98,6 +100,7 @@ locale={
|
||||
"See more":"Ver más",
|
||||
"Select a template":"Seleccione una plantilla",
|
||||
"Select disk":"Seleccione un disco",
|
||||
"Select image to upload":"Seleccione una imagen para subir",
|
||||
"Self-Service UI Configuration":"Configuración de la interfaz Self-Service",
|
||||
"Shutdown":"Apagar",
|
||||
"Sign out":"Desconectar",
|
||||
@ -132,8 +135,6 @@ locale={
|
||||
"Unpublish":"Despublicar",
|
||||
"Update":"Actualizar",
|
||||
"Update template":"Actualizar plantilla",
|
||||
"Upload image":"Subir imagen",
|
||||
"Upload progress":"Progreso se subida",
|
||||
"Useful links":"Enlances útiles",
|
||||
"Virtual Machine information":"Información de máquina virtual",
|
||||
"virtual machines":"máquinas virtuales",
|
||||
|
@ -17,7 +17,7 @@
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
tr_strings = `grep -h -o -R -e 'tr("[[:print:]]*")' ../js/* ../customize/* | cut -d'"' -f 2 | sort -u`
|
||||
tr_strings = `grep -h -o -R -e 'tr("[[:print:]]*")' ../js/* ../customize/* ../../../../../../sunstone/public/js/sunstone.js ../../../../../../sunstone/public/js/sunstone-util.js | cut -d'"' -f 2 | sort -u`
|
||||
|
||||
puts "//Translated by"
|
||||
puts 'lang="en_US"'
|
||||
|
@ -9,7 +9,9 @@
|
||||
<script type="text/javascript" src="vendor/crypto-js/2.3.0-crypto-sha1.js"></script>
|
||||
<!-- End Vendor Libraries -->
|
||||
|
||||
<script type="text/javascript" src="js/locale.js"></script>
|
||||
<script type="text/javascript" src="js/occi.js"></script>
|
||||
<script type="text/javascript" src="customize/custom.js"></script>
|
||||
<script type="text/javascript" src="js/login.js"></script>
|
||||
|
||||
</head>
|
||||
@ -23,7 +25,7 @@
|
||||
</div>
|
||||
|
||||
<div id="wrapper">
|
||||
<div id="logo_sunstone">
|
||||
<div id="logo_selfservice">
|
||||
</div>
|
||||
|
||||
<div id="auth_error" class="error_message">
|
||||
|
@ -52,6 +52,7 @@ int LibVirtDriver::deployment_description_vmware(
|
||||
|
||||
const VectorAttribute * nic;
|
||||
|
||||
string network_id = "";
|
||||
string mac = "";
|
||||
string bridge = "";
|
||||
string script = "";
|
||||
@ -163,7 +164,7 @@ int LibVirtDriver::deployment_description_vmware(
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
file << "\t<devices>" << endl;
|
||||
|
||||
|
||||
get_default("DISK","DRIVER",default_driver);
|
||||
|
||||
num = vm->get_template_attribute("DISK",attrs);
|
||||
@ -221,7 +222,7 @@ int LibVirtDriver::deployment_description_vmware(
|
||||
{
|
||||
file << "\t\t<disk type='file' device='cdrom'>" << endl;
|
||||
file << "\t\t\t<source file=[" << datastore << "] " << vm->get_oid()
|
||||
<< "/images/disk." << i << ".iso'/>" << endl;
|
||||
<< "/images/disk." << i << ".iso'/>" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -249,8 +250,8 @@ int LibVirtDriver::deployment_description_vmware(
|
||||
{
|
||||
if (!default_driver.empty())
|
||||
{
|
||||
file << "\t\t\t<driver name='" <<
|
||||
default_driver << "'/>" << endl;
|
||||
file << "\t\t\t<driver name='" <<
|
||||
default_driver << "'/>" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -306,21 +307,17 @@ int LibVirtDriver::deployment_description_vmware(
|
||||
continue;
|
||||
}
|
||||
|
||||
bridge = nic->vector_value("BRIDGE");
|
||||
mac = nic->vector_value("MAC");
|
||||
target = nic->vector_value("TARGET");
|
||||
script = nic->vector_value("SCRIPT");
|
||||
model = nic->vector_value("MODEL");
|
||||
network_id = nic->vector_value("NETWORK_ID");
|
||||
mac = nic->vector_value("MAC");
|
||||
target = nic->vector_value("TARGET");
|
||||
script = nic->vector_value("SCRIPT");
|
||||
model = nic->vector_value("MODEL");
|
||||
|
||||
if ( bridge.empty() )
|
||||
{
|
||||
file << "\t\t<interface type='ethernet'>" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
file << "\t\t<interface type='bridge'>" << endl;
|
||||
file << "\t\t\t<source bridge='" << bridge << "'/>" << endl;
|
||||
}
|
||||
bridge = "one-pg-";
|
||||
bridge.append(network_id);
|
||||
|
||||
file << "\t\t<interface type='bridge'>" << endl;
|
||||
file << "\t\t\t<source bridge='" << bridge << "'/>" << endl;
|
||||
|
||||
if( !mac.empty() )
|
||||
{
|
||||
|
@ -24,6 +24,7 @@ require 'OpenNebulaNic'
|
||||
require 'base64'
|
||||
|
||||
require 'scripts_common'
|
||||
require 'CommandManager'
|
||||
include OpenNebula
|
||||
|
||||
CONF = {
|
||||
@ -84,7 +85,7 @@ class VM
|
||||
def [](element)
|
||||
if @vm_root
|
||||
val = @vm_root.elements[element]
|
||||
if val.text
|
||||
if !val.nil? and val.text
|
||||
return val.text
|
||||
end
|
||||
end
|
||||
@ -106,7 +107,7 @@ class OpenNebulaNetwork
|
||||
else
|
||||
@hypervisor = hypervisor
|
||||
end
|
||||
|
||||
|
||||
@vm = VM.new(REXML::Document.new(vm_tpl).root, xpath_filter, deploy_id, @hypervisor)
|
||||
end
|
||||
|
||||
|
@ -22,6 +22,8 @@ class Nics < Array
|
||||
@nicClass = NicKVM
|
||||
when "xen"
|
||||
@nicClass = NicXen
|
||||
when "vmware"
|
||||
@nicClass = NicVMware
|
||||
end
|
||||
end
|
||||
|
||||
@ -30,7 +32,6 @@ class Nics < Array
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# A NIC using KVM. This class implements functions to get the physical interface
|
||||
# that the NIC is using
|
||||
class NicKVM < Hash
|
||||
@ -114,3 +115,18 @@ class NicXen < Hash
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
# A NIC using VMware. This class implements functions to get the physical interface
|
||||
# that the NIC is using
|
||||
class NicVMware < Hash
|
||||
def initialize
|
||||
super(nil)
|
||||
end
|
||||
|
||||
def get_info(vm)
|
||||
end
|
||||
|
||||
def get_tap(vm)
|
||||
self
|
||||
end
|
||||
end
|
||||
|
123
src/vnm_mad/remotes/vmware/VMware.rb
Normal file
123
src/vnm_mad/remotes/vmware/VMware.rb
Normal file
@ -0,0 +1,123 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
# -------------------------------------------------------------------------#
|
||||
# Set up the environment for the driver #
|
||||
# -------------------------------------------------------------------------#
|
||||
ONE_LOCATION = ENV["ONE_LOCATION"]
|
||||
|
||||
if !ONE_LOCATION
|
||||
ETC_LOCATION = "/etc/one/"
|
||||
else
|
||||
ETC_LOCATION = ONE_LOCATION + "/etc/"
|
||||
end
|
||||
|
||||
CONF_FILE = ETC_LOCATION + "/vmwarerc"
|
||||
|
||||
require 'yaml'
|
||||
require 'OpenNebulaNetwork'
|
||||
|
||||
class OpenNebulaVMware < OpenNebulaNetwork
|
||||
XPATH_FILTER = "TEMPLATE/NIC"
|
||||
VCLI_PREFIX = "/usr/bin/vicfg"
|
||||
|
||||
def initialize(vm, deploy_id = nil, hypervisor = nil)
|
||||
super(vm,XPATH_FILTER,deploy_id,hypervisor)
|
||||
|
||||
@config = YAML::load(File.read(CONF_FILE))
|
||||
|
||||
set_conn_options
|
||||
end
|
||||
|
||||
def set_conn_options
|
||||
username = @config[:username]
|
||||
password = @config[:password]
|
||||
server = @vm['HISTORY_RECORDS/HISTORY/HOSTNAME']
|
||||
|
||||
@conn_options = "--username=#{username} " <<
|
||||
"--password=#{password} " <<
|
||||
"--server=#{server}"
|
||||
end
|
||||
|
||||
def activate
|
||||
vm_id = @vm['ID']
|
||||
hostname = @vm['HISTORY_RECORDS/HISTORY/HOSTNAME']
|
||||
process do |nic|
|
||||
switch = nic[:bridge]
|
||||
network_id = nic[:network_id]
|
||||
pg = "one-pg-#{network_id}"
|
||||
|
||||
if nic[:vlan] == "YES"
|
||||
if nic[:vlan_id]
|
||||
vlan = nic[:vlan_id]
|
||||
else
|
||||
vlan = CONF[:start_vlan] + nic[:network_id].to_i
|
||||
end
|
||||
else
|
||||
vlan = nil
|
||||
end
|
||||
|
||||
add_pg(pg, switch, vlan) if !check_pg(pg, switch)
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
|
||||
def vcli(command, params)
|
||||
cmd = "#{VCLI_PREFIX}-#{command.to_s} #{@conn_options} #{params}"
|
||||
end
|
||||
|
||||
def vswitch(params)
|
||||
vcli(:vswitch, params)
|
||||
end
|
||||
|
||||
def check_pg(pg, switch)
|
||||
cmd = vcli(:vswitch, "--check-pg #{pg} #{switch}")
|
||||
rc, output = do_action(cmd)
|
||||
output.strip!
|
||||
if output.match(/^\d+$/)
|
||||
return output != "0"
|
||||
else
|
||||
OpenNebula.log_error("Unexpected output for #{cmd}:\n#{output}")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def add_pg(pg, switch, vlan=nil)
|
||||
add_pg_cmd = vcli(:vswitch, "--add-pg #{pg} #{switch}")
|
||||
do_action(add_pg_cmd)
|
||||
|
||||
if vlan
|
||||
set_vlan_cmd = vcli(:vswitch, "--vlan #{vlan} --pg #{pg} #{switch}")
|
||||
do_action(set_vlan_cmd)
|
||||
end
|
||||
end
|
||||
|
||||
#Performs an action using vCLI
|
||||
def do_action(cmd)
|
||||
rc = LocalCommand.run(cmd)
|
||||
|
||||
if rc.code == 0
|
||||
OpenNebula.log("Executed \"#{cmd}\".")
|
||||
return [true, rc.stdout]
|
||||
else
|
||||
err = "Error executing: #{cmd} err: #{rc.stderr} out: #{rc.stdout}"
|
||||
OpenNebula.log_error(err)
|
||||
return [false, rc.code]
|
||||
end
|
||||
end
|
||||
end
|
19
src/vnm_mad/remotes/vmware/clean
Executable file
19
src/vnm_mad/remotes/vmware/clean
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# 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
|
19
src/vnm_mad/remotes/vmware/post
Executable file
19
src/vnm_mad/remotes/vmware/post
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# 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
|
30
src/vnm_mad/remotes/vmware/pre
Executable file
30
src/vnm_mad/remotes/vmware/pre
Executable file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
# $stdout = $stderr
|
||||
|
||||
$: << File.dirname(__FILE__)
|
||||
$: << File.join(File.dirname(__FILE__), "..")
|
||||
|
||||
require 'VMware'
|
||||
|
||||
deploy_id = nil
|
||||
hypervisor = "vmware"
|
||||
vm_64 = ARGV[0]
|
||||
|
||||
vmware = OpenNebulaVMware.from_base64(vm_64, deploy_id, hypervisor)
|
||||
exit vmware.activate
|
Loading…
x
Reference in New Issue
Block a user