mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-06 13:17:42 +03:00
Merge remote-tracking branch 'origin/master' into feature-4317
This commit is contained in:
commit
e52996856d
@ -120,7 +120,7 @@ protected:
|
||||
{
|
||||
const VectorAttribute * vattr = driver_conf.get(name);
|
||||
|
||||
if (vattr != 0)
|
||||
if (vattr == 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -3,6 +3,16 @@
|
||||
:desc: ONE identifier for the Datastore
|
||||
:size: 4
|
||||
|
||||
:USER:
|
||||
:desc: Username of the Datastore owner
|
||||
:size: 10
|
||||
:left: true
|
||||
|
||||
:GROUP:
|
||||
:desc: Group of the Datastore
|
||||
:size: 10
|
||||
:left: true
|
||||
|
||||
:NAME:
|
||||
:desc: Name of the Datastore
|
||||
:size: 13
|
||||
|
@ -4,12 +4,12 @@
|
||||
:size: 4
|
||||
|
||||
:USER:
|
||||
:desc: Username of the Virtual Machine owner
|
||||
:desc: Username of the Image owner
|
||||
:size: 10
|
||||
:left: true
|
||||
|
||||
:GROUP:
|
||||
:desc: Group of the Virtual Machine
|
||||
:desc: Group of the Image
|
||||
:size: 10
|
||||
:left: true
|
||||
|
||||
|
@ -3,6 +3,16 @@
|
||||
:desc: ONE identifier for the Marketplace
|
||||
:size: 4
|
||||
|
||||
:USER:
|
||||
:desc: Username of the Marketplace owner
|
||||
:size: 10
|
||||
:left: true
|
||||
|
||||
:GROUP:
|
||||
:desc: Group of the Marketplace
|
||||
:size: 10
|
||||
:left: true
|
||||
|
||||
:NAME:
|
||||
:desc: Name of the Marketplace
|
||||
:size: 20
|
||||
|
@ -44,6 +44,16 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
|
||||
d["ID"]
|
||||
end
|
||||
|
||||
column :USER, "Username of the Datastore owner", :left,
|
||||
:size=>10 do |d|
|
||||
helper.user_name(d, options)
|
||||
end
|
||||
|
||||
column :GROUP, "Group of the Datastore", :left,
|
||||
:size=>10 do |d|
|
||||
helper.group_name(d, options)
|
||||
end
|
||||
|
||||
column :NAME, "Name of the Datastore", :left, :size=>13 do |d|
|
||||
d["NAME"]
|
||||
end
|
||||
@ -95,7 +105,7 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
|
||||
Datastore::SHORT_DATASTORE_STATES[state]
|
||||
end
|
||||
|
||||
default :ID, :NAME, :SIZE, :AVAIL, :CLUSTER, :IMAGES,
|
||||
default :ID, :USER, :GROUP, :NAME, :SIZE, :AVAIL, :CLUSTER, :IMAGES,
|
||||
:TYPE, :DS, :TM, :STAT
|
||||
end
|
||||
|
||||
@ -114,7 +124,6 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
|
||||
end
|
||||
|
||||
def factory_pool(user_flag=-2)
|
||||
#TBD OpenNebula::UserPool.new(@client, user_flag)
|
||||
OpenNebula::DatastorePool.new(@client)
|
||||
end
|
||||
|
||||
|
@ -44,6 +44,16 @@ class OneMarketPlaceHelper < OpenNebulaHelper::OneHelper
|
||||
d["ID"]
|
||||
end
|
||||
|
||||
column :USER, "Username of the Marketplace owner", :left,
|
||||
:size=>10 do |d|
|
||||
helper.user_name(d, options)
|
||||
end
|
||||
|
||||
column :GROUP, "Group of the Marketplace", :left,
|
||||
:size=>10 do |d|
|
||||
helper.group_name(d, options)
|
||||
end
|
||||
|
||||
column :NAME, "Name of the Marketplace", :left, :size=>30 do |d|
|
||||
d["NAME"]
|
||||
end
|
||||
@ -72,7 +82,7 @@ class OneMarketPlaceHelper < OpenNebulaHelper::OneHelper
|
||||
d["MARKET_MAD"]
|
||||
end
|
||||
|
||||
default :ID, :SIZE, :AVAIL, :APPS, :TYPE, :MAD, :NAME
|
||||
default :ID, :USER, :GROUP, :NAME, :SIZE, :AVAIL, :APPS, :TYPE, :MAD, :NAME
|
||||
end
|
||||
|
||||
table
|
||||
|
@ -123,49 +123,45 @@ class OneVirtualRouterHelper < OpenNebulaHelper::OneHelper
|
||||
nic_default = {"NETWORK" => "-",
|
||||
"IP" => "-"}
|
||||
|
||||
shown_ips = []
|
||||
|
||||
array_id = 0
|
||||
vm_nics = [obj.to_hash['VROUTER']['TEMPLATE']['NIC']].flatten.compact
|
||||
vm_nics.each {|nic|
|
||||
|
||||
next if nic.has_key?("CLI_DONE")
|
||||
|
||||
if nic.has_key?("IP6_LINK")
|
||||
shown_ips << nic["IP6_LINK"]
|
||||
floating = (nic.has_key?("FLOATING_IP") && nic["FLOATING_IP"].upcase() == "YES" )
|
||||
|
||||
ip6_link = {"IP" => nic.delete("IP6_LINK"),
|
||||
"CLI_DONE" => true,
|
||||
"DOUBLE_ENTRY" => true}
|
||||
vm_nics.insert(array_id+1,ip6_link)
|
||||
if floating
|
||||
if nic.has_key?("IP6_LINK")
|
||||
ip6_link = {"IP" => nic.delete("IP6_LINK"),
|
||||
"CLI_DONE" => true,
|
||||
"DOUBLE_ENTRY" => true}
|
||||
vm_nics.insert(array_id+1,ip6_link)
|
||||
|
||||
array_id += 1
|
||||
array_id += 1
|
||||
end
|
||||
|
||||
if nic.has_key?("IP6_ULA")
|
||||
ip6_link = {"IP" => nic.delete("IP6_ULA"),
|
||||
"CLI_DONE" => true,
|
||||
"DOUBLE_ENTRY" => true}
|
||||
vm_nics.insert(array_id+1,ip6_link)
|
||||
|
||||
array_id += 1
|
||||
end
|
||||
|
||||
if nic.has_key?("IP6_GLOBAL")
|
||||
ip6_link = {"IP" => nic.delete("IP6_GLOBAL"),
|
||||
"CLI_DONE" => true,
|
||||
"DOUBLE_ENTRY" => true}
|
||||
vm_nics.insert(array_id+1,ip6_link)
|
||||
|
||||
array_id += 1
|
||||
end
|
||||
else
|
||||
nic.delete("IP")
|
||||
end
|
||||
|
||||
if nic.has_key?("IP6_ULA")
|
||||
shown_ips << nic["IP6_ULA"]
|
||||
|
||||
ip6_link = {"IP" => nic.delete("IP6_ULA"),
|
||||
"CLI_DONE" => true,
|
||||
"DOUBLE_ENTRY" => true}
|
||||
vm_nics.insert(array_id+1,ip6_link)
|
||||
|
||||
array_id += 1
|
||||
end
|
||||
|
||||
if nic.has_key?("IP6_GLOBAL")
|
||||
shown_ips << nic["IP6_GLOBAL"]
|
||||
|
||||
ip6_link = {"IP" => nic.delete("IP6_GLOBAL"),
|
||||
"CLI_DONE" => true,
|
||||
"DOUBLE_ENTRY" => true}
|
||||
vm_nics.insert(array_id+1,ip6_link)
|
||||
|
||||
array_id += 1
|
||||
end
|
||||
|
||||
shown_ips << nic["IP"] if nic.has_key?("IP")
|
||||
|
||||
nic.merge!(nic_default) {|k,v1,v2| v1}
|
||||
array_id += 1
|
||||
}
|
||||
|
@ -176,6 +176,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
end
|
||||
end
|
||||
|
||||
download_desc = <<-EOT.unindent
|
||||
Downloads an image to a file
|
||||
EOT
|
||||
|
||||
command :download, download_desc, :imageid, :path do
|
||||
helper.perform_action(args[0],options,"downloaded") do |image|
|
||||
image.download(args[1], helper.client)
|
||||
end
|
||||
end
|
||||
|
||||
delete_desc = <<-EOT.unindent
|
||||
Deletes the given Image
|
||||
EOT
|
||||
|
@ -19,9 +19,11 @@
|
||||
ONE_LOCATION=ENV["ONE_LOCATION"]
|
||||
|
||||
if !ONE_LOCATION
|
||||
RUBY_LIB_LOCATION="/usr/lib/one/ruby"
|
||||
RUBY_LIB_LOCATION = "/usr/lib/one/ruby"
|
||||
VAR_LOCATION = "/var/lib/one"
|
||||
else
|
||||
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
|
||||
RUBY_LIB_LOCATION = ONE_LOCATION + "/lib/ruby"
|
||||
VAR_LOCATION = ONE_LOCATION + "/var"
|
||||
end
|
||||
|
||||
$: << RUBY_LIB_LOCATION
|
||||
@ -125,6 +127,16 @@ CommandParser::CmdParser.new(ARGV) do
|
||||
end
|
||||
end
|
||||
|
||||
download_desc = <<-EOT.unindent
|
||||
Downloads a MarketApp to a file
|
||||
EOT
|
||||
|
||||
command :download, download_desc, :appid, :path do
|
||||
helper.perform_action(args[0],options,"downloaded") do |app|
|
||||
app.download(args[1], helper.client)
|
||||
end
|
||||
end
|
||||
|
||||
delete_desc = <<-EOT.unindent
|
||||
Deletes the given marketplace app
|
||||
EOT
|
||||
|
@ -252,6 +252,57 @@ module OpenNebula
|
||||
def snapshot_flatten(snap_id)
|
||||
return call(IMAGE_METHODS[:snapshotflatten], @pe_id, snap_id)
|
||||
end
|
||||
|
||||
#######################################################################
|
||||
# OCA specific methods
|
||||
#######################################################################
|
||||
|
||||
# Invokes 'download.sh' to copy the image to the specified path
|
||||
# It calls the <ds_mad>/export action and downloader.sh
|
||||
#
|
||||
# @param path The destination of the downloader.sh action
|
||||
# @param client The request client
|
||||
#
|
||||
# @return [nil, OpenNebula::Error] nil in case of success or Error
|
||||
def download(path, client)
|
||||
rc = info
|
||||
return rc if OpenNebula.is_error?(rc)
|
||||
|
||||
ds_id = self['DATASTORE_ID']
|
||||
ds = Datastore.new(Datastore.build_xml(ds_id), client)
|
||||
|
||||
rc = ds.info
|
||||
return rc if OpenNebula.is_error?(rc)
|
||||
|
||||
drv_message = "<DS_DRIVER_ACTION_DATA>" <<
|
||||
"#{to_xml}#{ds.to_xml}" <<
|
||||
"</DS_DRIVER_ACTION_DATA>"
|
||||
|
||||
drv_message_64 = Base64::strict_encode64(drv_message)
|
||||
|
||||
export = "#{VAR_LOCATION}/remotes/datastore/#{ds['DS_MAD']}/export"
|
||||
|
||||
export_stdout = `#{export} #{drv_message_64} #{id}`
|
||||
doc = REXML::Document.new(export_stdout).root
|
||||
|
||||
import_source = doc.elements['IMPORT_SOURCE'].text rescue nil
|
||||
|
||||
if import_source.nil? || import_source.empty?
|
||||
return OpenNebula::Error.new("Cannot find image source.")
|
||||
end
|
||||
|
||||
download_cmd = "#{VAR_LOCATION}/remotes/datastore/downloader.sh " <<
|
||||
"#{import_source} #{path}"
|
||||
|
||||
system(download_cmd)
|
||||
|
||||
if (status = $?.exitstatus) != 0
|
||||
error_msg = "Error executing '#{download_cmd}'. " <<
|
||||
"Exit status: #{status}"
|
||||
return OpenNebula::Error.new(error_msg)
|
||||
end
|
||||
end
|
||||
|
||||
#######################################################################
|
||||
# Helpers to get Image information
|
||||
#######################################################################
|
||||
|
@ -216,6 +216,45 @@ module OpenNebula
|
||||
end
|
||||
end
|
||||
|
||||
# Invokes 'download.sh' to download the app to the specified path
|
||||
#
|
||||
# @param path The destination of the downloader.sh action
|
||||
# @param client The request client
|
||||
#
|
||||
# @return [nil, OpenNebula::Error] nil in case of success or Error
|
||||
def download(path, client)
|
||||
rc = info
|
||||
return rc if OpenNebula.is_error?(rc)
|
||||
|
||||
market_id = self['MARKETPLACE_ID']
|
||||
market = MarketPlace.new(MarketPlace.build_xml(market_id), client)
|
||||
|
||||
rc = market.info
|
||||
return rc if OpenNebula.is_error?(rc)
|
||||
|
||||
# This 'drv_message' is missing some elements, compared to the one
|
||||
# sent by the core. However, 'downloader.sh' only requires the
|
||||
# MarketPlace information.
|
||||
drv_message = "<DS_DRIVER_ACTION_DATA>" <<
|
||||
"#{market.to_xml}" <<
|
||||
"</DS_DRIVER_ACTION_DATA>"
|
||||
|
||||
drv_message_64 = Base64::strict_encode64(drv_message)
|
||||
|
||||
ENV['DRV_ACTION'] = drv_message_64
|
||||
|
||||
download_cmd = "#{VAR_LOCATION}/remotes/datastore/downloader.sh " <<
|
||||
"#{self['SOURCE']} #{path}"
|
||||
|
||||
system(download_cmd)
|
||||
|
||||
if (status = $?.exitstatus) != 0
|
||||
error_msg = "Error executing '#{download_cmd}'. " <<
|
||||
"Exit status: #{status}"
|
||||
return OpenNebula::Error.new(error_msg)
|
||||
end
|
||||
end
|
||||
|
||||
# Enables this app
|
||||
def enable
|
||||
return call(MARKETPLACEAPP_METHODS[:enable], @pe_id, true)
|
||||
|
@ -53,8 +53,6 @@ define(function(require) {
|
||||
_setupCloseDropdownsOnClick();
|
||||
_insertUserAndZoneSelector();
|
||||
|
||||
Config.initOnedConf();
|
||||
|
||||
if (Config.isTabEnabled(PROVISION_TAB_ID)) {
|
||||
Sunstone.showTab(PROVISION_TAB_ID);
|
||||
$('#loading').hide();
|
||||
|
@ -1,114 +0,0 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2015, 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. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
define(function(require) {
|
||||
var OpenNebulaAction = require('./action');
|
||||
var Locale = require('utils/locale');
|
||||
var OpenNebulaError = require('./error');
|
||||
var OpenNebulaHelper = require('./helper');
|
||||
|
||||
|
||||
var onedconfCache;
|
||||
var onedconfWaiting = false;
|
||||
var onedconfCallbacks = [];
|
||||
|
||||
var CACHE_EXPIRE = 36000000; //ms
|
||||
|
||||
var _clearCache = function() {
|
||||
onedconfCache = null;
|
||||
//console.log("onedconf. Cache cleaned");
|
||||
};
|
||||
|
||||
var RESOURCE = "SYSTEM";
|
||||
|
||||
var System = {
|
||||
"resource": RESOURCE,
|
||||
"onedconf": function(params){
|
||||
var callback = params.success;
|
||||
var callbackError = params.error;
|
||||
var request = OpenNebulaHelper.request(RESOURCE, "onedconf");
|
||||
|
||||
if (onedconfCache &&
|
||||
onedconfCache["timestamp"] + CACHE_EXPIRE > new Date().getTime()) {
|
||||
|
||||
//console.log("onedconf. Cache used");
|
||||
|
||||
return callback ?
|
||||
callback(request, onedconfCache["pcis"]) : null;
|
||||
}
|
||||
|
||||
onedconfCallbacks.push({
|
||||
success : callback,
|
||||
error : callbackError
|
||||
});
|
||||
|
||||
//console.log("onedconf. Callback queued");
|
||||
|
||||
if (onedconfWaiting) {
|
||||
return;
|
||||
}
|
||||
|
||||
onedconfWaiting = true;
|
||||
|
||||
//console.log("onedconf. NO cache, calling ajax");
|
||||
|
||||
$.ajax({
|
||||
url: "onedconf",
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
success: function(response) {
|
||||
onedconfCache = {
|
||||
timestamp : new Date().getTime(),
|
||||
onedConf : response
|
||||
};
|
||||
|
||||
onedconfWaiting = false;
|
||||
|
||||
for (var i = 0; i < onedconfCallbacks.length; i++) {
|
||||
var callback = onedconfCallbacks[i].success;
|
||||
|
||||
if (callback) {
|
||||
//console.log("onedconf. Callback called");
|
||||
callback(request, response);
|
||||
}
|
||||
}
|
||||
|
||||
onedconfCallbacks = [];
|
||||
|
||||
return;
|
||||
},
|
||||
error: function(response) {
|
||||
onedconfWaiting = false;
|
||||
|
||||
for (var i = 0; i < onedconfCallbacks.length; i++) {
|
||||
var callback = onedconfCallbacks[i].error;
|
||||
|
||||
if (callback) {
|
||||
//console.log("onedconf. ERROR Callback called");
|
||||
callback(request, OpenNebulaError(response));
|
||||
}
|
||||
}
|
||||
|
||||
onedconfCallbacks = [];
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return System;
|
||||
})
|
@ -16,23 +16,10 @@
|
||||
|
||||
define(function(require) {
|
||||
require('jquery');
|
||||
var OpenNebulaSystem = require('opennebula/system');
|
||||
|
||||
// Clone the local config object in a private var
|
||||
var _config = $.extend(true, {}, config);
|
||||
|
||||
var _defaultCost = {
|
||||
cpuCost : 0,
|
||||
memoryCost : 0,
|
||||
diskCost : 0
|
||||
};
|
||||
|
||||
var _dsMadConf = {};
|
||||
var _imMadConf = {};
|
||||
var _vmMadConf = {};
|
||||
var _authMadConf = {};
|
||||
var _marketMadConf = {};
|
||||
|
||||
var Config = {
|
||||
'isTabEnabled': function(tabName) {
|
||||
var enabled = _config['view']['enabled_tabs'].indexOf(tabName) != -1;
|
||||
@ -157,55 +144,7 @@ define(function(require) {
|
||||
'logo': (_config['view']["small_logo"] || "images/one_small_logo.png"),
|
||||
'vmLogos': (_config['vm_logos']),
|
||||
'enabledTabs': _config['view']['enabled_tabs'],
|
||||
"defaultCost" : _defaultCost,
|
||||
'dsMadConf' : _dsMadConf,
|
||||
'imMadConf' : _imMadConf,
|
||||
'vmMadConf' : _vmMadConf,
|
||||
'authMadConf' : _authMadConf,
|
||||
'marketMadConf' : _marketMadConf,
|
||||
"initOnedConf" : function() {
|
||||
OpenNebulaSystem.onedconf({
|
||||
data : {},
|
||||
timeout: true,
|
||||
success: function (request, onedconf){
|
||||
if (onedconf.DEFAULT_COST != undefined){
|
||||
if (onedconf.DEFAULT_COST.CPU_COST != undefined){
|
||||
_defaultCost.cpuCost = parseInt(onedconf.DEFAULT_COST.CPU_COST);
|
||||
}
|
||||
if (onedconf.DEFAULT_COST.MEMORY_COST != undefined){
|
||||
_defaultCost.memoryCost = parseInt(onedconf.DEFAULT_COST.MEMORY_COST);
|
||||
}
|
||||
if (onedconf.DEFAULT_COST.DISK_COST != undefined){
|
||||
_defaultCost.diskCost = parseInt(onedconf.DEFAULT_COST.DISK_COST);
|
||||
}
|
||||
}
|
||||
|
||||
if (onedconf.DS_MAD_CONF != undefined){
|
||||
$.extend(true, _dsMadConf, onedconf.DS_MAD_CONF);
|
||||
}
|
||||
|
||||
if (onedconf.MARKET_MAD_CONF != undefined){
|
||||
$.extend(true, _marketMadConf, onedconf.MARKET_MAD_CONF);
|
||||
}
|
||||
|
||||
if (onedconf.IM_MAD != undefined){
|
||||
$.extend(true, _imMadConf, onedconf.IM_MAD);
|
||||
}
|
||||
|
||||
if (onedconf.VM_MAD != undefined){
|
||||
$.extend(true, _vmMadConf, onedconf.VM_MAD);
|
||||
}
|
||||
|
||||
if (onedconf.AUTH_MAD != undefined){
|
||||
$.extend(true, _authMadConf, onedconf.AUTH_MAD);
|
||||
}
|
||||
},
|
||||
error: function(request, error_json){
|
||||
console.error("There was an error requesting oned.conf: "+
|
||||
error_json.error.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
'onedConf': _config['oned_conf']
|
||||
}
|
||||
|
||||
return Config;
|
||||
|
@ -554,17 +554,19 @@ define(function(require) {
|
||||
$('[required_active]', dialog).removeAttr('required')
|
||||
.removeAttr('required_active');
|
||||
|
||||
$.each(Config.dsMadConf, function(i, e){
|
||||
if (e["NAME"] == mad) {
|
||||
if (!$.isEmptyObject(e["REQUIRED_ATTRS"])) {
|
||||
$.each(e["REQUIRED_ATTRS"].split(","), function(i, e){
|
||||
$('#' + e.toLowerCase(), dialog).attr('required', true).attr('required_active', '');
|
||||
});
|
||||
if (Config.onedConf.DS_MAD_CONF !== undefined) {
|
||||
$.each(Config.onedConf.DS_MAD_CONF, function(i, e){
|
||||
if (e["NAME"] == mad) {
|
||||
if (!$.isEmptyObject(e["REQUIRED_ATTRS"])) {
|
||||
$.each(e["REQUIRED_ATTRS"].split(","), function(i, e){
|
||||
$('#' + e.toLowerCase(), dialog).attr('required', true).attr('required_active', '');
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -65,15 +65,15 @@ define(function(require) {
|
||||
var that = this;
|
||||
|
||||
that.vmMadNameList = [];
|
||||
if (Config.vmMadConf !== undefined) {
|
||||
$.each(Config.vmMadConf, function(index, vmMad) {
|
||||
if (Config.onedConf.VM_MAD !== undefined) {
|
||||
$.each(Config.onedConf.VM_MAD, function(index, vmMad) {
|
||||
that.vmMadNameList.push(vmMad["NAME"]);
|
||||
});
|
||||
}
|
||||
|
||||
that.imMadNameList = [];
|
||||
if (Config.imMadConf !== undefined) {
|
||||
$.each(Config.imMadConf, function(index, imMad) {
|
||||
if (Config.onedConf.IM_MAD !== undefined) {
|
||||
$.each(Config.onedConf.IM_MAD, function(index, imMad) {
|
||||
that.imMadNameList.push(imMad["NAME"]);
|
||||
});
|
||||
}
|
||||
|
@ -145,18 +145,20 @@ define(function(require) {
|
||||
var pers_forced = false;
|
||||
|
||||
// Set the persistency
|
||||
$.each(Config.dsMadConf,function(i,e){
|
||||
if (e["NAME"] == mad && !$.isEmptyObject(e["PERSISTENT_ONLY"])) {
|
||||
if (e["PERSISTENT_ONLY"] != undefined &&
|
||||
e["PERSISTENT_ONLY"].toLowerCase() == "yes") {
|
||||
$('#img_persistent', context).prop('disabled', true);
|
||||
$('#img_persistent', context).prop('checked', true);
|
||||
pers_forced = true;
|
||||
return false;
|
||||
if (Config.onedConf.DS_MAD_CONF !== undefined) {
|
||||
$.each(Config.onedConf.DS_MAD_CONF, function(i,e){
|
||||
if (e["NAME"] == mad && !$.isEmptyObject(e["PERSISTENT_ONLY"])) {
|
||||
if (e["PERSISTENT_ONLY"] != undefined &&
|
||||
e["PERSISTENT_ONLY"].toLowerCase() == "yes") {
|
||||
$('#img_persistent', context).prop('disabled', true);
|
||||
$('#img_persistent', context).prop('checked', true);
|
||||
pers_forced = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
if (!pers_forced) {
|
||||
$('#img_persistent', context).prop('disabled', false);
|
||||
|
@ -137,8 +137,8 @@ define(function(require) {
|
||||
};
|
||||
|
||||
that.marketMadNameList = [];
|
||||
if (Config.marketMadConf !== undefined) {
|
||||
$.each(Config.marketMadConf, function(index, marketMad) {
|
||||
if (Config.onedConf.MARKET_MAD_CONF !== undefined) {
|
||||
$.each(Config.onedConf.MARKET_MAD_CONF, function(index, marketMad) {
|
||||
that.marketMadNameList.push(marketMad["NAME"]);
|
||||
});
|
||||
}
|
||||
@ -250,17 +250,19 @@ define(function(require) {
|
||||
|
||||
// Show attributes for the selected market mad and set the required ones
|
||||
$('.market-mad-attr-container.' + marketMADName).show();
|
||||
$.each(Config.marketMadConf, function(i, e){
|
||||
if (e["NAME"] == marketMADName) {
|
||||
if (!$.isEmptyObject(e["REQUIRED_ATTRS"])) {
|
||||
$.each(e["REQUIRED_ATTRS"].split(","), function(i, attrName){
|
||||
$('#' + attrName, dialog).attr('required', true);
|
||||
});
|
||||
if (Config.onedConf.MARKET_MAD_CONF !== undefined) {
|
||||
$.each(Config.onedConf.MARKET_MAD_CONF, function(i, e){
|
||||
if (e["NAME"] == marketMADName) {
|
||||
if (!$.isEmptyObject(e["REQUIRED_ATTRS"])) {
|
||||
$.each(e["REQUIRED_ATTRS"].split(","), function(i, attrName){
|
||||
$('#' + attrName, dialog).attr('required', true);
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -193,15 +193,15 @@ define(function(require) {
|
||||
var diskCost = capacity.DISK_COST;
|
||||
|
||||
if (cpuCost == undefined){
|
||||
cpuCost = Config.defaultCost.cpuCost;
|
||||
cpuCost = Config.onedConf.DEFAULT_COST.CPU_COST;
|
||||
}
|
||||
|
||||
if (memoryCost == undefined){
|
||||
memoryCost = Config.defaultCost.memoryCost;
|
||||
memoryCost = Config.onedConf.DEFAULT_COST.MEMORY_COST;
|
||||
}
|
||||
|
||||
if (diskCost == undefined){
|
||||
diskCost = Config.defaultCost.diskCost;
|
||||
diskCost = Config.onedConf.DEFAULT_COST.DISK_COST;
|
||||
}
|
||||
|
||||
if ((cpuCost != 0 || memoryCost != 0 || diskCost != 0) && Config.isFeatureEnabled("showback")) {
|
||||
@ -357,11 +357,11 @@ define(function(require) {
|
||||
var memoryCost = capacity.MEMORY_COST;
|
||||
|
||||
if (cpuCost == undefined){
|
||||
cpuCost = Config.defaultCost.cpuCost;
|
||||
cpuCost = Config.onedConf.DEFAULT_COST.CPU_COST;
|
||||
}
|
||||
|
||||
if (memoryCost == undefined){
|
||||
memoryCost = Config.defaultCost.memoryCost;
|
||||
memoryCost = Config.onedConf.DEFAULT_COST.MEMORY_COST;
|
||||
}
|
||||
|
||||
var _redoCost = function(values){
|
||||
|
@ -73,8 +73,12 @@ define(function(require) {
|
||||
|
||||
function _setup(context) {
|
||||
$("input[name='graphics_type']", context).change(function() {
|
||||
$("#TYPE", context).val($(this).attr("value"))
|
||||
$("#LISTEN", context).val("0.0.0.0")
|
||||
$("#TYPE", context).val($(this).attr("value"));
|
||||
if ($(this).attr("value") !== '') {
|
||||
$("#LISTEN", context).val("0.0.0.0");
|
||||
} else {
|
||||
$("#LISTEN", context).val('');
|
||||
}
|
||||
});
|
||||
|
||||
context.off("click", '#add_input');
|
||||
|
@ -20,6 +20,8 @@
|
||||
<legend>{{tr "Graphics"}}</legend>
|
||||
<div class="row">
|
||||
<div class="large-12 columns text-center">
|
||||
<input type="radio" name="graphics_type" ID="radioNoneType" value="">
|
||||
<label for="radioNoneType">{{tr "None"}}</label>
|
||||
<input type="radio" name="graphics_type" ID="radioVncType" value="VNC">
|
||||
<label for="radioVncType">VNC</label>
|
||||
<input type="radio" name="graphics_type" ID="radioSdlType" value="SDL" class="hypervisor only_kvm only_vmware only_xen" >
|
||||
|
@ -201,11 +201,11 @@ define(function(require) {
|
||||
var memoryCost = template_json.VMTEMPLATE.TEMPLATE.MEMORY_COST;
|
||||
|
||||
if (cpuCost == undefined){
|
||||
cpuCost = Config.defaultCost.cpuCost;
|
||||
cpuCost = Config.onedConf.DEFAULT_COST.CPU_COST;
|
||||
}
|
||||
|
||||
if (memoryCost == undefined){
|
||||
memoryCost = Config.defaultCost.memoryCost;
|
||||
memoryCost = Config.onedConf.DEFAULT_COST.MEMORY_COST;
|
||||
}
|
||||
|
||||
if ((cpuCost != 0 || memoryCost != 0) && Config.isFeatureEnabled("showback")) {
|
||||
|
@ -48,8 +48,8 @@ define(function(require) {
|
||||
this.options.auth_driver = true;
|
||||
}
|
||||
|
||||
if (Config.authMadConf !== undefined && Config.authMadConf['AUTHN'] !== undefined) {
|
||||
this.authMadNameList = Config.authMadConf['AUTHN'].split(',');
|
||||
if (Config.onedConf.AUTH_MAD !== undefined && Config.onedConf.AUTH_MAD['AUTHN'] !== undefined) {
|
||||
this.authMadNameList = Config.onedConf.AUTH_MAD['AUTHN'].split(',');
|
||||
} else {
|
||||
this.authMadNameList = []
|
||||
}
|
||||
|
@ -82,11 +82,11 @@ define(function(require) {
|
||||
var memoryCost = this.element.TEMPLATE.MEMORY_COST;
|
||||
|
||||
if (cpuCost == undefined){
|
||||
cpuCost = Config.defaultCost.cpuCost;
|
||||
cpuCost = Config.onedConf.DEFAULT_COST.CPU_COST;
|
||||
}
|
||||
|
||||
if (memoryCost == undefined){
|
||||
memoryCost = Config.defaultCost.memoryCost;
|
||||
memoryCost = Config.onedConf.DEFAULT_COST.MEMORY_COST;
|
||||
}
|
||||
|
||||
return TemplateInfo({
|
||||
|
@ -72,7 +72,7 @@ define(function(require) {
|
||||
var diskCost = this.element.TEMPLATE.DISK_COST;
|
||||
|
||||
if (diskCost == undefined){
|
||||
diskCost = Config.defaultCost.diskCost;
|
||||
diskCost = Config.onedConf.DEFAULT_COST.DISK_COST;
|
||||
}
|
||||
|
||||
return TemplateHtml({
|
||||
|
@ -68,7 +68,7 @@ define(function(require) {
|
||||
|
||||
NicsSection.insert({},
|
||||
$(".nicsContext", context),
|
||||
{floatingIP: true, management: true,
|
||||
{floatingIP: true, forceIPv4:true, management: true,
|
||||
hide_add_button:true,
|
||||
click_add_button:true
|
||||
});
|
||||
|
@ -108,7 +108,7 @@ define(function(require) {
|
||||
|
||||
NicsSection.insert({},
|
||||
$(".nicsContext", context),
|
||||
{floatingIP: true, management: true});
|
||||
{floatingIP: true, forceIPv4:true, management: true});
|
||||
|
||||
this.templatesTable.initialize();
|
||||
|
||||
|
@ -81,6 +81,34 @@ define(function(require) {
|
||||
nics = [this.element.TEMPLATE.NIC];
|
||||
}
|
||||
|
||||
$.map(nics, function(nic){
|
||||
if (nic.NETWORK == undefined){
|
||||
nic.NETWORK = "--";
|
||||
}
|
||||
|
||||
if (nic.FLOATING_IP != undefined && nic.FLOATING_IP.toUpperCase() == "YES"){
|
||||
if(nic.IP == undefined){
|
||||
nic.IP = "--";
|
||||
}
|
||||
|
||||
if(nic.IP6_ULA == undefined){
|
||||
nic.IP6_ULA = "--";
|
||||
}
|
||||
|
||||
if(nic.IP6_GLOBAL == undefined){
|
||||
nic.IP6_GLOBAL = "--";
|
||||
}
|
||||
} else {
|
||||
nic.IP = "--";
|
||||
nic.IP6_ULA = "--";
|
||||
nic.IP6_GLOBAL = "--";
|
||||
}
|
||||
|
||||
if(nic.VROUTER_MANAGEMENT == undefined){
|
||||
nic.VROUTER_MANAGEMENT = "--";
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: simplify interface?
|
||||
var strippedTemplate = $.extend({}, this.element.TEMPLATE);
|
||||
delete strippedTemplate["NIC"];
|
||||
|
@ -61,10 +61,10 @@
|
||||
<tr>
|
||||
<td class="nic_id" nic_id="{{NIC_ID}}">{{NIC_ID}}</td>
|
||||
<td>{{NETWORK}}</td>
|
||||
<td>{{valOrDefault IP "--"}}</td>
|
||||
<td>{{valOrDefault IP6_ULA "--"}}</td>
|
||||
<td>{{valOrDefault IP6_GLOBAL "--"}}</td>
|
||||
<td>{{valOrDefault VROUTER_MANAGEMENT "--"}}</td>
|
||||
<td>{{IP}}</td>
|
||||
<td>{{IP6_ULA}}</td>
|
||||
<td>{{IP6_GLOBAL}}</td>
|
||||
<td>{{VROUTER_MANAGEMENT}}</td>
|
||||
<td>
|
||||
{{#isTabActionEnabled "vrouters-tab" "VirtualRouter.detachnic"}}
|
||||
<a href="VirtualRouter.detachnic" class="detachnic" ><i class="fa fa-times"/>
|
||||
|
@ -77,7 +77,7 @@ define(function(require){
|
||||
var disk_cost = template_json.VMTEMPLATE.TEMPLATE.DISK_COST;
|
||||
|
||||
if (disk_cost == undefined) {
|
||||
disk_cost = Config.defaultCost.diskCost;
|
||||
disk_cost = Config.onedConf.DEFAULT_COST.DISK_COST;
|
||||
}
|
||||
|
||||
if (disk_cost != 0 && Config.isFeatureEnabled("showback")) {
|
||||
|
@ -39,6 +39,8 @@ define(function(require) {
|
||||
* - click_add_button {bool}
|
||||
* - floatingIP {bool}: true to show the
|
||||
* floating IP checkbox
|
||||
* - forceIPv4 {bool}: true to show the
|
||||
* input to select the IPv4
|
||||
* - management {bool}: true to show the
|
||||
* management checkbox
|
||||
*/
|
||||
@ -91,12 +93,12 @@ define(function(require) {
|
||||
if (nic) {
|
||||
if ($("input.floating_ip", $(this)).prop("checked")){
|
||||
nic["FLOATING_IP"] = "YES";
|
||||
}
|
||||
|
||||
var ip4 = $("input.manual_ip4", $(this)).val();
|
||||
var ip4 = $("input.manual_ip4", $(this)).val();
|
||||
|
||||
if (ip4 != ""){
|
||||
nic["IP"] = ip4;
|
||||
}
|
||||
if (ip4 != undefined && ip4 != ""){
|
||||
nic["IP"] = ip4;
|
||||
}
|
||||
|
||||
if ($("input.management", $(this)).prop("checked")){
|
||||
@ -117,6 +119,8 @@ define(function(require) {
|
||||
* - vnet_attr {object}
|
||||
* - floatingIP {bool}: true to show the
|
||||
* floating IP checkbox
|
||||
* - forceIPv4 {bool}: true to show the
|
||||
* input to select the IPv4
|
||||
* - management {bool}: true to show the
|
||||
* management checkbox
|
||||
*/
|
||||
@ -276,13 +280,17 @@ define(function(require) {
|
||||
'</span>' +
|
||||
'</label>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
}
|
||||
|
||||
if (options.forceIPv4){
|
||||
html +=
|
||||
'<div class="row noclick">' +
|
||||
'<div class="small-5 columns">' +
|
||||
'<label class="right inline" style="color: #777; font-size: 16px">' +
|
||||
Locale.tr("Force IPv4:") + " " +
|
||||
'<span class="tip">' +
|
||||
Locale.tr("Optionally, you can force the IP assigned to the floating IP.") +
|
||||
Locale.tr("Optionally, you can force the IP assigned to the network interface.") +
|
||||
'</span>' +
|
||||
'</label>' +
|
||||
'</div>' +
|
||||
@ -312,8 +320,6 @@ define(function(require) {
|
||||
Tips.setup($(".selected_network", dd_context));
|
||||
|
||||
$('a', dd_context).first().trigger("click");
|
||||
|
||||
$("input.floating_ip", dd_context).change();
|
||||
})
|
||||
|
||||
dd_context.on("click", ".provision_remove_nic" , function() {
|
||||
@ -325,10 +331,6 @@ define(function(require) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
dd_context.on("change", "input.floating_ip" , function() {
|
||||
$(".manual_ip4", dd_context).prop("disabled", !$(this).is(":checked"));
|
||||
});
|
||||
|
||||
if (!options.nic && !options.vnet_attr) {
|
||||
$('a', dd_context).trigger("click");
|
||||
}
|
||||
@ -343,6 +345,8 @@ define(function(require) {
|
||||
* - click_add_button {bool}
|
||||
* - floatingIP {bool}: true to show the
|
||||
* floating IP checkbox
|
||||
* - forceIPv4 {bool}: true to show the
|
||||
* input to select the IPv4
|
||||
* - management {bool}: true to show the
|
||||
* management checkbox
|
||||
*/
|
||||
|
@ -56,6 +56,13 @@ GROUP_ADMIN_DEFAULT_VIEW_XPATH = 'TEMPLATE/SUNSTONE/GROUP_ADMIN_DEFAULT_VIEW'
|
||||
TABLE_DEFAULT_PAGE_LENGTH_XPATH = 'TEMPLATE/SUNSTONE/TABLE_DEFAULT_PAGE_LENGTH'
|
||||
LANG_XPATH = 'TEMPLATE/SUNSTONE/LANG'
|
||||
|
||||
# If no costs are defined in oned.conf these values will be used
|
||||
DEFAULT_COST = {
|
||||
'CPU_COST' => 0,
|
||||
'MEMORY_COST' => 0,
|
||||
'DISK_COST' => 0
|
||||
};
|
||||
|
||||
##############################################################################
|
||||
# Required libraries
|
||||
##############################################################################
|
||||
@ -384,9 +391,42 @@ get '/' do
|
||||
error 500, ""
|
||||
end
|
||||
|
||||
serveradmin_client = $cloud_auth.client(nil, session[:active_zone_endpoint])
|
||||
|
||||
rc = OpenNebula::System.new(serveradmin_client).get_configuration
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
logger.error { rc.message }
|
||||
error 500, ""
|
||||
end
|
||||
|
||||
oned_conf_template = rc.to_hash()['TEMPLATE']
|
||||
|
||||
keys = [
|
||||
:DEFAULT_COST,
|
||||
:DS_MAD_CONF,
|
||||
:MARKET_MAD_CONF,
|
||||
:VM_MAD,
|
||||
:IM_MAD,
|
||||
:AUTH_MAD
|
||||
]
|
||||
|
||||
oned_conf = {}
|
||||
keys.each do |key|
|
||||
if key == :DEFAULT_COST
|
||||
if oned_conf_template[key.to_s]
|
||||
oned_conf[key] = oned_conf_template[key.to_s]
|
||||
else
|
||||
oned_conf[key] = DEFAULT_COST
|
||||
end
|
||||
else
|
||||
oned_conf[key] = oned_conf_template[key.to_s]
|
||||
end
|
||||
end
|
||||
|
||||
response.set_cookie("one-user", :value=>"#{session[:user]}")
|
||||
|
||||
erb :index, :locals => {:logos_conf => logos_conf}
|
||||
erb :index, :locals => {:logos_conf => logos_conf, :oned_conf => oned_conf}
|
||||
end
|
||||
|
||||
get '/login' do
|
||||
@ -509,35 +549,6 @@ get '/infrastructure' do
|
||||
[200, infrastructure.to_json]
|
||||
end
|
||||
|
||||
get '/onedconf' do
|
||||
serveradmin_client = $cloud_auth.client(nil, session[:active_zone_endpoint])
|
||||
|
||||
rc = OpenNebula::System.new(serveradmin_client).get_configuration
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
logger.error { rc.message }
|
||||
error 500, ""
|
||||
end
|
||||
|
||||
onedconf_template = rc.to_hash()['TEMPLATE']
|
||||
|
||||
keys = [
|
||||
:DEFAULT_COST,
|
||||
:DS_MAD_CONF,
|
||||
:MARKET_MAD_CONF,
|
||||
:VM_MAD,
|
||||
:IM_MAD,
|
||||
:AUTH_MAD
|
||||
]
|
||||
|
||||
onedconf = {}
|
||||
keys.each do |key|
|
||||
onedconf[key] = onedconf_template[key.to_s]
|
||||
end
|
||||
|
||||
[200, onedconf.to_json]
|
||||
end
|
||||
|
||||
get '/vm/:id/log' do
|
||||
@SunstoneServer.get_vm_log(params[:id])
|
||||
end
|
||||
|
@ -42,7 +42,8 @@
|
||||
'display_name' : '<%= session[:display_name] %>',
|
||||
'zone_name' : '<%= session[:zone_name] %>',
|
||||
'page_length' : '<%= session[:page_length] %>',
|
||||
'vm_logos' : <%= logos_conf.to_json %>
|
||||
'vm_logos' : <%= logos_conf.to_json %>,
|
||||
'oned_conf' : <%= oned_conf.to_json %>
|
||||
};
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user