mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
(cherry picked from commit 7181175f7378f694e790f41515e28aa7d9b10e3c)
This commit is contained in:
parent
6cbdfd2631
commit
424cd761c4
@ -858,13 +858,24 @@ class ServiceLCM
|
||||
rc = @srv_pool.get(service_id, client) do |service|
|
||||
service.remove_role(role_name)
|
||||
|
||||
service.set_state(Service::STATE['RUNNING'])
|
||||
if service.all_roles_done?
|
||||
rc = service.delete_networks
|
||||
|
||||
rc = service.update
|
||||
if rc && !rc.empty?
|
||||
Log.info LOG_COMP, 'Error trying to delete '\
|
||||
"Virtual Networks #{rc}"
|
||||
end
|
||||
|
||||
return rc if OpenNebula.is_error?(rc)
|
||||
service.delete
|
||||
else
|
||||
service.set_state(Service::STATE['RUNNING'])
|
||||
|
||||
@wd.add_service(service) if service.all_roles_running?
|
||||
rc = service.update
|
||||
|
||||
return rc if OpenNebula.is_error?(rc)
|
||||
|
||||
@wd.add_service(service) if service.all_roles_running?
|
||||
end
|
||||
end
|
||||
|
||||
Log.error LOG_COMP, rc.message if OpenNebula.is_error?(rc)
|
||||
|
@ -26,9 +26,9 @@ require 'openssl'
|
||||
require 'sunstone_remotes'
|
||||
|
||||
if !ONE_LOCATION
|
||||
VAR_LOCATION = '/var/lib/one/'
|
||||
VAR_LOCATION ||= '/var/lib/one/'
|
||||
else
|
||||
VAR_LOCATION = ONE_LOCATION + '/var/'
|
||||
VAR_LOCATION ||= ONE_LOCATION + '/var/'
|
||||
end
|
||||
|
||||
FIREEDGE_KEY = VAR_LOCATION + '/.one/fireedge_key'
|
||||
|
@ -189,6 +189,44 @@ define(function(require) {
|
||||
}
|
||||
});
|
||||
},
|
||||
"remove" : function(params) {
|
||||
var request = OpenNebulaHelper.request(RESOURCE, "remove", params.data.id);
|
||||
|
||||
$.ajax({
|
||||
url: PATH + "/" + String(params.data.id) + "/role_action",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data: JSON.stringify(params.data.extra_param),
|
||||
success: function(response) {
|
||||
return params.success ? params.success(request, response) : null;
|
||||
},
|
||||
error: function(response) {
|
||||
response.status === 201
|
||||
? params.success ? params.success(request, response) : null
|
||||
: params.error ? params.error(request, OpenNebulaError(response)) : null;
|
||||
}
|
||||
});
|
||||
},
|
||||
"add" : function(params) {
|
||||
var request = OpenNebulaHelper.request(RESOURCE, "add", params.data.id);
|
||||
|
||||
$.ajax({
|
||||
url: PATH + "/" + String(params.data.id) + "/role_action",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data: JSON.stringify(params.data.extra_param),
|
||||
success: function(response) {
|
||||
return params.success ? params.success(request, response) : null;
|
||||
},
|
||||
error: function(response) {
|
||||
response.status === 201
|
||||
? params.success ? params.success(request, response) : null
|
||||
: params.error ? params.error(request, OpenNebulaError(response)) : null;
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
return Role;
|
||||
|
@ -26,6 +26,7 @@ define(function(require) {
|
||||
|
||||
var _dialogs = [
|
||||
require('./oneflow-services-tab/dialogs/scale'),
|
||||
require('./oneflow-services-tab/dialogs/add'),
|
||||
];
|
||||
|
||||
var _panels = [
|
||||
|
@ -29,6 +29,8 @@ define(function(require) {
|
||||
|
||||
var ROLES_PANEL_ID = require('./panels/roles/panelId');
|
||||
var SCALE_DIALOG_ID = require('./dialogs/scale/dialogId');
|
||||
var ADD_DIALOG_ID = require('./dialogs/add/dialogId');
|
||||
var CONFIRM_DIALOG_ID = require('utils/dialogs/generic-confirm/dialogId');
|
||||
var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId');
|
||||
var UPDATE_DIALOG_ID = require('./form-panels/update/formPanelId');
|
||||
|
||||
@ -317,6 +319,84 @@ define(function(require) {
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Role.remove_dialog" : {
|
||||
type: "custom",
|
||||
call: function(){
|
||||
params = roleElement();
|
||||
|
||||
if(!params.serviceId || !params.roleName) {
|
||||
Notifier.onError("Select one role");
|
||||
return;
|
||||
}
|
||||
|
||||
var obj = {
|
||||
"action": {
|
||||
"perform":"remove_role",
|
||||
"params" : {
|
||||
"role" : params.roleName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Sunstone.getDialog(CONFIRM_DIALOG_ID).setParams({
|
||||
header : Locale.tr("Confirm"),
|
||||
headerTabId: TAB_ID,
|
||||
body : "",
|
||||
question : Locale.tr("Are you sure you want to delete the role") + " <b>" + params.roleName + "</b>?",
|
||||
buttons : [
|
||||
Locale.tr("Confirm"),
|
||||
],
|
||||
submit : [
|
||||
function(){
|
||||
Sunstone.getDialog(CONFIRM_DIALOG_ID).hide();
|
||||
Sunstone.runAction('Role.remove', params.serviceId, obj);
|
||||
return false;
|
||||
}
|
||||
]
|
||||
});
|
||||
Sunstone.getDialog(CONFIRM_DIALOG_ID).reset();
|
||||
Sunstone.getDialog(CONFIRM_DIALOG_ID).show();
|
||||
}
|
||||
},
|
||||
|
||||
"Role.remove" : {
|
||||
type: "single",
|
||||
call: OpenNebulaRole.remove,
|
||||
callback : function() {
|
||||
Sunstone.getDialog(CONFIRM_DIALOG_ID).hide();
|
||||
roleCallback();
|
||||
},
|
||||
error: function(request, response) {
|
||||
Sunstone.getDialog(CONFIRM_DIALOG_ID).hide();
|
||||
Notifier.onError(request, response);
|
||||
},
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Role.add" : {
|
||||
type: "single",
|
||||
call: OpenNebulaRole.add,
|
||||
callback : function() {
|
||||
Sunstone.getDialog(ADD_DIALOG_ID).hide();
|
||||
roleCallback();
|
||||
},
|
||||
error: function(request, response) {
|
||||
Sunstone.getDialog(ADD_DIALOG_ID).hide();
|
||||
Notifier.onError(request, response);
|
||||
},
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Role.add_dialog" : {
|
||||
type: "custom",
|
||||
call: function(){
|
||||
params = roleElement();
|
||||
|
||||
Sunstone.getDialog(ADD_DIALOG_ID).reset();
|
||||
Sunstone.getDialog(ADD_DIALOG_ID).show();
|
||||
}
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
"RoleVM.deploy" : {
|
||||
|
124
src/sunstone/public/app/tabs/oneflow-services-tab/dialogs/add.js
Normal file
124
src/sunstone/public/app/tabs/oneflow-services-tab/dialogs/add.js
Normal file
@ -0,0 +1,124 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2021, 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) {
|
||||
/*
|
||||
DEPENDENCIES
|
||||
*/
|
||||
|
||||
var BaseDialog = require('utils/dialogs/dialog');
|
||||
var TemplateHTML = require('hbs!./add/html');
|
||||
var Sunstone = require('sunstone');
|
||||
var Notifier = require('utils/notifier');
|
||||
var Locale = require('utils/locale');
|
||||
var Tips = require('utils/tips');
|
||||
var RoleTab = require('tabs/oneflow-services-tab/utils/role-tab');
|
||||
var OpenNebulaRole = require("opennebula/role");
|
||||
|
||||
/*
|
||||
CONSTANTS
|
||||
*/
|
||||
|
||||
var DIALOG_ID = require('./add/dialogId');
|
||||
var TAB_ID = require('../tabId');
|
||||
|
||||
/*
|
||||
CONSTRUCTOR
|
||||
*/
|
||||
|
||||
function Dialog() {
|
||||
this.dialogId = DIALOG_ID;
|
||||
|
||||
BaseDialog.call(this);
|
||||
}
|
||||
|
||||
Dialog.DIALOG_ID = DIALOG_ID;
|
||||
Dialog.prototype = Object.create(BaseDialog.prototype);
|
||||
Dialog.prototype.constructor = Dialog;
|
||||
Dialog.prototype.html = _html;
|
||||
Dialog.prototype.onShow = _onShow;
|
||||
Dialog.prototype.setup = _setup;
|
||||
Dialog.prototype.setParams = _setParams;
|
||||
|
||||
return Dialog;
|
||||
|
||||
/*
|
||||
FUNCTION DEFINITIONS
|
||||
*/
|
||||
|
||||
function _html() {
|
||||
return TemplateHTML({
|
||||
'dialogId': this.dialogId
|
||||
});
|
||||
}
|
||||
|
||||
function _onShow(context) {
|
||||
this.setNames( {tabId: TAB_ID} );
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
var that = this;
|
||||
|
||||
var html_role_id = "newRole";
|
||||
|
||||
var role = new RoleTab(html_role_id)
|
||||
|
||||
var role_section = $("<div id=\"" +
|
||||
html_role_id +
|
||||
"Tab\" class=\"role_content wizard_internal_tab\" role_id=\"0\">" +
|
||||
role.html() +
|
||||
"</div>"
|
||||
);
|
||||
|
||||
$('.add-role-form', context).html(role_section);
|
||||
$('#roleTabTemplatesnewRoleContainer', context).closest('.row').show();
|
||||
|
||||
role.setup(role_section);
|
||||
role.onShow();
|
||||
|
||||
$('#refresh_button_roleTabTemplatesnewRole').trigger('click');
|
||||
|
||||
$('#addServiceRoleDialogForm',context).on("submit", function(ev) {
|
||||
ev.preventDefault();
|
||||
var role_info = role.retrieve(context);
|
||||
var obj = {
|
||||
"action": {
|
||||
"perform":"add_role",
|
||||
"params" : {
|
||||
"role" : JSON.stringify(role_info)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var flow_id = $('.resource-id').text();
|
||||
Sunstone.runAction('Role.add', flow_id, obj);
|
||||
return false;
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} params
|
||||
* - params.serviceId : selected service ID
|
||||
* - params.roleName : selected role name
|
||||
*/
|
||||
function _setParams(params) {
|
||||
this.serviceId = params.serviceId;
|
||||
this.roleName = params.roleName;
|
||||
}
|
||||
});
|
@ -0,0 +1,19 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2021, 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){
|
||||
return 'addServiceRoleDialog';
|
||||
});
|
@ -0,0 +1,35 @@
|
||||
{{! -------------------------------------------------------------------------- }}
|
||||
{{! Copyright 2002-2021, 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. }}
|
||||
{{! -------------------------------------------------------------------------- }}
|
||||
|
||||
<div id="{{dialogId}}" class="reveal" data-reveal>
|
||||
<div class="row">
|
||||
<h3 class="subheader">{{tr "Add role"}}</h3>
|
||||
</div>
|
||||
<div class="confirm-resources-header"></div>
|
||||
<form data-abide novalidate id="{{dialogId}}Form">
|
||||
<div class="add-role-form">
|
||||
|
||||
</div>
|
||||
<div class="form_buttons row">
|
||||
<button type="submit" class="add-role-btn button radius right">
|
||||
{{tr "Add"}}
|
||||
</button>
|
||||
</div>
|
||||
<button class="close-button" data-close aria-label="{{tr "Close modal"}}" type="button">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
@ -152,6 +152,13 @@ define(function(require) {
|
||||
|
||||
Tips.setup(context);
|
||||
|
||||
console.log()
|
||||
|
||||
$('#addRoleBtn').on('click', function(event){
|
||||
event.preventDefault();
|
||||
Sunstone.runAction("Role.add_dialog");
|
||||
});
|
||||
|
||||
if (roles && roles.length) {
|
||||
that.servicerolesDataTable = new DomDataTable(
|
||||
"datatable_roles_"+this.panelId,
|
||||
|
@ -18,7 +18,13 @@
|
||||
<div class="row">
|
||||
{{#if servicePanel}}
|
||||
<div id="role_actions">
|
||||
<div class="action_blocks columns medium-8">
|
||||
<div class=" columns medium-2">
|
||||
<button class="role-state-dependent success button" id="addRoleBtn">
|
||||
<i class="fas fa-plus"></i>
|
||||
Add Role
|
||||
</button>
|
||||
</div>
|
||||
<div class="action_blocks columns medium-6">
|
||||
</div>
|
||||
<div class="columns medium-4 right">
|
||||
<div class="row">
|
||||
|
@ -89,6 +89,12 @@ define(function(require) {
|
||||
text: Locale.tr("Terminate") + ' <span class="label secondary radius">hard</span>',
|
||||
layout: "vmsdelete_buttons",
|
||||
custom_classes : "role-state-dependent"
|
||||
},
|
||||
"Role.remove_dialog" : {
|
||||
type: "action",
|
||||
text: Locale.tr("Remove Role"),
|
||||
layout: "vmsdelete_buttons",
|
||||
custom_classes : "role-state-dependent"
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -121,6 +121,14 @@ post '/service/purge' do
|
||||
af_format_response(resp)
|
||||
end
|
||||
|
||||
post '/service/:id/role_action' do
|
||||
client = af_build_client
|
||||
|
||||
resp = client.post('/service/' + params[:id] + '/role_action' , @request_body)
|
||||
|
||||
af_format_response(resp)
|
||||
end
|
||||
|
||||
##############################################################################
|
||||
# Service Template
|
||||
##############################################################################
|
||||
|
@ -20,21 +20,21 @@
|
||||
ONE_LOCATION = ENV['ONE_LOCATION']
|
||||
|
||||
if !ONE_LOCATION
|
||||
LOG_LOCATION = '/var/log/one'
|
||||
VAR_LOCATION = '/var/lib/one'
|
||||
ETC_LOCATION = '/etc/one'
|
||||
SHARE_LOCATION = '/usr/share/one'
|
||||
RUBY_LIB_LOCATION = '/usr/lib/one/ruby'
|
||||
GEMS_LOCATION = '/usr/share/one/gems'
|
||||
SUNSTONE_LOCATION = '/usr/lib/one/sunstone'
|
||||
LOG_LOCATION ||= '/var/log/one'
|
||||
VAR_LOCATION ||= '/var/lib/one'
|
||||
ETC_LOCATION ||= '/etc/one'
|
||||
SHARE_LOCATION ||= '/usr/share/one'
|
||||
RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby'
|
||||
GEMS_LOCATION ||= '/usr/share/one/gems'
|
||||
SUNSTONE_LOCATION ||= '/usr/lib/one/sunstone'
|
||||
else
|
||||
VAR_LOCATION = ONE_LOCATION + '/var'
|
||||
LOG_LOCATION = ONE_LOCATION + '/var'
|
||||
ETC_LOCATION = ONE_LOCATION + '/etc'
|
||||
SHARE_LOCATION = ONE_LOCATION + '/share'
|
||||
RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby'
|
||||
GEMS_LOCATION = ONE_LOCATION + '/share/gems'
|
||||
SUNSTONE_LOCATION = ONE_LOCATION + '/lib/sunstone'
|
||||
VAR_LOCATION ||= ONE_LOCATION + '/var'
|
||||
LOG_LOCATION ||= ONE_LOCATION + '/var'
|
||||
ETC_LOCATION ||= ONE_LOCATION + '/etc'
|
||||
SHARE_LOCATION ||= ONE_LOCATION + '/share'
|
||||
RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby'
|
||||
GEMS_LOCATION ||= ONE_LOCATION + '/share/gems'
|
||||
SUNSTONE_LOCATION ||= ONE_LOCATION + '/lib/sunstone'
|
||||
end
|
||||
|
||||
SUNSTONE_AUTH = VAR_LOCATION + '/.one/sunstone_auth'
|
||||
|
Loading…
x
Reference in New Issue
Block a user