/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
*
* 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 workflow = {
name: 'Configuration for OpenStack Cinder Driver',
origin: 'Oracle Corporation',
description: 'Setup environment for OpenStack Cinder Driver',
version: '1.0.0',
parameters: {
name: {
label: 'Cinder\'s User\'s Name',
type: 'String'
},
password: {
label: 'Password',
type: 'Password'
}
},
execute: function (params) {
/*
* Check for REST service to be enabled
*/
try {
run('configuration services rest');
if (get('<status>') != 'online')
run('enable');
} catch (err) {
return ('The REST API is not available on this version of \
appliance software and is required to run with the \
ZFSSA cinder driver. Please upgrade the appliance \
software.');
}
/*
* Cinder role
*/
var osrole = 'OpenStackRole';
run('cd /');
run('configuration roles');
try {
run('select ' + osrole);
} catch(err) {
run('role ' + osrole);
run('set description="OpenStack Cinder Driver"');
run('commit');
run('select ' + osrole);
}
run('authorizations');
run('create');
run('set scope=stmf');
run('set allow_configure=true');
run('commit');
run('create');
run('set scope=nas');
run('set allow_clone=true');
run('set allow_createProject=true');
run('set allow_createShare=true');
run('set allow_changeSpaceProps=true');
run('set allow_changeGeneralProps=true');
run('set allow_destroy=true');
run('set allow_rollback=true');
run('set allow_takeSnap=true');
run('commit');
/*
* Set user with Cinder role
*/
var msg = 'User ' + params.name;
run('cd /')
run('configuration users');
try {
run('select ' + params.name);
msg += ' updated.';
} catch (err) {
run('user ' + params.name);
run('set initial_password=' + params.password);
run('set fullname="OpenStack Cinder Driver"');
run('commit');
run('select ' + params.name);
msg += ' created.';
}
run('set roles=' + osrole);
run('commit');
return (msg);
}
};