diff options
Diffstat (limited to 'dcae-controller-core/dcae-controller-platform-server/src/main/server')
47 files changed, 2552 insertions, 0 deletions
diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/bin/dcae-controller.sh b/dcae-controller-core/dcae-controller-platform-server/src/main/server/bin/dcae-controller.sh new file mode 100644 index 0000000..51a6416 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/bin/dcae-controller.sh @@ -0,0 +1,130 @@ +#!/bin/bash + +cd $(dirname $(dirname $(readlink -e $0))) + +ROOT=$(pwd) +CMD=$ROOT/bin/controller-platform-server-controller + +mkdir -p logs/ +echo $(date) bin/dcae-controller.sh "$@" >> logs/dcae-controller.sh.log + +if [ -e /opt/app/dcae-controller-platform-server ]; then + ### IST/ETE/PROD deployment + ### verify/fix JAVA and GROOVY setup + FOO=todo +fi + +CMD1=$1 +shift + +case $CMD1 in + start|stop|restart|console) + if [ -e makefile ]; then + make $CMD1 + exit + fi + case $CMD1 in + start) + JVMARGS=$(cat config/controller.properties | grep JVMARGS | sed 's/[^=]*=//') + $CMD $CMD1 $JVMARGS + ;; + stop|console) + $CMD $CMD1 + ;; + *) + $CMD stop + JVMARGS=$(cat config/controller.properties | grep JVMARGS | sed 's/[^=]*=//') + $CMD start $JVMARGS + ;; + esac + exit + ;; + backup|restore) + exit + ;; + config) + /opt/app/dcae-controller-core-utils/bin/setup_https.sh config/controller.properties + exit + ;; + sync-install) + ENV=$1 + DIR=$2 + if [ ! -e config/server.private ]; then + echo "No private key: $(pwd)/config/server.private" + exit 1 + fi + for f in $DIR/config/*; do + echo "Updating config/$(basename $f)" + rm -rf config/$(basename $f) + cp -rp $f config/$(basename $f) + done + for jar in /opt/app/dcae-*-{jars,model,manager,adaptor}/lib/*.jar /opt/app/ncomp-*-{jars,model,manager,adaptor}/lib/*.jar; do + echo "Updating $jar" + cp $jar lib/ + done + exit + ;; + add-service-artifact) + G=$1 + A=$2 + V=$3 + F=$HOME/.m2/repository/$(echo $G | sed 'sx\.x/xg')/$A/$V/$A-$V.jar + #echo Local artifact $F + #if [ ! -e $F ]; then + #mvn org.apache.maven.plugins:maven-dependency-plugin:2.9:copy -Dartifact=$G:$A:$V:jar -DoutputDirectory=/tmp + #F=/tmp/$A-$V.jar + #fi + if [ ! -e $F ]; then F=/home/ubuntu/$A-$V.jar; fi + if [ ! -e $F ]; then echo "unable to find service artifact"; exit 1; fi + if [ -e lib/$A-*.jar ]; then + #echo removing old version + rm -f lib/$A-*.jar + fi + cp $F lib/ + touch config/runtime.properties + sed -i /factory.$A/d config/runtime.properties + jar tf $F | grep Factory.java | grep -v /gui/ | sed 's/.java$//' | sed sx/x.xg | awk -vA=$A '{ print "factory." A "." NR "=" $1}' >> config/runtime.properties + echo bin/dcae-controller.sh add-service-artifact "$@" >> config/init.sh + sort -u config/init.sh > config/init.sh.tmp + mv config/init.sh.tmp config/init.sh + exit + ;; + add-manager) + C2=$1 + U=$2 + P=$(echo $3 | sed 's/%/ /g') + MFILE=config/managers.properties + sed -i /$C2/d $MFILE + echo $C2.endpoint=http://IP:PORT >> $MFILE + echo $C2.user=$U >> $MFILE + echo $C2.password=$P >> $MFILE + exit + ;; + "") + echo " start" + for f in scripts/*groovy; do + cmd=$(basename $f | sed 's/.groovy$//') + echo " $cmd" + done + exit + ;; + usage) + echo ================ start ============================= + echo dcae-controller.sh start + for f in scripts/*groovy; do + cmd=$(basename $f | sed 's/.groovy$//') + echo ================ $cmd ============================= + bin/controller-platform-server-controller groovy scripts/$cmd + done + exit + ;; +esac + +if [ ! -e scripts/$CMD1.groovy ]; then + echo $0 $CMD1 does not exists. + exit 1 +fi + +bin/controller-platform-server-controller groovy scripts/$CMD1.groovy "$@" + + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/console.properties b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/console.properties new file mode 100644 index 0000000..4b63607 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/console.properties @@ -0,0 +1,3 @@ +localhost.endpoint=http://localhost:PORT +localhost.user=console +localhost.password=CONSOLE_PW diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/controller.properties b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/controller.properties new file mode 100644 index 0000000..21ff0a6 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/controller.properties @@ -0,0 +1,8 @@ +server.dir = data/resources +metrics.dir = data/metrics +properties.dir = data/properties +server.port = PORT +server.user.console = CONSOLE_PW +server.user.gui = GUI_PW +server.user.client = CLIENT_PW +server.user.monitor = MONITOR_PW diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/gui.properties b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/gui.properties new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/gui.properties diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/log4j.properties b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/log4j.properties new file mode 100644 index 0000000..529c40e --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/log4j.properties @@ -0,0 +1,91 @@ +#log4j.debug=0 +log4j.rootLogger=warn, file +log4j.logger.org.openecomp.ncomp=info, file +log4j.additivity.org.openecomp.ncomp=false +log4j.logger.org.openecomp.ncomp.datarouter=warn, file +log4j.additivity.org.openecomp.ncomp.datarouter=false +#log4j.logger.org.apache.http.headers=debug, file +#log4j.logger.org.apache.http.wire=debug, file + +## uploaded logger +log4j.logger.org.openecomp.ncomp.sirius.manager.uploaded=info, uploaded +log4j.additivity.org.openecomp.ncomp.sirius.manager.uploaded=false +## request logging +log4j.logger.org.openecomp.ncomp.sirius.manager.ManagementServer.requests=info, requests +log4j.additivity.org.openecomp.ncomp.sirius.manager.ManagementServer.requests=false +## openstack polling +log4j.logger.org.openecomp.ncomp.openstack.OpenStackUtil.polling=info, polling +log4j.additivity.org.openecomp.ncomp.openstack.OpenStackUtil.polling=false + +log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file.File=logs/dcae-controller.log +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d %5p [%t] %m %C:%L%n +log4j.appender.file.MaxFileSize=50MB +log4j.appender.file.MaxBackupIndex=5 + +log4j.appender.uploaded=org.apache.log4j.RollingFileAppender +log4j.appender.uploaded.File=logs/dcae-controller-uploaded.log +log4j.appender.uploaded.layout=org.apache.log4j.PatternLayout +log4j.appender.uploaded.layout.ConversionPattern=%d %5p [%t] %m %C:%L%n +log4j.appender.uploaded.MaxFileSize=50MB +log4j.appender.uploaded.MaxBackupIndex=5 + +log4j.appender.requests=org.apache.log4j.RollingFileAppender +log4j.appender.requests.File=logs/dcae-controller-requests.log +log4j.appender.requests.layout=org.apache.log4j.PatternLayout +log4j.appender.requests.layout.ConversionPattern=%d %5p [%t] %m %C:%L%n +log4j.appender.requests.MaxFileSize=50MB +log4j.appender.requests.MaxBackupIndex=5 + +log4j.appender.polling=org.apache.log4j.RollingFileAppender +log4j.appender.polling.File=logs/dcae-controller-polling.log +log4j.appender.polling.layout=org.apache.log4j.PatternLayout +log4j.appender.polling.layout.ConversionPattern=%d %5p [%t] %m %C:%L%n +log4j.appender.polling.MaxFileSize=50MB +log4j.appender.polling.MaxBackupIndex=5 + + +### ECOMP Logging + +log4j.logger.com.att.eelf.audit=info, audit +log4j.additivity.com.att.eelf.audit=false +log4j.logger.com.att.eelf.audit=info, metrics +log4j.additivity.com.att.eelf.metrics=false +log4j.logger.com.att.eelf.audit=info, error +log4j.additivity.com.att.eelf.error=false +log4j.logger.com.att.eelf.audit=info, debug +log4j.additivity.com.att.eelf.debug=false + +log4j.appender.audit=org.apache.log4j.RollingFileAppender +log4j.appender.audit.File=logs/audit.log +log4j.appender.audit.layout=org.apache.log4j.PatternLayout +log4j.appender.audit.layout.ConversionPattern=%d{MM/dd-HH:mm:ss.SSS}|%logger|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{Timer}|%m%n + +log4j.appender.audit.MaxFileSize=50MB +log4j.appender.audit.MaxBackupIndex=5 + +log4j.appender.metrics=org.apache.log4j.RollingFileAppender +log4j.appender.metrics.File=logs/audit.log +log4j.appender.metrics.layout=org.apache.log4j.PatternLayout +log4j.appender.metrics.layout.ConversionPattern=%d{MM/dd-HH:mm:ss.SSS}|%logger|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{Timer}|%m%n + +log4j.appender.metrics.MaxFileSize=50MB +log4j.appender.metrics.MaxBackupIndex=5 + +log4j.appender.error=org.apache.log4j.RollingFileAppender +log4j.appender.error.File=logs/audit.log +log4j.appender.error.layout=org.apache.log4j.PatternLayout +log4j.appender.error.layout.ConversionPattern=%d{MM/dd-HH:mm:ss.SSS}|%logger|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{Timer}|%m%n + +log4j.appender.error.MaxFileSize=50MB +log4j.appender.error.MaxBackupIndex=5 + +log4j.appender.debug=org.apache.log4j.RollingFileAppender +log4j.appender.debug.File=logs/audit.log +log4j.appender.debug.layout=org.apache.log4j.PatternLayout +log4j.appender.debug.layout.ConversionPattern=%d{MM/dd-HH:mm:ss.SSS}|%logger|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{Timer}|%m%n + +log4j.appender.debug.MaxFileSize=50MB +log4j.appender.debug.MaxBackupIndex=5 + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/makefile b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/makefile new file mode 100644 index 0000000..a43b607 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/makefile @@ -0,0 +1,9 @@ + +restart: stop start + +start: + M2_HOME=/home/ncomp/.m2 bin/controller-platform-server-controller start +stop: + bin/controller-platform-server-controller stop +console: + bin/controller-platform-server-controller console diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/pw.sh.sh b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/pw.sh.sh new file mode 100644 index 0000000..af4ae0d --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/pw.sh.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +### used to generate random passwords + + +echo '#!/bin/bash' +echo "" + +echo 'cat \' + +for i in CONSOLE GUI CLIENT MONITOR +do + echo ' |' sed s/${i}_PW/$(echo $i:$(date +%s) | sha256sum | base64 | head -c 20 ; echo)/ \\ +done +
\ No newline at end of file diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-dcae-location.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-dcae-location.groovy new file mode 100644 index 0000000..9aff1e2 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-dcae-location.groovy @@ -0,0 +1,50 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh add-dcae-location OPTIONS') +cli.n(longOpt:'name', args:1, 'Name of DCAE location') +cli.l(longOpt:'location', args:1, 'Name of Openstack location') +cli.p(longOpt:'project', args:1, 'Name of Openstack Project') + +def options = cli.parse(args) + +if (options == null || ! options.name || ! options.location || ! options.project ) { + println "Bad Usage:" + cli.usage() + System.exit(1) +} + +server.create("/locations/$options.name", [ openstackProject : [ '$ref' : "/openstack/locations/$options.location/projects/$options.project" ] ]) +// needed to persist. +server.update("/",[:]) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-openstack-location.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-openstack-location.groovy new file mode 100644 index 0000000..3ab8669 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-openstack-location.groovy @@ -0,0 +1,46 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh add-openstack-location OPTIONS') +cli.n(longOpt:'location', args:1, 'Name of location') +cli.k(longOpt:'keystoneURL', args:1, 'Keystone URL') +cli.b(longOpt:'bypassIp', args:1, 'Bypass Ip') +cli.v(longOpt:'version', args:1, 'Openstack version') + +def options = cli.parse(args) + +if (options == null || ! options.location || ! options.keystoneURL || ! options.bypassIp ) { + cli.usage() + System.exit(0) +} + +server.create("/openstack/locations/$options.location", [keystoneUrl:options.keystoneURL, bypassIp:options.bypassIp, version : options.version]) diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-openstack-project.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-openstack-project.groovy new file mode 100644 index 0000000..ab5ab07 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-openstack-project.groovy @@ -0,0 +1,48 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh add-openstack-project OPTIONS') +cli.o(longOpt:'location', args:1, 'Name of Openstack location') +cli.n(longOpt:'project', args:1, 'Name of project') +cli.t(longOpt:'tenantId', args:1, 'Tenant Id') +cli.u(longOpt:'user', args:1, 'User Id for this Tenant') + +def options = cli.parse(args) + +if (options == null || ! options.project || ! options.tenantId || ! options.user || ! options.location ) { + cli.usage() + System.exit(0) +} + +server.create("/openstack/locations/$options.location/projects/$options.project", [tenantId:options.tenantId, adminUser:options.user]) +server.update("/openstack/locations/$options.location/projects/$options.project", [:]) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-service-instance.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-service-instance.groovy new file mode 100644 index 0000000..19808ac --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-service-instance.groovy @@ -0,0 +1,91 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh add-service-instance OPTIONS') +cli.i(longOpt:'instance', args:1, 'Name of Service Instance') +cli.s(longOpt:'service', args:1, 'Name of Service (optional but then descriptor)') +cli.c(longOpt:'config', args:1, 'JSON configuration (optional)') +cli.f(longOpt:'configFile', args:1, 'JSON configuration File (optional)') +cli.C(longOpt:'className', args:1, 'Service Class (optional)') +cli.d(longOpt:'descriptor', args:1, 'Descriptor (optional)') +cli._(longOpt:'debug', args:0, 'Debug') +cli._(longOpt:'controllerEndpoint', args:1, 'Name of controller endpoint (optional)') + +def options = cli.parse(args) + +if (options == null || ! options.instance || ( ! options.service && ! options.descriptor ) ) { + cli.usage() + System.exit(1) +} + +server = new DcaeDcaePlatformControllerConsole("console.properties",options.controllerEndpoint ? options.controllerEndpoint : "localhost") +def service = options.descriptor ? options.descriptor : options.service + + +if (options.config && options.configFile) { + println "only one of --config and --configFile can be specified." + System.exit(1) +} + +def o = [:] + +if (options.config) { + o = Utils.json2object(new JSONObject(options.config)) +} + +if (options.configFile) { + File f = new File(options.configFile) + if (!f.exists()) { + println "Configuration File does not exists: $f.absolutePath" + System.exit(1) + } + o = Utils.json2object(new JSONObject(f.text)) +} + + +if (options.className) o['$class'] = options.className + +if (options.descriptor) { + def d = server.list("/descriptors/$options.descriptor",100) + o['$class'] = "${d.servicePackage}.${d.serviceInstanceClass}" + if (d.vmType != null) o.vmType = [ '$ref' : "/openstack/vmTypes/$d.vmType" ] + if (d.managerPortNumber != null) o.managerPortNumber = d.managerPortNumber +} + +if (options.debug) { + println o +} + +server.create("/services/$service/instances/$options.instance", o) +// needed to persist. +server.update("/",[:]) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-service.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-service.groovy new file mode 100644 index 0000000..e2c8c36 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-service.groovy @@ -0,0 +1,71 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh add-service OPTIONS') +cli.s(longOpt:'service', args:1, 'Name of Service') +cli.c(longOpt:'config', args:1, 'JSON configuration (optional)') +cli.f(longOpt:'configFile', args:1, 'JSON configuration File (optional)') +cli.C(longOpt:'className', args:1, 'Service Class') + +def options = cli.parse(args) + +if (options == null || ! options.service || ! options.className ) { + cli.usage() + System.exit(1) +} + +if (options.config && options.configFile) { + println "only one of --config and --configFile can be specified." + System.exit(1) +} + +def o = [:] + +if (options.config) { + o = Utils.json2object(new JSONObject(options.config)) +} + +if (options.configFile) { + File f = new File(options.configFile) + if (!f.exists()) { + println "Configuration File does not exists: $f.absolutePath" + System.exit(1) + } + o = Utils.json2object(new JSONObject(f.text)) +} + + +o['$class'] = options.className + +server.create("/services/$options.service", o) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/configure-service-instance.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/configure-service-instance.groovy new file mode 100644 index 0000000..29e9935 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/configure-service-instance.groovy @@ -0,0 +1,50 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh configure-service-instance OPTIONS') +cli.s(longOpt:'service', args:1, 'Name of Service') +cli.i(longOpt:'instance', args:1, 'Name of Service Instance') +cli._(longOpt:'controllerEndpoint', args:1, 'Name of controller endpoint (optional)') + +def options = cli.parse(args) + +if (options == null || ! options.service || ! options.instance ) { + cli.usage() + System.exit(1) +} +server = new DcaeDcaePlatformControllerConsole("console.properties",options.controllerEndpoint ? options.controllerEndpoint : "localhost") + +def o = [ + instanceName : options.instance, +] + +server.operation("/services/$options.service", "pushManagerConfiguration", o) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/console.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/console.groovy new file mode 100644 index 0000000..fa62023 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/console.groovy @@ -0,0 +1,27 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/create-keypair.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/create-keypair.groovy new file mode 100644 index 0000000..d7cc2ee --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/create-keypair.groovy @@ -0,0 +1,51 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + +import org.openecomp.ncomp.utils.CryptoUtils +import java.text.SimpleDateFormat + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh operation-service-instance OPTIONS') +cli.f(longOpt:'fileroot', args:1, 'File name Root') + +def options = cli.parse(args) + +if (options == null || ! options.fileroot ) { + cli.usage() + System.exit(1) +} + +["private","public"].each { x -> + def f = new File("${options.fileroot}.$x") + if (! f.exists() ) return + println "$f already exists. Proceed? [no, yes]" + def r = System.in.newReader().readLine() + switch (r) { + case "yes": break + default: System.exit(0) + } + def t = new SimpleDateFormat("yyyy-MM-dd-HH-mm").format(f.lastModified()) + f.renameTo "${options.fileroot}.$x.$t" +} + +CryptoUtils.createKeyPair(options.fileroot); + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/create-object.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/create-object.groovy new file mode 100644 index 0000000..43f9664 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/create-object.groovy @@ -0,0 +1,57 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh create-object OPTIONS') +cli.p(longOpt:'path', args:1, argName:'path', 'Resource Path') +cli.f(longOpt:'file', args:1, argName:'configFile', 'JSON configuration File (optional)') +cli.C(longOpt:'className', args:1, argName:'className', 'Class Name') + +def options = cli.parse(args) + +if (options == null || ! options.path || ! options.file ) { + cli.usage() + System.exit(1) +} + +File f = new File(options.file) +if (!f.exists()) { + println "Configuration File does not exists: $f.absolutePath" + System.exit(1) +} +o = Utils.json2object(new JSONObject(f.text)) + + +if ( options.className ) o['$class'] = options.className + +server.create(options.path, o) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/databus-refresh.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/databus-refresh.groovy new file mode 100644 index 0000000..b0791ba --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/databus-refresh.groovy @@ -0,0 +1,47 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh databus-refresh OPTIONS') +cli.m(longOpt:'nameMatch', args:1, 'Name Match') + +def options = cli.parse(args) + +if (options == null || ! options.nameMatch) { + cli.usage() + System.exit(1) +} + +def o = [nameMatch:options.nameMatch] + +server.operation("/", "refreshDataBus", o) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/decrypt-value.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/decrypt-value.groovy new file mode 100644 index 0000000..de75151 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/decrypt-value.groovy @@ -0,0 +1,38 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + +import org.openecomp.ncomp.utils.CryptoUtils + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh encrypt-password OPTIONS') +cli.v(longOpt:'value', args:1, 'Value to decrypt') + +def options = cli.parse(args) + +if (options == null || ! options.value ) { + cli.usage() + System.exit(1) +} + +str = CryptoUtils.decryptPrivate(CryptoUtils.getKey("config/server.private"),options.value); + +println "$str" diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/delete-object.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/delete-object.groovy new file mode 100644 index 0000000..1a6278e --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/delete-object.groovy @@ -0,0 +1,45 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh delete-object OPTIONS') +cli.p(longOpt:'path', args:1, argName:'path', 'Resource Path') + +def options = cli.parse(args) + +if (options == null || ! options.path ) { + cli.usage() + System.exit(1) +} + +server.delete(options.path) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-descriptor.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-descriptor.groovy new file mode 100644 index 0000000..9487c79 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-descriptor.groovy @@ -0,0 +1,82 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh deploy-descriptor OPTIONS') +cli.n(longOpt:'name', args:1, 'Descriptor Name') +cli._(longOpt:'debug', args:0, 'Debug') + +def options = cli.parse(args) + +if (options == null || ! options.name ) { + cli.usage() + System.exit(1) +} + +def d = server.list("/descriptors/$options.name",100) + +if (options.debug) { + println Utils.p(d) +} + +/* +if (d.artifact != null) { +Utils.runCmd("bin/dcae-controller.sh add-service-artifact org.openecomp.dcae.controller $d.artifact-model 0.1.0-SNAPSHOT",5000) + +switch (d.artifact) { +case "dcae-controller-service-cdap": + Utils.runCmd("bin/dcae-controller.sh add-service-artifact org.openecomp.dcae.controller $d.artifact-adaptor 0.1.0-SNAPSHOT", 5000) ; break +default: + Utils.runCmd("bin/dcae-controller.sh add-service-artifact org.openecomp.dcae.controller $d.artifact-manager 0.1.0-SNAPSHOT", 5000) +} + +switch (d['$class']) { + case "org.openecomp.dcae.controller.service.vm.VirtualMachineServiceDescriptor": + if (d.encryptedPassword == null || ! d.encryptedPassword.startsWith("rsa:") ) { + System.err.println "Bad Password: $d.encryptedPassword" + System.exit(2) + } + def p = d.encryptedPassword.replace(" ","%") + Utils.runCmd("bin/dcae-controller.sh add-manager ${d.servicePackage}.${d.serviceInstanceClass} $d.managerUser $p",5000) +} + + +Utils.runCmd("bin/dcae-controller.sh stop", 20000) +Utils.runCmd("bin/dcae-controller.sh start", 30000) + +Utils.runCmd("sleep 25",60000) +} +*/ + +def o = [:] +o['$class'] = "${d.servicePackage}.${d.serviceClass}" +if (d.managerPortNumber != null) o.managerPortNumber = d.managerPortNumber + +// creating service +server.create("/services/$options.name", o) diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-manual-vm-service-instance.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-manual-vm-service-instance.groovy new file mode 100644 index 0000000..f25dbea --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-manual-vm-service-instance.groovy @@ -0,0 +1,58 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh deploy-service-instance OPTIONS') +cli.i(longOpt:'instance', args:1, 'Name of Service Instance') +cli.s(longOpt:'service', args:1, 'Name of Service') +cli._(longOpt:'publicIp', args:1, 'Public IP') +cli._(longOpt:'privateIp', args:1, 'Private IP') +cli._(longOpt:'port', args:1, 'Port Number') + +def options = cli.parse(args) + +if (options == null || ! options.service || ! options.instance ) { + cli.usage() + System.exit(1) +} + +def o = [ + '$class':"org.openecomp.dcae.controller.service.vm.PhysicalMachine", +] + +if (options.publicIp) o.publicIp = options.publicIp +if (options.privateIp) o.privateIp = options.privateIp +if (options.port) o.managerPortNumber = options.port + +def n ="manual:$options.service:$options.instance:0" + +server.create("/services/$options.service/instances/$options.instance/servers/$n", o) diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-service-instance.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-service-instance.groovy new file mode 100644 index 0000000..61c45c5 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-service-instance.groovy @@ -0,0 +1,51 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh deploy-service-instance OPTIONS') +cli.i(longOpt:'instance', args:1, argName:'instance', 'Name of Service Instance') +cli.s(longOpt:'service', args:1, argName:'service', 'Name of Service') +cli.c(longOpt:'container', args:1, argName:'container', 'Path to Service Container') +cli._(longOpt:'controllerEndpoint', args:1, 'Name of controller endpoint (optional)') + +def options = cli.parse(args) + +if (options == null || ! options.service || ! options.instance ) { + cli.usage() + System.exit(1) +} + +server = new DcaeDcaePlatformControllerConsole("console.properties",options.controllerEndpoint ? options.controllerEndpoint : "localhost") + +def o = [ instanceName: options.instance ] + +if (options.container) o.containerPath = options.container +server.operation("/services/$options.service", "deploy", o) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-undeployed-descriptors.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-undeployed-descriptors.groovy new file mode 100644 index 0000000..1b9c7cb --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-undeployed-descriptors.groovy @@ -0,0 +1,59 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh deploy-undeployed-descriptors OPTIONS') + +def options = cli.parse(args) + +if (options == null ) { + println "Bad Usage:" + cli.usage() + System.exit(1) +} + +l1 = server.list("/descriptors").descriptors +l2 = server.list("/services").services + +println "descriptors: $l1" +println "services: $l2" + +(l1 - l2).each { n -> + d = server.list("/descriptors/$n") + switch (d['$class']) { + case null: break + default: + println "Deploying undeployed descriptor $n" + Utils.runCmd("bin/dcae-controller.sh deploy-descriptor --name $n", 100000) + l3 = server.list("/",0).services + if (l3.contains(n)) + println "Done: services: ${server.list("/services").services}" + else + System.err.println "Failed to deploy $n: services: ${server.list("/services").services}" + } +} + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-user.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-user.groovy new file mode 100644 index 0000000..5100faa --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-user.groovy @@ -0,0 +1,50 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh deploy-user OPTIONS') +cli.p(longOpt:'project', args:1, 'Openstack Project') +cli.l(longOpt:'location', args:1, 'Openstack Location') +cli.u(longOpt:'user', args:1, 'User') + +def options = cli.parse(args) + +if (options == null || ! options.user || ! options.location || ! options.project ) { + cli.usage() + System.exit(1) +} + +server.operation("/openstack/locations/$options.location", "deployUser", [ + projectName : options.project, + user : [ '$ref' : "/users/$options.user", '$refroot' :"/" ] +]) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-vmType.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-vmType.groovy new file mode 100644 index 0000000..40669d8 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-vmType.groovy @@ -0,0 +1,47 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh deploy-vmType OPTIONS') +cli.v(longOpt:'vmType', args:1, 'Name of VmType') +cli.l(longOpt:'location', args:1, 'Openstack Location') +cli.p(longOpt:'project', args:1, 'Openstack Project') + +def options = cli.parse(args) + +if (options == null || ! options.vmType || ! options.location || ! options.project ) { + cli.usage() + System.exit(1) +} + +server.operation("/openstack/locations/$options.location", "deployVmType", [ projectName : options.project, vmTypeName : options.vmType ]) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/encrypt-file.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/encrypt-file.groovy new file mode 100644 index 0000000..ee146c1 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/encrypt-file.groovy @@ -0,0 +1,64 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + +import org.openecomp.ncomp.utils.CryptoUtils +import java.security.SecureRandom; +import java.math.BigInteger; +import org.json.JSONObject; +import org.yaml.snakeyaml.DumperOptions; +import org.yaml.snakeyaml.Yaml; +import static org.openecomp.ncomp.sirius.manager.console.Utils.*; + +class X { +static def object2yaml(Object object) { + DumperOptions options = new DumperOptions(); + options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); + options.setSplitLines(true); + options.setWidth(100000); + Yaml y = new Yaml(options); + JSONObject json = (JSONObject) object2json(object); + def data = y.load(json.toString()); + return y.dump(data); +} +} + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh encrypt-file OPTIONS') +cli.k(longOpt:'key', args:1, 'Public Key File') +cli.f(longOpt:'file', args:1, 'File') + +def options = cli.parse(args) + +if (options == null || ! options.key || ! options.file ) { + cli.usage() + System.exit(1) +} + +def password = new BigInteger(130, new SecureRandom()).toString(32); + +println password + +str = CryptoUtils.encrypt(password,new File(options.file).text).replace("\r",""); + +str1 = CryptoUtils.encryptPublic(CryptoUtils.getKey(options.key),password).replace("\r",""); + +println X.object2yaml(['encrypted-file': [ content:str, 'encrypted-password' : str1 ]]) diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/encrypt-password.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/encrypt-password.groovy new file mode 100644 index 0000000..d13ce8c --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/encrypt-password.groovy @@ -0,0 +1,43 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + +import org.openecomp.ncomp.utils.CryptoUtils + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh encrypt-password OPTIONS') +cli.k(longOpt:'key', args:1, 'Public Key File') + +def options = cli.parse(args) + +if (options == null || ! options.key ) { + cli.usage() + System.exit(1) +} + +def password = System.console().readLine 'Password to encrypt?' + + +str = CryptoUtils.encryptPublic(CryptoUtils.getKey(options.key),password); + +str = str.replace('\n',' ').replace('\r',' ') + +println "rsa:$str" diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/get-service-instance-configuration.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/get-service-instance-configuration.groovy new file mode 100644 index 0000000..bf1b44e --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/get-service-instance-configuration.groovy @@ -0,0 +1,46 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh get-service-instance-configuration OPTIONS') +cli.i(longOpt:'instance', args:1, 'Name of Service Instance') +cli.s(longOpt:'service', args:1, 'Name of Service') + +def options = cli.parse(args) + +if (options == null || ! options.instance || ! options.service ) { + cli.usage() + System.exit(1) +} + +println Utils.object2json(server.list("/services/$options.service/instances/$options.instance", 100)).toString(2) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/get-service-instance-manager-configuration.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/get-service-instance-manager-configuration.groovy new file mode 100644 index 0000000..cf18a8d --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/get-service-instance-manager-configuration.groovy @@ -0,0 +1,48 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh get-service-instance-configuration OPTIONS') +cli.i(longOpt:'instance', args:1, 'Name of Service Instance') +cli.s(longOpt:'service', args:1, 'Name of Service') +cli._(longOpt:'controllerEndpoint', args:1, 'Name of controller endpoint (optional)') + +def options = cli.parse(args) + +if (options == null || ! options.instance || ! options.service ) { + cli.usage() + System.exit(1) +} + +server = new DcaeDcaePlatformControllerConsole("console.properties",options.controllerEndpoint ? options.controllerEndpoint : "localhost") +def o = [ instanceName : options.instance ] +println Utils.object2json(server.operation("/services/$options.service", "managerConfiguration", o)).toString(2) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/init-controller.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/init-controller.groovy new file mode 100644 index 0000000..28d0a78 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/init-controller.groovy @@ -0,0 +1,32 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + +try { server.delete("/openstack") } catch (e) {} +server.create("/openstack", [:]) diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/list-object.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/list-object.groovy new file mode 100644 index 0000000..9c1b03a --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/list-object.groovy @@ -0,0 +1,48 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh list-object OPTIONS') +cli.p(longOpt:'path', args:1, argName:'path', 'Resource Path') +cli.l(longOpt:'levels', args:1, argName:'levels', 'Resource Path') + +def options = cli.parse(args) + +if (options == null || ! options.path ) { + cli.usage() + System.exit(1) +} + +def levels = options.levels ? Integer.parseInt(options.levels) : 0 + +println Utils.p(server.list(options.path,levels)) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/operation-service-instance.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/operation-service-instance.groovy new file mode 100644 index 0000000..b71031b --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/operation-service-instance.groovy @@ -0,0 +1,66 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh operation-service-instance OPTIONS') +cli.s(longOpt:'service', args:1, 'Name of Service') +cli.i(longOpt:'instance', args:1, 'Name of Service Instance') +cli.o(longOpt:'operation', args:1, 'Name of Operation') +cli.p(longOpt:'parameters', args:1, 'JSON Object with parameters (optional)') + +def options = cli.parse(args) + +if (options == null || ! options.service || ! options.operation || ! options.instance ) { + cli.usage() + System.exit(1) +} + +def o = [ + instanceName : options.instance, + operation : options.operation, +] + +if (options.parameters) { + o.parameters = "$options.parameters" +} + +def res = server.operation("/services/$options.service", "managerOperation", o) + +try { + def json = new JSONObject(res.returns) + println json.toString(2) +} +catch (e) { + println res.returns +} + + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/operation-service.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/operation-service.groovy new file mode 100644 index 0000000..7a0e5c0 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/operation-service.groovy @@ -0,0 +1,53 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh operation-service OPTIONS') +cli.s(longOpt:'service', args:1, 'Name of Service') +cli.o(longOpt:'operation', args:1, 'Name of Operation') +cli.p(longOpt:'parameters', args:1, 'JSON Object with parameters (optional)') + +def options = cli.parse(args) + +if (options == null || ! options.service || ! options.operation ) { + cli.usage() + System.exit(1) +} + +def o = [:] + +if (options.parameters) { + o = Utils.json2object(new JSONObject(options.parameters)) +} + +println Utils.object2json(server.operation("/services/$options.service", options.operation, o)).toString(2) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/rackspace-substitute.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/rackspace-substitute.groovy new file mode 100644 index 0000000..855e151 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/rackspace-substitute.groovy @@ -0,0 +1,60 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + +import org.yaml.snakeyaml.Yaml; + +import org.openecomp.ncomp.utils.CryptoUtils; +import org.openecomp.ncomp.utils.StringUtil; + +import groovy.text.SimpleTemplateEngine +import groovy.io.FileType + +import org.openecomp.ncomp.webservice.utils.FileUtils +import static org.openecomp.ncomp.sirius.manager.console.Utils.*; + + +def cli = new CliBuilder(usage:'dcae-controller.sh rackspace-substitute OPTIONS') +cli.a(longOpt:'from', args:1, 'Source Directory') +cli.b(longOpt:'to', args:1, 'Destination Directory') +cli.f(longOpt:'file', args:1, 'Substitution YAML File') + +def options = cli.parse(args) + +def fromDir = new File(options.from) +def toDir = new File(options.to) + +if (toDir.exists()) + FileUtils.deleteDirectory(toDir) + +def f = new File(options.file) +Yaml yaml = new Yaml(); +def m = yaml.load(f.text) + +if (m['POLICY-IP'] == null) m['POLICY-IP'] = "10.0.6.1" + +fromDir.eachFileRecurse (FileType.FILES) { file -> + def ofile = new File(file.toString().replace(options.from, options.to)) + switch (file.name) { + default: + ofile.parentFile.mkdirs() + ofile.text = StringUtil.expandUsingJson(file.text, object2json(m), "@") + } +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/report.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/report.groovy new file mode 100644 index 0000000..a40e367 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/report.groovy @@ -0,0 +1,64 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh reports OPTIONS') +cli.n(longOpt:'name', args:1, 'Report Name') +cli._(longOpt:'debug', args:0, 'Debug') +cli._(longOpt:'controllerEndpoint', args:1, 'Name of controller endpoint (optional)') + +def options = cli.parse(args) +server = new DcaeDcaePlatformControllerConsole("console.properties",options.controllerEndpoint ? options.controllerEndpoint : "localhost") + +if (options == null || ! options.name ) { + cli.usage() + System.exit(1) +} + +def table = server.operation("/gui","getTable", [path:"$options.name",start:"-24hour",end:"now"]) + + +def convert(table) { +// println table.rows.get(0) + def res = [header:[],rows:[]] + table.columns.each { col -> + res.header += col.colName + } + table.rows.each { row -> + def r = [] + row.cells.each { cell -> + r += cell.value + } + res.rows += [ r ] + } + return res +} + +println Utils.pTable(convert(table.returns),"txt",System.out) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/setup-openstack-bash-shell.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/setup-openstack-bash-shell.groovy new file mode 100644 index 0000000..5dd25f8 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/setup-openstack-bash-shell.groovy @@ -0,0 +1,74 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.openecomp.ncomp.sirius.manager.JavaHttpClient; + + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh setup-openstack-bash-shell OPTIONS') +cli.l(longOpt:'location', args:1, 'Openstack Location') +cli.p(longOpt:'project', args:1, 'Openstack Project') + +def options = cli.parse(args) + +if (options == null || ! options.location || ! options.project ) { + cli.usage() + System.exit(1) +} + +def x = server.list("/openstack/locations/$options.location", 1000) +def p = x.projects[options.project] + +if (p == null) { + println "no project $options.project exists at location $options.location" + System.exit(1) +} + +def prop = org.openecomp.ncomp.utils.PropertyUtil.getPropertiesFromClasspath("openstack.properties") + +def pw = prop.getProperty("${options.location}.password.$p.adminUser") +if (pw == null) { + println "Unable to find property ${options.location}.password.$p.adminUser in openstack.properties" + System.exit(1) +} + +def f = new File(".openstack.${options.location}.${options.project}") +if (f.exists()) f.delete() + +f << "export OS_AUTH_URL=$x.keystoneUrl\n" +f << "export OS_TENANT_ID=$p.tenantId\n" +f << "export OS_TENANT_NAME=$options.location\n" +f << "export OS_PROJECT_NAME=$options.location\n" +f << "export OS_USERNAME=$p.adminUser\n" +f << "export OS_PASSWORD=${JavaHttpClient.decryptPassword(pw)}\n" +if (p.region != null) f << "export OS_REGION_NAME=$p.region\n" + +println "Wrote . $f" + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/sync-configuration-from-directory.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/sync-configuration-from-directory.groovy new file mode 100644 index 0000000..a155b9c --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/sync-configuration-from-directory.groovy @@ -0,0 +1,83 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject +import org.openecomp.ncomp.sirius.manager.ManagementServer; + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh deploy-descriptor OPTIONS') +cli.d(longOpt:'directory', args:1, 'Configuration Directory') +cli._(longOpt:'force', args:0, 'Force update') +cli._(longOpt:'debug', args:0, 'Debug') + +def options = cli.parse(args) + +if (options == null || ! options.directory ) { + cli.usage() + System.exit(1) +} + +m = new ManagementServer() +m.eFactory = org.openecomp.dcae.controller.platform.controller.ControllerFactory.eINSTANCE +m.eClassName = "DcaePlatformController" +org.openecomp.dcae.controller.platform.controller.ControllerPackage.eINSTANCE +org.openecomp.dcae.controller.service.vm.VmPackage.eINSTANCE +m.addFactory(org.openecomp.dcae.controller.service.vm.VmFactory.eINSTANCE) +m.addRuntimeFactories(null) + +def o = m.load(options.directory) +o = Utils.json2object(Utils.object2json(o)) +o.services = null + +if (o.openstack != null && o.openstack.locations != null) { + o.openstack.locations.each { locN, loc -> + loc.projects.each { projectN, project -> + project.each { n2, v2 -> + switch (n2) { + case "privateNetwork" : + case "region" : + case "publicNetwork" : + case "adminUser" : + case "apiKey" : + case "tenantId" : break + default: project[n2] = null + } + } + } + } +} + +if (options.force) { o['$forcedUpdate'] = 1 } +if (options.debug) { println Utils.object2json(o).toString(2) } + + +// currently references are not handled correctly in SOMF to new objects. So doing it twice fixes that. +// first time we do not need to persist the changes on the controller +o['$nosave'] = 1 +server.update("/",o) +o['$nosave'] = null +server.update("/",o) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/sync-configuration.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/sync-configuration.groovy new file mode 100644 index 0000000..386515a --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/sync-configuration.groovy @@ -0,0 +1,59 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject +import org.openecomp.ncomp.sirius.manager.ManagementServer; + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh sync-configuration OPTIONS') +cli.e(longOpt:'environment', args:1, 'Configuration Directory') +cli._(longOpt:'force', args:0, 'Force update') +cli._(longOpt:'debug', args:0, 'Debug') + +def options = cli.parse(args) + +if (options == null || ! options.environment ) { + cli.usage() + System.exit(1) +} + +def dir = "GITLINK/$options.environment/controller-gen" + +def f = new File(dir) + +if (!f.exists()) { + println "Configuration directory does not exists: $dir" + System.exit(1) +} + +Utils.runCmd("bin/dcae-controller.sh sync-install $options.environment $dir", 60000) + +Utils.runCmd("bin/dcae-controller.sh start", 60000) + +Utils.runCmd("bin/dcae-controller.sh sync-configuration-from-directory --directory $dir/resources", 600000) + +Utils.runCmd("bin/dcae-controller.sh deploy-undeployed-descriptors", 6000000) + +Utils.runCmd("bin/dcae-controller.sh sync-services-from-directory --directory $dir/services-resources", 600000) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/sync-services-from-directory.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/sync-services-from-directory.groovy new file mode 100644 index 0000000..845b510 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/sync-services-from-directory.groovy @@ -0,0 +1,90 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject +import org.openecomp.ncomp.sirius.manager.ManagementServer; +import org.openecomp.ncomp.webservice.utils.JsonUtils + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh sync-services-from-directory OPTIONS') +cli.d(longOpt:'directory', args:1, 'Configuration Directory') +cli._(longOpt:'force', args:0, 'Force update') +cli._(longOpt:'debug', args:0, 'Debug') + +def options = cli.parse(args) + +if (options == null || ! options.directory ) { + cli.usage() + System.exit(1) +} + +m = new ManagementServer() +m.eFactory = org.openecomp.dcae.controller.platform.controller.ControllerFactory.eINSTANCE +m.eClassName = "DcaePlatformController" +org.openecomp.dcae.controller.platform.controller.ControllerPackage.eINSTANCE +org.openecomp.dcae.controller.service.vm.VmPackage.eINSTANCE +m.addFactory(org.openecomp.dcae.controller.service.vm.VmFactory.eINSTANCE) +m.addRuntimeFactories(null) + +def o = m.load(options.directory) +o = Utils.json2object(Utils.object2json(o)) + +def rootFile = new File("$options.directory/services") + +if (options.debug) { println Utils.object2json(o).toString(2) } + +def services = server.list("/services").services + +rootFile.listFiles().each { File f -> +// println "$f" + String sname = f.name + if (sname.endsWith(".json")) return + println "service $sname" + if (! services.contains(sname)) { + println "No such service: $sname" + return + } + def instances = server.list("/services/$sname/instances").instances + def dir = new File("$options.directory/services/$sname/instances") + dir.listFiles().each { File f1 -> + def iname = f1.name.replace(".json", "") + JSONObject instance = JsonUtils.file2json("$options.directory/services/$sname/instances/${iname}.json") +// println "json ${instance.toString(2)}" + instance.put('$nosave',1); +// instance.put('$useNull',1); + if (instances.contains(iname)) { + server.update("/services/$sname/instances/$iname",instance) + println "updating instance $iname" + } else { + server.create("/services/$sname/instances/$iname",instance) + println "creating instance $iname" + } + } +} + +server.update("/",[:]) + + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/tosca-add-blueprint.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/tosca-add-blueprint.groovy new file mode 100644 index 0000000..b08fdc3 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/tosca-add-blueprint.groovy @@ -0,0 +1,69 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh add-service-instance OPTIONS') +cli.i(longOpt:'instance', args:1, 'Name of Service Instance') +cli.s(longOpt:'service', args:1, 'Name of Service (optional but then descriptor)') +cli.f(longOpt:'toscaFile', args:1, 'Tosca configuration File') +cli._(longOpt:'debug', args:0, 'Debug') +cli._(longOpt:'controllerEndpoint', args:1, 'Name of controller endpoint (optional)') + +def options = cli.parse(args) + +if (options == null || ! options.instance || ! options.service || ! options.toscaFile ) { + cli.usage() + System.exit(1) +} + +server = new DcaeDcaePlatformControllerConsole("console.properties",options.controllerEndpoint ? options.controllerEndpoint : "localhost") + +def service = options.descriptor ? options.descriptor : options.service + +if (options.config) { + o = Utils.json2object(new JSONObject(options.config)) +} + +File f = new File(options.toscaFile) +if (!f.exists()) { + println "Tosca File does not exists: $f.absolutePath" + System.exit(1) +} + +def o = [instanceName:options.instance,blueprintYaml:f.text] + + +if (options.debug) { + println o +} + +server.operation("/services/$options.service", "uploadBlueprint", o) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-service-instance-chef.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-service-instance-chef.groovy new file mode 100644 index 0000000..1e7ed99 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-service-instance-chef.groovy @@ -0,0 +1,68 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + +
+
+import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole
+import org.openecomp.ncomp.sirius.manager.console.Utils
+
+import org.json.JSONObject
+import org.junit.After;
+
+server = new DcaeDcaePlatformControllerConsole("console.properties","localhost")
+
+def p(x) { Utils.object2json(x).toString(2) }
+
+// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html
+def cli = new CliBuilder(usage:'dcae-controller.sh undeploy-service-instance OPTIONS')
+cli.i(longOpt:'instance', args:1, argName:'instance', 'Name of Service Instance')
+cli.s(longOpt:'service', args:1, argName:'service', 'Name of Service')
+
+def options = cli.parse(args)
+
+if (options == null || ! options.service || ! options.instance ) {
+ cli.usage()
+ System.exit(1)
+}
+
+def servers = []
+
+server.listAll("/services/$options.service/instances/$options.instance/servers/.*/networks/.*").each { p ->
+
+ def x = server.list(p)
+ if ( x.dnsName == null) return
+ servers += x.dnsName
+}
+
+servers.each { n ->
+ try {
+ println "$n"
+ Utils.runCmd("knife node delete $n --yes",10000)
+ Utils.runCmd("knife client delete $n --yes",10000)
+ }
+ catch (e) {
+ println "Error removing node from CHEF"
+ }
+}
+
+server.operation("/services/$options.service", "undeploy", [ instanceName: options.instance ])
+
+
diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-service-instance.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-service-instance.groovy new file mode 100644 index 0000000..bc5de44 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-service-instance.groovy @@ -0,0 +1,46 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh undeploy-service-instance OPTIONS') +cli.i(longOpt:'instance', args:1, argName:'instance', 'Name of Service Instance') +cli.s(longOpt:'service', args:1, argName:'service', 'Name of Service') + +def options = cli.parse(args) + +if (options == null || ! options.service || ! options.instance ) { + cli.usage() + System.exit(1) +} + +server.operation("/services/$options.service", "undeploy", [ instanceName: options.instance ]) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-user.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-user.groovy new file mode 100644 index 0000000..daac7f2 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-user.groovy @@ -0,0 +1,50 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh undeploy-user OPTIONS') +cli.p(longOpt:'project', args:1, 'Openstack Project') +cli.l(longOpt:'location', args:1, 'Openstack Location') +cli.u(longOpt:'user', args:1, 'User') + +def options = cli.parse(args) + +if (options == null || ! options.user || ! options.location || ! options.project ) { + cli.usage() + System.exit(1) +} + +server.operation("/openstack/locations/$options.location", "undeployUser", [ + projectName : options.project, + user : [ '$ref' : "/users/$options.user", '$refroot' :"/" ] +]) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-vmType.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-vmType.groovy new file mode 100644 index 0000000..68c82d7 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-vmType.groovy @@ -0,0 +1,47 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh undeploy-vmType OPTIONS') +cli.v(longOpt:'vmType', args:1, 'Name of VmType') +cli.l(longOpt:'location', args:1, 'Openstack Location') +cli.p(longOpt:'project', args:1, 'Openstack Project') + +def options = cli.parse(args) + +if (options == null || ! options.vmType || ! options.location || ! options.project ) { + cli.usage() + System.exit(1) +} + +server.operation("/openstack/locations/$options.location", "undeployVmType", [ projectName : options.project, vmTypeName : options.vmType ]) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/update-configuration-from-policy-service-instance.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/update-configuration-from-policy-service-instance.groovy new file mode 100644 index 0000000..09ef819 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/update-configuration-from-policy-service-instance.groovy @@ -0,0 +1,50 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh update-configuration-from-policy-service-instance OPTIONS') +cli.s(longOpt:'service', args:1, 'Name of Service') +cli.i(longOpt:'instance', args:1, 'Name of Service Instance') + +def options = cli.parse(args) + +if (options == null || ! options.service || ! options.instance ) { + cli.usage() + System.exit(1) +} + +def o = [ + instanceName : options.instance, +] + +server.operation("/services/$options.service", "updateConfigurationFromPolicy", o) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/update-object.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/update-object.groovy new file mode 100644 index 0000000..df45f25 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/update-object.groovy @@ -0,0 +1,67 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh create-object OPTIONS') +cli.p(longOpt:'path', args:1, argName:'path', 'Resource Path') +cli.f(longOpt:'file', args:1, argName:'configFile', 'JSON configuration File (optional)') +cli.c(longOpt:'config', args:1, argName:'config', 'JSON configuration (optional)') + +def options = cli.parse(args) + +if (options == null || ! options.path || ( ! options.file && ! options.config ) ) { + cli.usage() + System.exit(1) +} + +if (options.config && options.file) { + println "only one of --config and --configFile can be specified." + System.exit(1) +} + +def o = [:] + +if (options.config) { + o = Utils.json2object(new JSONObject(options.config)) +} + +if (options.file) { + File f = new File(options.file) + if (!f.exists()) { + println "Configuration File does not exists: $f.absolutePath" + System.exit(1) + } + o = Utils.json2object(new JSONObject(f.text)) +} + +server.update(options.path, o) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/wait-for.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/wait-for.groovy new file mode 100644 index 0000000..1c2f840 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/wait-for.groovy @@ -0,0 +1,101 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. 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. + * ============LICENSE_END============================================ + */ + +import org.yaml.snakeyaml.Yaml; + + +import groovy.text.SimpleTemplateEngine +import groovy.io.FileType +import static org.openecomp.ncomp.sirius.manager.console.Utils.*; + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def cli = new CliBuilder(usage:'dcae-controller.sh wait-for OPTIONS') +cli.p(longOpt:'path', args:1, 'Resource Path') +cli.e(longOpt:'exists', args:0, 'Object Exists') +cli.a(longOpt:'attribute', args:1, 'Attribute') +cli.m(longOpt:'match', args:1, 'Match') +cli.n(longOpt:'isNull', args:0, 'Is Null') +cli.N(longOpt:'isNotNull', args:0, 'Is not Null') +cli.f(longOpt:'frequency', args:1, 'Polling Frequency (seconds)') +cli.t(longOpt:'timeout', args:1, 'Timeout (seconds)') +cli._(longOpt:'debug', args:0, 'Debug') +cli.v(longOpt:'verbose', args:0, 'Verbose') + +def options = cli.parse(args) + +if (args.length == 0 ) { + cli.usage() + System.exit(1) +} + + +def timeout = options.timeout ? Long.parseLong(options.timeout) * 1000 : 300000 // default 5 min +def frequency = options.frequency ? Long.parseLong(options.frequency) * 1000 : 30000 // default 30 seconds +def path = options.path ? options.path : "/" // default 30 seconds + +Date start = new Date() + +def status = "UNKNOWN" +while (new Date().time < start.time + timeout) { + def o = null + try { o = server.list(path,0) } catch (e) { + if (options.debug) println "LISTING error: $e" + } + if (options.debug) { + if (o) + println "object is ${object2json(o).toString(2)}" + else + println "object is NULL" + } + if ( ! options.exists && o == null) { + println "Error: caller expect the object to exists but it does not: $path" + System.exit(2) + } + if (options.exists && o == null) { + // need to keep waiting + status = "Object does not exists: $path" + } + else { + if ( ! options.attribute ) System.exit(0) + def a = options.attribute + def v = o[a] + if (options.isNull) { + if (v == null) System.exit(0) else status = "Attribute not null: $path@$a" + } + if (options.isNotNull) { + if (v != null) System.exit(0) else status = "Attribute null: $path@$a" + } + if (options.match) { + if ("$v" == options.match) System.exit(0) else status = "Attribute match: $path@$a '$v' != '$options.match'" + } + } + if (options.verbose) + println "Waiting: $status : waited ${new Date().time-start.time} milliseconds" + Thread.sleep(frequency) +} + +println "Error: Timeout: $status : waited ${new Date().time-start.time} milliseconds" +System.exit(2) + + |