mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-23 17:33:56 +03:00
Merge branch 'feature-1303'
This commit is contained in:
commit
a088b8d2fa
26
install.sh
26
install.sh
@ -198,6 +198,7 @@ LIB_DIRS="$LIB_LOCATION/ruby \
|
||||
$LIB_LOCATION/ruby/cloud/econe \
|
||||
$LIB_LOCATION/ruby/cloud/econe/views \
|
||||
$LIB_LOCATION/ruby/cloud/occi \
|
||||
$LIB_LOCATION/ruby/cloud/marketplace \
|
||||
$LIB_LOCATION/ruby/cloud/CloudAuth \
|
||||
$LIB_LOCATION/ruby/onedb \
|
||||
$LIB_LOCATION/mads \
|
||||
@ -341,6 +342,10 @@ LIB_OCCI_CLIENT_DIRS="$LIB_LOCATION/ruby \
|
||||
$LIB_LOCATION/ruby/OpenNebula \
|
||||
$LIB_LOCATION/ruby/cloud/occi"
|
||||
|
||||
LIB_MARKET_CLIENT_DIRS="$LIB_LOCATION/ruby \
|
||||
$LIB_LOCATION/ruby/OpenNebula \
|
||||
$LIB_LOCATION/ruby/cloud/marketplace"
|
||||
|
||||
LIB_OCA_CLIENT_DIRS="$LIB_LOCATION/ruby \
|
||||
$LIB_LOCATION/ruby/OpenNebula"
|
||||
|
||||
@ -350,7 +355,7 @@ LIB_CLI_CLIENT_DIRS="$LIB_LOCATION/ruby/cli \
|
||||
CONF_CLI_DIRS="$ETC_LOCATION/cli"
|
||||
|
||||
if [ "$CLIENT" = "yes" ]; then
|
||||
MAKE_DIRS="$MAKE_DIRS $LIB_ECO_CLIENT_DIRS $LIB_OCCI_CLIENT_DIRS \
|
||||
MAKE_DIRS="$MAKE_DIRS $LIB_ECO_CLIENT_DIRS $LIB_OCCI_CLIENT_DIRS $LIB_MARKET_CLIENT_DIRS \
|
||||
$LIB_OCA_CLIENT_DIRS $LIB_CLI_CLIENT_DIRS $CONF_CLI_DIRS \
|
||||
$ETC_LOCATION $OZONES_CLIENT_DIRS $SELF_SERVICE_DIRS"
|
||||
elif [ "$SUNSTONE" = "yes" ]; then
|
||||
@ -426,6 +431,8 @@ INSTALL_FILES=(
|
||||
ECO_BIN_FILES:$BIN_LOCATION
|
||||
OCCI_LIB_FILES:$LIB_LOCATION/ruby/cloud/occi
|
||||
OCCI_BIN_FILES:$BIN_LOCATION
|
||||
MARKET_LIB_FILES:$LIB_LOCATION/ruby/cloud/marketplace
|
||||
MARKET_BIN_FILES:$BIN_LOCATION
|
||||
MAN_FILES:$MAN_LOCATION
|
||||
CLI_LIB_FILES:$LIB_LOCATION/ruby/cli
|
||||
ONE_CLI_LIB_FILES:$LIB_LOCATION/ruby/cli/one_helper
|
||||
@ -438,6 +445,8 @@ INSTALL_CLIENT_FILES=(
|
||||
COMMON_CLOUD_CLIENT_LIB_FILES:$LIB_LOCATION/ruby/cloud
|
||||
OCCI_LIB_CLIENT_FILES:$LIB_LOCATION/ruby/cloud/occi
|
||||
OCCI_BIN_CLIENT_FILES:$BIN_LOCATION
|
||||
MARKET_LIB_CLIENT_FILES:$LIB_LOCATION/ruby/cloud/marketplace
|
||||
MARKET_BIN_CLIENT_FILES:$BIN_LOCATION
|
||||
CLI_BIN_FILES:$BIN_LOCATION
|
||||
CLI_LIB_FILES:$LIB_LOCATION/ruby/cli
|
||||
ONE_CLI_LIB_FILES:$LIB_LOCATION/ruby/cli/one_helper
|
||||
@ -1112,6 +1121,19 @@ OCCI_ETC_TEMPLATE_FILES="src/cloud/occi/etc/templates/common.erb \
|
||||
src/cloud/occi/etc/templates/network.erb \
|
||||
src/cloud/occi/etc/templates/large.erb"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Marketplace Client
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
MARKET_LIB_FILES="src/cloud/marketplace/lib/marketplace_client.rb"
|
||||
|
||||
MARKET_LIB_CLIENT_FILES="src/cloud/marketplace/lib/marketplace_client.rb"
|
||||
|
||||
MARKET_BIN_FILES="src/cloud/marketplace/bin/onemarket"
|
||||
|
||||
MARKET_BIN_CLIENT_FILES="src/cloud/marketplace/bin/onemarket"
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# CLI files
|
||||
#-----------------------------------------------------------------------------
|
||||
@ -1171,6 +1193,7 @@ SUNSTONE_ETC_FILES="src/sunstone/etc/sunstone-server.conf \
|
||||
|
||||
SUNSTONE_MODELS_FILES="src/sunstone/models/OpenNebulaJSON.rb \
|
||||
src/sunstone/models/SunstoneServer.rb \
|
||||
src/sunstone/models/SunstoneMarketplace.rb \
|
||||
src/sunstone/models/SunstonePlugins.rb"
|
||||
|
||||
SUNSTONE_MODELS_JSON_FILES="src/sunstone/models/OpenNebulaJSON/HostJSON.rb \
|
||||
@ -1215,6 +1238,7 @@ SUNSTONE_PUBLIC_JS_PLUGINS_FILES="\
|
||||
src/sunstone/public/js/plugins/vms-tab.js \
|
||||
src/sunstone/public/js/plugins/acls-tab.js \
|
||||
src/sunstone/public/js/plugins/vnets-tab.js \
|
||||
src/sunstone/public/js/plugins/marketplace-tab.js \
|
||||
src/sunstone/public/js/plugins/config-tab.js"
|
||||
|
||||
SUNSTONE_PUBLIC_CSS_FILES="src/sunstone/public/css/application.css \
|
||||
|
184
src/cloud/marketplace/bin/onemarket
Executable file
184
src/cloud/marketplace/bin/onemarket
Executable file
@ -0,0 +1,184 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2012, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
ONE_LOCATION=ENV["ONE_LOCATION"]
|
||||
|
||||
if !ONE_LOCATION
|
||||
RUBY_LIB_LOCATION="/usr/lib/one/ruby"
|
||||
else
|
||||
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
|
||||
TEMPLATES_LOCATION=ONE_LOCATION+"/etc/occi_templates"
|
||||
CONF_LOCATION=ONE_LOCATION+"/etc"
|
||||
end
|
||||
|
||||
$: << RUBY_LIB_LOCATION
|
||||
$: << RUBY_LIB_LOCATION+"/cloud"
|
||||
|
||||
require 'marketplace/marketplace_client'
|
||||
|
||||
require 'cli/command_parser'
|
||||
require 'cli/cli_helper'
|
||||
|
||||
require 'rubygems'
|
||||
require 'json'
|
||||
|
||||
#
|
||||
# Options
|
||||
#
|
||||
|
||||
DEFAULT_OPTIONS = [
|
||||
ENDPOINT = {
|
||||
:name => "server",
|
||||
:short => "-s url",
|
||||
:large => "--server url",
|
||||
:format => String,
|
||||
:description => "Marketplace endpoint"
|
||||
},
|
||||
USERNAME={
|
||||
:name => "username",
|
||||
:short => "-u name",
|
||||
:large => "--username name",
|
||||
:format => String,
|
||||
:description => "User name"
|
||||
},
|
||||
PASSWORD={
|
||||
:name => "password",
|
||||
:short => "-p pass",
|
||||
:large => "--password pass",
|
||||
:format => String,
|
||||
:description => "User password"
|
||||
}
|
||||
]
|
||||
|
||||
JSON_FORMAT={
|
||||
:name => "json",
|
||||
:short => "-j",
|
||||
:large => "--json",
|
||||
:description => "Show in JSON format"
|
||||
}
|
||||
|
||||
#
|
||||
# Table
|
||||
#
|
||||
|
||||
TABLE = CLIHelper::ShowTable.new(nil, self) do
|
||||
column :ID, "Appliance", :size=>25 do |d|
|
||||
d["_id"]["$oid"]
|
||||
end
|
||||
|
||||
column :NAME, "Name", :size=>50 do |d|
|
||||
d["name"]
|
||||
end
|
||||
|
||||
column :PUBLISHER, "Publisher", :size=>15 do |d|
|
||||
d["publisher"]
|
||||
end
|
||||
|
||||
default :ID, :NAME, :PUBLISHER
|
||||
end
|
||||
|
||||
#
|
||||
# Commands
|
||||
#
|
||||
|
||||
cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
usage "`onemarket` <command> [<args>] [<options>]"
|
||||
|
||||
set :option, DEFAULT_OPTIONS
|
||||
|
||||
#
|
||||
# List
|
||||
#
|
||||
|
||||
list_desc = <<-EOT.unindent
|
||||
List the available appliances in the Marketplace
|
||||
EOT
|
||||
|
||||
command :list, list_desc, :options => JSON_FORMAT do
|
||||
client = Market::ApplianceClient.new(
|
||||
options[:username],
|
||||
options[:password],
|
||||
options[:server])
|
||||
|
||||
response = client.list
|
||||
|
||||
if CloudClient::is_error?(response)
|
||||
[response.code.to_i, response.to_s]
|
||||
else
|
||||
if options[:json]
|
||||
[0,response.body]
|
||||
else
|
||||
array_list = JSON.parse(response.body)
|
||||
TABLE.show(array_list['appliances'])
|
||||
0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Create
|
||||
#
|
||||
|
||||
create_desc = <<-EOT.unindent
|
||||
Create a new appliance in the Marketplace
|
||||
EOT
|
||||
|
||||
command :create, create_desc, :file do
|
||||
client = Market::ApplianceClient.new(
|
||||
options[:username],
|
||||
options[:password],
|
||||
options[:server])
|
||||
|
||||
response = client.create(File.read(args[0]))
|
||||
|
||||
if CloudClient::is_error?(response)
|
||||
[response.code.to_i, response.to_s]
|
||||
else
|
||||
[0, response.body]
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Show
|
||||
#
|
||||
|
||||
show_desc = <<-EOT.unindent
|
||||
Show detailed information of a given appliance
|
||||
EOT
|
||||
|
||||
command :show, show_desc, :id, :options => JSON_FORMAT do
|
||||
client = Market::ApplianceClient.new(
|
||||
options[:username],
|
||||
options[:password],
|
||||
options[:server])
|
||||
|
||||
response = client.show(args[0])
|
||||
|
||||
if CloudClient::is_error?(response)
|
||||
[response.code.to_i, response.to_s]
|
||||
else
|
||||
if options[:json]
|
||||
[0,response.body]
|
||||
else
|
||||
array_list = JSON.parse(response.body)
|
||||
TABLE.show(array_list['appliances'])
|
||||
0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
76
src/cloud/marketplace/lib/marketplace_client.rb
Normal file
76
src/cloud/marketplace/lib/marketplace_client.rb
Normal file
@ -0,0 +1,76 @@
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2012, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
require 'uri'
|
||||
require 'cloud/CloudClient'
|
||||
|
||||
module Market
|
||||
class Client
|
||||
def initialize(username, password, url)
|
||||
@username = username
|
||||
@password = password
|
||||
url ||= 'http://localhost:9292/'
|
||||
|
||||
@uri = URI.parse(url)
|
||||
end
|
||||
|
||||
def get(path)
|
||||
req = Net::HTTP::Get.new(path)
|
||||
|
||||
do_request(req)
|
||||
end
|
||||
|
||||
def post(path, body)
|
||||
req = Net::HTTP::Post.new(path)
|
||||
req.body = body
|
||||
|
||||
do_request(req)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def do_request(req)
|
||||
if @username && @password
|
||||
req.basic_auth @username, @password
|
||||
end
|
||||
|
||||
res = CloudClient::http_start(@uri, @timeout) do |http|
|
||||
http.request(req)
|
||||
end
|
||||
|
||||
res
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
class ApplianceClient < Client
|
||||
def initialize(user, password, url)
|
||||
super(user, password, url)
|
||||
end
|
||||
|
||||
def list
|
||||
get("/appliance")
|
||||
end
|
||||
|
||||
def create(body)
|
||||
post("/appliance", body)
|
||||
end
|
||||
|
||||
def show(id)
|
||||
get("/appliance/#{id}")
|
||||
end
|
||||
end
|
||||
end
|
@ -70,3 +70,7 @@
|
||||
:ALL: true
|
||||
:user:
|
||||
:group:
|
||||
- plugins/marketplace-tab.js:
|
||||
:ALL: true
|
||||
:user:
|
||||
:group:
|
||||
|
@ -14,57 +14,63 @@
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
#############################################################
|
||||
################################################################################
|
||||
# Server Configuration
|
||||
#############################################################
|
||||
################################################################################
|
||||
|
||||
# Directory to store temp files when uploading images
|
||||
#
|
||||
:tmpdir: /var/tmp/one
|
||||
|
||||
# OpenNebula sever contact information
|
||||
#
|
||||
:one_xmlrpc: http://localhost:2633/RPC2
|
||||
|
||||
# Server Configuration
|
||||
#
|
||||
:host: 127.0.0.1
|
||||
:port: 9869
|
||||
|
||||
#############################################################
|
||||
################################################################################
|
||||
# Log
|
||||
#############################################################
|
||||
################################################################################
|
||||
|
||||
# Log debug level
|
||||
# 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG
|
||||
#
|
||||
:debug_level: 3
|
||||
|
||||
#############################################################
|
||||
################################################################################
|
||||
# Auth
|
||||
#############################################################
|
||||
################################################################################
|
||||
|
||||
# Authentication driver for incomming requests
|
||||
# sunstone, for OpenNebula's user-password scheme
|
||||
# x509, for x509 certificates based authentication
|
||||
# opennebula, the authentication will be done by the opennebula core using the driver
|
||||
# defined for the user
|
||||
# opennebula, the authentication will be done by the opennebula core using the
|
||||
# driver defined for the user
|
||||
#
|
||||
:auth: sunstone
|
||||
|
||||
# Authentication driver to communicate with OpenNebula core
|
||||
# cipher, for symmetric cipher encryption of tokens
|
||||
# x509, for x509 certificate encryption of tokens
|
||||
#
|
||||
:core_auth: cipher
|
||||
|
||||
#############################################################
|
||||
################################################################################
|
||||
# UI Settings
|
||||
#############################################################
|
||||
|
||||
# VNC Configuration
|
||||
################################################################################
|
||||
# :vnc_proxy_
|
||||
# base_port: base_port + vnc_port of the VM is the port where the
|
||||
# proxy will listen for VNC session connections to that VM.
|
||||
# vnc_proxy_path: path to the websockets proxy (set by install_novnc.sh)
|
||||
# path: path to the websockets proxy (set by install_novnc.sh)
|
||||
# support_wss: no | yes | only. For yes and only, provide path to
|
||||
# cert and key. "yes" means both ws and wss connections will be
|
||||
# supported.
|
||||
# vnc_proxy_cert: Certificate to encrypt wss connections.
|
||||
# vnc_proxy_key: Key for wss connections. Only necessary if not included in cert.
|
||||
# cert and key. "yes" means both ws and wss connections will
|
||||
# be supported.
|
||||
# cert: Certificate to encrypt wss connections.
|
||||
# key: Key for wss connections. Only if not included in cert.
|
||||
#
|
||||
:vnc_proxy_base_port: 29876
|
||||
:vnc_proxy_path:
|
||||
:vnc_proxy_support_wss: no
|
||||
@ -74,3 +80,17 @@
|
||||
|
||||
# Default language setting
|
||||
:lang: en_US
|
||||
|
||||
################################################################################
|
||||
# Marketplace
|
||||
################################################################################
|
||||
|
||||
# Marketplace username and password
|
||||
# If no credentials are provided, an anonymous client will be used
|
||||
#
|
||||
#:marketplace_username:
|
||||
#:marketplace_password:
|
||||
|
||||
# Marketplace endpoint
|
||||
#
|
||||
:marketplace_url: http://marketplace.c12g.com/
|
||||
|
51
src/sunstone/models/SunstoneMarketplace.rb
Normal file
51
src/sunstone/models/SunstoneMarketplace.rb
Normal file
@ -0,0 +1,51 @@
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2012, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
require 'marketplace/marketplace_client'
|
||||
|
||||
module SunstoneMarketplace
|
||||
def get_appliance_pool
|
||||
client = Market::ApplianceClient.new(
|
||||
@config[:marketplace_username],
|
||||
@config[:marketplace_password],
|
||||
@config[:marketplace_url])
|
||||
|
||||
response = client.list
|
||||
|
||||
if CloudClient::is_error?(response)
|
||||
error = Error.new(response.to_s)
|
||||
return [response.code, error.to_json]
|
||||
end
|
||||
|
||||
[200, response.body]
|
||||
end
|
||||
|
||||
def get_appliance(app_id)
|
||||
client = Market::ApplianceClient.new(
|
||||
@config[:marketplace_username],
|
||||
@config[:marketplace_password],
|
||||
@config[:marketplace_url])
|
||||
|
||||
response = client.show(app_id)
|
||||
|
||||
if CloudClient::is_error?(response)
|
||||
error = Error.new(response.to_s)
|
||||
return [response.code, error.to_json]
|
||||
end
|
||||
|
||||
[200, response.body]
|
||||
end
|
||||
end
|
@ -23,6 +23,8 @@ require 'OpenNebulaVNC'
|
||||
require 'OpenNebulaJSON/JSONUtils'
|
||||
include JSONUtils
|
||||
|
||||
require 'SunstoneMarketplace'
|
||||
|
||||
class SunstoneServer < CloudServer
|
||||
# FLAG that will filter the elements retrieved from the Pools
|
||||
POOL_FILTER = Pool::INFO_ALL
|
||||
@ -30,6 +32,8 @@ class SunstoneServer < CloudServer
|
||||
# Secs to sleep between checks to see if image upload to repo is finished
|
||||
IMAGE_POLL_SLEEP_TIME = 5
|
||||
|
||||
include SunstoneMarketplace
|
||||
|
||||
def initialize(client, config, logger)
|
||||
super(config, logger)
|
||||
@client = client
|
||||
@ -139,7 +143,7 @@ class SunstoneServer < CloudServer
|
||||
if OpenNebula.is_error?(ds_id)
|
||||
return [500, ds_id.to_json]
|
||||
end
|
||||
|
||||
|
||||
new_template = {
|
||||
:image => image_hash,
|
||||
:ds_id => ds_id,
|
||||
|
299
src/sunstone/public/js/plugins/marketplace-tab.js
Normal file
299
src/sunstone/public/js/plugins/marketplace-tab.js
Normal file
@ -0,0 +1,299 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2010-2012, C12G Labs S.L */
|
||||
/* */
|
||||
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
|
||||
/* not use this file except in compliance with the License. You may obtain */
|
||||
/* a copy of the License at */
|
||||
/* */
|
||||
/* http://www.apache.org/licenses/LICENSE-2.0 */
|
||||
/* */
|
||||
/* Unless required by applicable law or agreed to in writing, software */
|
||||
/* distributed under the License is distributed on an "AS IS" BASIS, */
|
||||
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
|
||||
/* See the License for the specific language governing permissions and */
|
||||
/* limitations under the License. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/* Marketpplace tab plugin */
|
||||
var dataTable_marketplace;
|
||||
|
||||
/*
|
||||
* fnReloadAjax: re-read the Ajax source and update the table
|
||||
*/
|
||||
|
||||
$.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback, bStandingRedraw )
|
||||
{
|
||||
if ( typeof sNewSource != 'undefined' && sNewSource != null )
|
||||
{
|
||||
oSettings.sAjaxSource = sNewSource;
|
||||
}
|
||||
this.oApi._fnProcessingDisplay( oSettings, true );
|
||||
var that = this;
|
||||
var iStart = oSettings._iDisplayStart;
|
||||
var aData = [];
|
||||
|
||||
this.oApi._fnServerParams( oSettings, aData );
|
||||
|
||||
oSettings.fnServerData( oSettings.sAjaxSource, aData, function(json) {
|
||||
/* Clear the old information from the table */
|
||||
that.oApi._fnClearTable( oSettings );
|
||||
|
||||
/* Got the data - add it to the table */
|
||||
var aData = (oSettings.sAjaxDataProp !== "") ?
|
||||
that.oApi._fnGetObjectDataFn( oSettings.sAjaxDataProp )( json ) : json;
|
||||
|
||||
for ( var i=0 ; i<aData.length ; i++ )
|
||||
{
|
||||
that.oApi._fnAddData( oSettings, aData[i] );
|
||||
}
|
||||
|
||||
oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
|
||||
that.fnDraw();
|
||||
|
||||
if ( typeof bStandingRedraw != 'undefined' && bStandingRedraw === true )
|
||||
{
|
||||
oSettings._iDisplayStart = iStart;
|
||||
that.fnDraw( false );
|
||||
}
|
||||
|
||||
that.oApi._fnProcessingDisplay( oSettings, false );
|
||||
|
||||
/* Callback user function - for event handlers etc */
|
||||
if ( typeof fnCallback == 'function' && fnCallback != null )
|
||||
{
|
||||
fnCallback( oSettings );
|
||||
}
|
||||
}, oSettings );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* MAIN TAB
|
||||
*/
|
||||
|
||||
var market_actions = {
|
||||
"Marketplace.refresh" : {
|
||||
type: "custom",
|
||||
call: function () {
|
||||
dataTable_marketplace.fnReloadAjax();
|
||||
}
|
||||
},
|
||||
"Marketplace.import" : {
|
||||
type: "single",
|
||||
call: function () {
|
||||
var app_id = getSelectedNodes(dataTable_marketplace)[0];
|
||||
|
||||
$.ajax({
|
||||
url: "/marketplace/" + app_id,
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
success: function(response){
|
||||
document.getElementById("img_name").value = response['name'];
|
||||
document.getElementById("img_path").value = response['links']['download']['href'];
|
||||
popUpCreateImageDialog();
|
||||
},
|
||||
error: function(response)
|
||||
{
|
||||
return onError(null, OpenNebula.Error(response));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var market_buttons = {
|
||||
"Marketplace.refresh" : {
|
||||
type: "image",
|
||||
text: tr("Refresh list"),
|
||||
img: "images/Refresh-icon.png"
|
||||
},
|
||||
"Marketplace.import" : {
|
||||
type: "action",
|
||||
text: tr('Import to local infrastructure')
|
||||
}
|
||||
};
|
||||
|
||||
var marketplace_tab_content = '\
|
||||
<h2>'+tr("OpenNebula Marketplace")+'</h2>\
|
||||
<form id="marketplace_form" action="" action="javascript:alert(\'js error!\');">\
|
||||
<div class="action_blocks">\
|
||||
</div>\
|
||||
<table id="datatable_marketplace" class="display">\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th class="check"></th>\
|
||||
<th>'+tr("ID")+'</th>\
|
||||
<th>'+tr("Name")+'</th>\
|
||||
<th>'+tr("Publisher")+'</th>\
|
||||
<th>'+tr("Hypervisor")+'</th>\
|
||||
<th>'+tr("Arch")+'</th>\
|
||||
<th>'+tr("Format")+'</th>\
|
||||
<th>'+tr("Tags")+'</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody id="tbodymarketplace">\
|
||||
</tbody>\
|
||||
</table>\
|
||||
</div>';
|
||||
|
||||
|
||||
var marketplace_tab = {
|
||||
title: '<i class="icon-shopping-cart"></i>' + tr("Marketplace"),
|
||||
content: marketplace_tab_content,
|
||||
buttons: market_buttons,
|
||||
};
|
||||
|
||||
Sunstone.addMainTab('marketplace_tab', marketplace_tab);
|
||||
Sunstone.addActions(market_actions);
|
||||
|
||||
|
||||
/*
|
||||
* INFO PANEL
|
||||
*/
|
||||
|
||||
var marketplace_info_panel = {
|
||||
"marketplace_info_tab" : {
|
||||
title: tr("Appliance information"),
|
||||
content:""
|
||||
},
|
||||
};
|
||||
|
||||
Sunstone.addInfoPanel("marketplace_info_panel", marketplace_info_panel);
|
||||
|
||||
|
||||
function updateMarketInfo(request,app){
|
||||
var info_tab = {
|
||||
title : tr("Appliance information"),
|
||||
content :
|
||||
'<table id="info_marketplace_table" class="info_table">\
|
||||
<thead>\
|
||||
<tr><th colspan="2">'+tr("Appliance information")+'</th></tr>\
|
||||
</thead>\
|
||||
<tbody>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("ID") + '</td>\
|
||||
<td class="value_td">'+app['_id']["$oid"]+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Publisher") + '</td>\
|
||||
<td class="value_td">'+app['publisher']+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Downloads") + '</td>\
|
||||
<td class="value_td">'+app['downloads']+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("OS") + '</td>\
|
||||
<td class="value_td">'+app['files'][0]['os-id']+' '+app['files'][0]['os-release']+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Arch") + '</td>\
|
||||
<td class="value_td">'+app['files'][0]['os-arch']+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Size") + '</td>\
|
||||
<td class="value_td">'+app['files'][0]['size']+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Hypervisor") + '</td>\
|
||||
<td class="value_td">'+app['files'][0]['hypervisor']+'</td>\
|
||||
</tr>\
|
||||
</tbody>\
|
||||
</table>\
|
||||
<table id="info_marketplace_table2" class="info_table">\
|
||||
<thead>\
|
||||
<tr><th colspan="2">'+tr("Description")+'</th></tr>\
|
||||
</thead>\
|
||||
<tbody>\
|
||||
<tr>\
|
||||
<td class="value_td">'+app['description'].replace(/\n/g, "<br />")+'</td>\
|
||||
</tr>\
|
||||
</tbody>\
|
||||
</table>'
|
||||
};
|
||||
|
||||
Sunstone.updateInfoPanelTab("marketplace_info_panel", "marketplace_info_tab", info_tab);
|
||||
Sunstone.popUpInfoPanel("marketplace_info_panel");
|
||||
};
|
||||
|
||||
function infoListenerMarket(dataTable){
|
||||
$('tbody tr',dataTable).live("click",function(e){
|
||||
if ($(e.target).is('input')) {return true;}
|
||||
|
||||
var aData = dataTable.fnGetData(this);
|
||||
var id = aData["_id"]["$oid"];
|
||||
if (!id) return true;
|
||||
|
||||
popDialogLoading();
|
||||
|
||||
$.ajax({
|
||||
url: "/marketplace/" + id,
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
success: function(response){
|
||||
return updateMarketInfo(null, response);
|
||||
},
|
||||
error: function(response)
|
||||
{
|
||||
return onError(null, OpenNebula.Error(response));
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* onlyOneCheckboxListener: Only one box can be checked
|
||||
*/
|
||||
|
||||
function onlyOneCheckboxListener(dataTable) {
|
||||
$('tbody input.check_item', dataTable).live("change", function(){
|
||||
var checked = $('input.check_item:checked', $('tr', dataTable));
|
||||
var self = this;
|
||||
checked.each(function(){
|
||||
if(this!=self) this.checked = ''
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Document
|
||||
*/
|
||||
|
||||
$(document).ready(function(){
|
||||
dataTable_marketplace = $("#datatable_marketplace", main_tabs_context).dataTable({
|
||||
"bJQueryUI": true,
|
||||
"bSortClasses": false,
|
||||
"sPaginationType": "full_numbers",
|
||||
"sDom" : '<"H"lfrC>t<"F"ip>',
|
||||
"sAjaxSource": "/marketplace",
|
||||
"sAjaxDataProp": "appliances",
|
||||
"bAutoWidth":false,
|
||||
"aoColumns": [
|
||||
{ "bSortable": false,
|
||||
"fnRender": function ( o, val ) {
|
||||
return '<input class="check_item" type="checkbox" id="marketplace_'+o.aData['_id']['$oid']+'" name="selected_items" value="'+o.aData['_id']['$oid']+'"/>'
|
||||
} },
|
||||
{ "mDataProp": "_id.$oid", "bVisible": false },
|
||||
{ "mDataProp": "name" },
|
||||
{ "mDataProp": "publisher" },
|
||||
{ "mDataProp": "files.0.hypervisor"},
|
||||
{ "mDataProp": "files.0.os-arch"},
|
||||
{ "mDataProp": "files.0.format"},
|
||||
{ "mDataProp": "tags", "bVisible": false}
|
||||
],
|
||||
"oLanguage": (datatable_lang != "") ?
|
||||
{
|
||||
sUrl: "locale/"+lang+"/"+datatable_lang
|
||||
} : ""
|
||||
});
|
||||
|
||||
|
||||
initCheckAllBoxes(dataTable_marketplace);
|
||||
tableCheckboxesListener(dataTable_marketplace);
|
||||
onlyOneCheckboxListener(dataTable_marketplace);
|
||||
|
||||
infoListenerMarket(dataTable_marketplace);
|
||||
});
|
@ -268,7 +268,7 @@ post '/config' do
|
||||
rescue Exception => e
|
||||
msg = "Error parsing configuration JSON"
|
||||
logger.error { msg }
|
||||
logger.error { e.message }
|
||||
logger.error { e.message }
|
||||
[500, OpenNebula::Error.new(msg).to_json]
|
||||
end
|
||||
|
||||
@ -301,12 +301,22 @@ get '/:resource/:id/monitor' do
|
||||
params[:monitor_resources])
|
||||
end
|
||||
|
||||
##############################################################################
|
||||
# Marketplace
|
||||
##############################################################################
|
||||
get '/marketplace' do
|
||||
@SunstoneServer.get_appliance_pool
|
||||
end
|
||||
|
||||
get '/marketplace/:id' do
|
||||
@SunstoneServer.get_appliance(params[:id])
|
||||
end
|
||||
|
||||
##############################################################################
|
||||
# GET Pool information
|
||||
##############################################################################
|
||||
get '/:pool' do
|
||||
@SunstoneServer.get_pool(params[:pool],
|
||||
session[:user_gid])
|
||||
@SunstoneServer.get_pool(params[:pool], session[:user_gid])
|
||||
end
|
||||
|
||||
##############################################################################
|
||||
|
Loading…
Reference in New Issue
Block a user