diff --git a/apptools/install.sh b/apptools/install.sh index 5234b1c4d1..d751dda0ed 100755 --- a/apptools/install.sh +++ b/apptools/install.sh @@ -17,6 +17,5 @@ . ../install_lib.sh -copy_files "sunstone/public/images/*" "$SUNSTONE_LOCATION/public/images" -copy_files "sunstone/public/js/user-plugins/*" "$SUNSTONE_LOCATION/public/js/user-plugins" +copy_files "share/*" "$SHARE_LOCATION" diff --git a/apptools/share/sunstone/public/js/opennebula.js b/apptools/share/sunstone/public/js/opennebula.js new file mode 100644 index 0000000000..e5feba7291 --- /dev/null +++ b/apptools/share/sunstone/public/js/opennebula.js @@ -0,0 +1,1055 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2012, 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. */ +/* -------------------------------------------------------------------------- */ + +var OpenNebula = { + + "Error": function(resp) + { + var error = {}; + if (resp.responseText) + { + try { + error = JSON.parse(resp.responseText); + } + catch (e) { + error.error = {message: "It appears there was a server exception. Please check server's log."}; + }; + } + else + { + error.error = {}; + } + error.error.http_status = resp.status; + return error; + }, + + "is_error": function(obj) + { + return obj.error ? true : false; + }, + + "Helper": { + "resource_state": function(type, value) + { + var state; + switch(type) + { + case "HOST": + case "host": + state = tr(["INIT", + "MONITORING_MONITORED", + "MONITORED", + "ERROR", + "DISABLED", + "MONITORING_ERROR"][value]); + break; + case "HOST_SIMPLE": + case "host_simple": + state = tr(["INIT", + "UPDATE", + "ON", + "ERROR", + "OFF", + "RETRY"][value]); + break; + case "VM": + case "vm": + state = tr(["INIT", + "PENDING", + "HOLD", + "ACTIVE", + "STOPPED", + "SUSPENDED", + "DONE", + "FAILED", + "POWEROFF"][value]); + break; + case "VM_LCM": + case "vm_lcm": + state = tr(["LCM_INIT", + "PROLOG", + "BOOT", + "RUNNING", + "MIGRATE", + "SAVE_STOP", + "SAVE_SUSPEND", + "SAVE_MIGRATE", + "PROLOG_MIGRATE", + "PROLOG_RESUME", + "EPILOG_STOP", + "EPILOG", + "SHUTDOWN", + "CANCEL", + "FAILURE", + "CLEANUP", + "UNKNOWN", + "HOTPLUG", + "SHUTDOWN_POWEROFF"][value]); + break; + case "IMAGE": + case "image": + state = tr(["INIT", + "READY", + "USED", + "DISABLED", + "LOCKED", + "ERROR", + "CLONE", + "DELETE", + "USED_PERS"][value]); + break; + case "VM_MIGRATE_REASON": + case "vm_migrate_reason": + state = tr(["NONE", + "ERROR", + "STOP_RESUME", + "USER", + "CANCEL"][value]); + break; + default: + return value; + } + if (!state) state = value + return state; + }, + + "image_type": function(value) + { + return ["OS", "CDROM", "DATABLOCK"][value]; + }, + + "action": function(action, params) + { + obj = { + "action": { + "perform": action + } + } + if (params) + { + obj.action.params = params; + } + return obj; + }, + + "request": function(resource, method, data) { + var r = { + "request": { + "resource" : resource, + "method" : method + } + } + if (data) + { + if (typeof(data) != "array") + { + data = [data]; + } + r.request.data = data; + } + return r; + }, + + "pool": function(resource, response) + { + var pool_name = resource + "_POOL"; + var type = resource; + var pool; + + if (typeof(pool_name) == "undefined") + { + return Error('Incorrect Pool'); + } + + var p_pool = []; + + if (response[pool_name]) { + pool = response[pool_name][type]; + } else { pull = null }; + + if (pool == null) + { + return p_pool; + } + else if (pool.length) + { + for (i=0;i\ -
\ -\ -

apptools logoAppTools is a group of tools for users and administrators of OpenNebula to simplify and optimize cloud application management. With AppTools you can configure the software stack in the applications, manage multi-tiered applications, and build your own private market to distribute applications across several OpenNebula instances.

\ -
\ - \ - \ - \ -\ -\ -\ -\ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
\ -
\ -

' + tr("AppEnv - A tool to manage environments") + '

\ -
\ -\ -

appenv logoAppEnv performs the automatic installation and configuration of the software stack that constitutes an application environment. With AppEnv you can easily define software configurations for your VMs and share them with other users.

\ -
\ -
\ -
\ -
\ -

' + tr("AppFlow - Service deployment") + '

\ -
\ -

appflow logoAppFlow enables the automatic execution of multi-tiered applications. With AppFlow you can define multi-tier applications composed of interconnected VMs and manage them as a single entity.

\ -
\ -
\ -
\ -
\ -

' + tr("AppMarket - Image repository") + '

\ -
\ -

appflow logoAppMarket builds a centralized catalog of cloud applications. With AppMarket you can build a private repository to share and distribute virtual appliances across OpenNebula instances.

\ -
\ -
\ -
\ -\ -'; - -var apptools_tab = { - title: 'AppTools', - content: apptools_dashboard_tmpl, -} - - -Sunstone.addMainTab('apptools_tab',apptools_tab); diff --git a/env/install.sh b/env/install.sh index 088e45b4a1..76ec8d1cf3 100755 --- a/env/install.sh +++ b/env/install.sh @@ -21,4 +21,5 @@ copy_files "lib/* cli/*" "$LIB_LOCATION/env" copy_files "bin/*" "$BIN_LOCATION" copy_files "share/packages/*" "$PACKAGES_LOCATION" copy_files "sunstone/public/js/user-plugins/*" "$SUNSTONE_LOCATION/public/js/user-plugins" +copy_files "sunstone/public/images/*" "$SUNSTONE_LOCATION/public/images" copy_files "sunstone/routes/*" "$SUNSTONE_LOCATION/routes" diff --git a/apptools/sunstone/public/images/appenv_icon.png b/env/sunstone/public/images/appenv_icon.png similarity index 100% rename from apptools/sunstone/public/images/appenv_icon.png rename to env/sunstone/public/images/appenv_icon.png diff --git a/flow/client/bin/appflow-template b/flow/client/bin/appflow-template index 957981e738..5c3630faab 100755 --- a/flow/client/bin/appflow-template +++ b/flow/client/bin/appflow-template @@ -323,7 +323,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do Service.perform_actions(args[0]) { |service_id| params = Hash.new - params['gid'] = args[1].to_i + params['group_id'] = args[1].to_i json_action = Service.build_json_action('chgrp', params) @@ -344,8 +344,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do Service.perform_actions(args[0]) { |service_id| params = Hash.new - params['uid'] = args[1] - params['gid'] = args[2] if args[2] + params['owner_id'] = args[1] + params['group_id'] = args[2] if args[2] json_action = Service.build_json_action('chown', params) diff --git a/flow/controllers/appflow-server.rb b/flow/controllers/appflow-server.rb index 4ea16b95d9..48d8c3b545 100644 --- a/flow/controllers/appflow-server.rb +++ b/flow/controllers/appflow-server.rb @@ -319,10 +319,10 @@ post '/service_template/:id/action' do body service.to_json when 'chown' - if opts && opts['uid'] + if opts && opts['owner_id'] args = Array.new - args << opts['uid'].to_i - args << (opts['gid'].to_i || -1) + args << opts['owner_id'].to_i + args << (opts['group_id'].to_i || -1) service_template.chown(*args) else @@ -330,8 +330,8 @@ post '/service_template/:id/action' do "You have to specify a UID") end when 'chgrp' - if opts && opts['gid'] - service_template.chown(-1, opts['gid'].to_i) + if opts && opts['group_id'] + service_template.chown(-1, opts['group_id'].to_i) else OpenNebula::Error.new("Action #{action['perform']}: " << "You have to specify a GID") diff --git a/flow/install.sh b/flow/install.sh index 5903768aa7..9368bed704 100755 --- a/flow/install.sh +++ b/flow/install.sh @@ -23,6 +23,10 @@ else LOG_LOCATION="$ROOT/var/appflow" fi +DIRECTORIES="$LIB_LOCATION $BIN_LOCATION $ETC_LOCATION $LOG_LOCATION" + +create_dirs $DIRECTORIES + ## Client files copy_files "client/lib/*" "$LIB_LOCATION/flow" copy_files "client/bin/*" "$BIN_LOCATION" @@ -40,11 +44,13 @@ copy_files "lib/* models.rb config.ru Gemfile Gemfile.lock \ Rakefile" "$LIB_LOCATION/flow" # Sunstone -copy_files "sunstone/public/js/user-plugins/*" \ - "$SUNSTONE_LOCATION/public/js/user-plugins" +copy_files "sunstone/public/js/user-plugins/*" "$SUNSTONE_LOCATION/public/js/user-plugins" +copy_files "sunstone/public/images/*" "$SUNSTONE_LOCATION/public/images" copy_files "sunstone/routes/*" "$SUNSTONE_LOCATION/routes" # Do not link the ETC files LINK="no" copy_files "sunstone/etc/sunstone-appflow.conf" "$ETC_LOCATION" copy_files "config/appflow-server.conf" "$ETC_LOCATION" + +change_ownership $LOG_LOCATION diff --git a/flow/lib/validator.rb b/flow/lib/validator.rb index 88cd48a916..15f775b0d0 100644 --- a/flow/lib/validator.rb +++ b/flow/lib/validator.rb @@ -243,12 +243,10 @@ class Validator # # def validate_integer(body, schema_array, schema_key) - if body.is_a?(Integer) - body - else - raise ParseException, "KEY: '#{schema_key}' must be an Integer;"\ - " SCHEMA: #{schema_array}" - end + Integer(body) + rescue ArgumentError + raise ParseException, "KEY: '#{schema_key}' must be an Integer;"\ + " SCHEMA: #{schema_array}" end # Validate an null type diff --git a/apptools/sunstone/public/images/appflow_icon.png b/flow/sunstone/public/images/appflow_icon.png similarity index 100% rename from apptools/sunstone/public/images/appflow_icon.png rename to flow/sunstone/public/images/appflow_icon.png diff --git a/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js b/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js index 3d75377666..775a9ab204 100644 --- a/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js +++ b/flow/sunstone/public/js/user-plugins/apptools.appflow.templates.js @@ -643,7 +643,7 @@ function setupCreateServiceTemplateDialog(){ var role = { name : name, cardinality: cardinality, - template: template, + vm_template: template, parents: parents }; @@ -663,7 +663,7 @@ function setupCreateServiceTemplateDialog(){ $('input[name="cardinality"]', context).val("1"); //unselect selected parents $('select[name="parents"] option[clicked="clicked"]').trigger('click'); - } + } else notifyError(tr("There is already a role with this name!")); diff --git a/flow/sunstone/routes/appflow.rb b/flow/sunstone/routes/appflow.rb index acaba258ab..916f1eaae9 100644 --- a/flow/sunstone/routes/appflow.rb +++ b/flow/sunstone/routes/appflow.rb @@ -115,4 +115,4 @@ post '/service_template' do resp = client.post('/service_template', request.body.read) af_format_response(resp) -end \ No newline at end of file +end diff --git a/install_lib.sh b/install_lib.sh index a540182f69..7b1946dd0b 100644 --- a/install_lib.sh +++ b/install_lib.sh @@ -15,7 +15,8 @@ usage() { echo - echo "Usage: install.sh [-d ONE_LOCATION] [-l] [-h]" + echo "Usage: install.sh [-u install_user] [-g install_group]" + echo " [-d ONE_LOCATION] [-l] [-h]" echo echo "-d: target installation directory, if not defined it'd be root. Must be" echo " an absolute path." @@ -23,7 +24,7 @@ usage() { echo "-h: prints this help" } -TEMP_OPT=`getopt -o hld: -n 'install.sh' -- "$@"` +TEMP_OPT=`getopt -o hlu:g:d: -n 'install.sh' -- "$@"` if [ $? != 0 ] ; then usage @@ -33,6 +34,8 @@ fi eval set -- "$TEMP_OPT" LINK="no" +ONEADMIN_USER=`id -u` +ONEADMIN_GROUP=`id -g` SRC_DIR=$PWD while true ; do @@ -40,6 +43,8 @@ while true ; do -h) usage; exit 0;; -d) ROOT="$2" ; shift 2 ;; -l) LINK="yes" ; shift ;; + -u) ONEADMIN_USER="$2" ; shift 2;; + -g) ONEADMIN_GROUP="$2"; shift 2;; --) shift ; break ;; *) usage; exit 1 ;; esac @@ -49,12 +54,14 @@ if [ -z "$ROOT" ]; then LIB_LOCATION="/usr/lib/one/ruby/apptools" BIN_LOCATION="/usr/bin" PACKAGES_LOCATION="/usr/share/one/apptools" + SHARE_LOCATION="/usr/share/one/apptools" ETC_LOCATION="/etc/one" SUNSTONE_LOCATION="/usr/lib/one/sunstone" else LIB_LOCATION="$ROOT/lib/ruby/apptools" BIN_LOCATION="$ROOT/bin" PACKAGES_LOCATION="$ROOT/share/apptools" + SHARE_LOCATION="$ROOT/share/apptools" ETC_LOCATION="$ROOT/etc" SUNSTONE_LOCATION="$ROOT/lib/sunstone" fi @@ -82,3 +89,18 @@ copy_files() { done } +create_dirs() { + DIRS=$* + + for d in $DIRS; do + dir=$DESTDIR$d + mkdir -p $dir + done +} + +change_ownership() { + DIRS=$* + for d in $DIRS; do + chown -R $ONEADMIN_USER:$ONEADMIN_GROUP $DESTDIR$d + done +} diff --git a/market/install.sh b/market/install.sh index 4217f097f7..c1dcec144e 100755 --- a/market/install.sh +++ b/market/install.sh @@ -34,8 +34,8 @@ copy_files "lib/* models.rb config.ru Gemfile Gemfile.lock \ Rakefile config/init.rb" "$LIB_LOCATION/market" # Sunstone -copy_files "sunstone/public/js/user-plugins/*" \ - "$SUNSTONE_LOCATION/public/js/user-plugins" +copy_files "sunstone/public/js/user-plugins/*" "$SUNSTONE_LOCATION/public/js/user-plugins" +copy_files "sunstone/public/images/*" "$SUNSTONE_LOCATION/public/images" copy_files "sunstone/routes/*" "$SUNSTONE_LOCATION/routes" # Do not link the ETC files diff --git a/apptools/sunstone/public/images/appmarket_icon.png b/market/sunstone/public/images/appmarket_icon.png similarity index 100% rename from apptools/sunstone/public/images/appmarket_icon.png rename to market/sunstone/public/images/appmarket_icon.png