2900N/A/*
2900N/A * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
2900N/A *
2900N/A * Licensed under the Apache License, Version 2.0 (the "License"); you may
2900N/A * not use this file except in compliance with the License. You may obtain
2900N/A * a copy of the License at
2900N/A *
2900N/A * http://www.apache.org/licenses/LICENSE-2.0
2900N/A *
2900N/A * Unless required by applicable law or agreed to in writing, software
2900N/A * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
2900N/A * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
2900N/A * License for the specific language governing permissions and limitations
2900N/A * under the License.
2900N/A */
2900N/A
2900N/Avar workflow = {
2900N/A name: 'Configuration for OpenStack Cinder Driver',
2900N/A origin: 'Oracle Corporation',
2900N/A description: 'Setup environment for OpenStack Cinder Driver',
2900N/A version: '1.0.0',
2900N/A parameters: {
2900N/A name: {
2900N/A label: 'Cinder\'s User\'s Name',
2900N/A type: 'String'
2900N/A },
2900N/A password: {
2900N/A label: 'Password',
2900N/A type: 'Password'
2900N/A }
2900N/A },
2900N/A execute: function (params) {
2900N/A /*
2900N/A * Check for REST service to be enabled
2900N/A */
2900N/A try {
2900N/A run('configuration services rest');
2900N/A if (get('<status>') != 'online')
2900N/A run('enable');
2900N/A } catch (err) {
2900N/A return ('The REST API is not available on this version of \
2900N/A appliance software and is required to run with the \
2900N/A ZFSSA cinder driver. Please upgrade the appliance \
2900N/A software.');
2900N/A }
2900N/A
2900N/A /*
2900N/A * Cinder role
2900N/A */
2900N/A var osrole = 'OpenStackRole';
2900N/A run('cd /');
2900N/A run('configuration roles');
2900N/A try {
2900N/A run('select ' + osrole);
2900N/A } catch(err) {
2900N/A run('role ' + osrole);
2900N/A run('set description="OpenStack Cinder Driver"');
2900N/A run('commit');
2900N/A run('select ' + osrole);
2900N/A }
2900N/A run('authorizations');
2900N/A run('create');
2900N/A run('set scope=stmf');
2900N/A run('set allow_configure=true');
2900N/A run('commit');
2900N/A run('create');
2900N/A run('set scope=nas');
2900N/A run('set allow_clone=true');
2900N/A run('set allow_createProject=true');
2900N/A run('set allow_createShare=true');
2900N/A run('set allow_changeSpaceProps=true');
2900N/A run('set allow_changeGeneralProps=true');
2900N/A run('set allow_destroy=true');
2900N/A run('set allow_rollback=true');
2900N/A run('set allow_takeSnap=true');
2900N/A run('commit');
2900N/A
2900N/A /*
2900N/A * Set user with Cinder role
2900N/A */
2900N/A var msg = 'User ' + params.name;
2900N/A run('cd /')
2900N/A run('configuration users');
2900N/A try {
2900N/A run('select ' + params.name);
2900N/A msg += ' updated.';
2900N/A } catch (err) {
2900N/A run('user ' + params.name);
2900N/A run('set initial_password=' + params.password);
2900N/A run('set fullname="OpenStack Cinder Driver"');
2900N/A run('commit');
2900N/A run('select ' + params.name);
2900N/A msg += ' created.';
2900N/A }
2900N/A run('set roles=' + osrole);
2900N/A run('commit');
2900N/A return (msg);
2900N/A }
2900N/A};