diff --git a/.env b/.env index 3d33a846994f75814bc466052fb0eecdec57ca12..5565a83ebba9713acde60c159877db536576c55b 100644 --- a/.env +++ b/.env @@ -1,29 +1,10 @@ -# Reference documentation https://docs.docker.com/compose/environment-variables/ -# Focus default variables as production, to allow direct download and run in production -# Required external variables that must be defined externally are those that have no value - -DEVSVC_BASE_PATH=development-services/ -DEVSVC_SETUP_BASE_PATH= - -#### Production related #### - -DOCKER_REGISTRY_PREFIX=optima-piacere-docker-dev.artifact.tecnalia.com -PROJECT_NAME= -COMPOSE_PROJECT_VERSION=y1 - -TZ=Madrid -ADMIN_PASSWORD=piacerePassword -HTTPS_PORT=8443 -SERVER_HOST=192.168.56.1.nip.io -IOP_SPRING_PROFILES_ACTIVE=dev,api-docs,no-liquibase - -# https://docs.docker.com/compose/reference/envvars/#compose_file#compose_project_name -# these are docker-compose related environment variables -COMPOSE_PROJECT_NAME=piacere-production -COMPOSE_FILE=docker-compose-iop.yaml:docker-compose-iop-traefik.yaml:docker-compose-traefik-tecnalia-selfsigned-sans.yaml:development-services/docker-compose-traefik-selfsigned.yaml:docker-compose-expose.yaml:docker-compose-redirect-http.yaml - -#### Build related #### -DOCKER_BUILDKIT=1 -COMPOSE_DOCKER_CLI_BUILD=1 - - +TRAEFIK_NETWORK_NAME=traefik_network +TRAEFIK_HTTPS_ENTRYPOINT_NAME=websecure +ADMIN_USER=admin +ADMIN_PASSWORD=projectPassword +HTTPS_PORT=443 +SERVER_HOST=ci.piacere.digital.tecnalia.dev +IOP_SPRING_PROFILES_ACTIVE=prod,api-docs,no-liquibase +COMPOSE_PROJECT_NAME=piacere-iop-production +IMAGE_IOP_OPTIMIZER=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iop-optimizer:y3 +COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:release/docker-compose.yaml diff --git a/.env.build b/.env.build deleted file mode 100644 index c92ebba2f06c5d3848e4215d0f6ebb59afb0ec16..0000000000000000000000000000000000000000 --- a/.env.build +++ /dev/null @@ -1,28 +0,0 @@ -# Reference documentation https://docs.docker.com/compose/environment-variables/ -# Focus default variables as production, to allow direct download and run in production -# Required external variables that must be defined externally are those that have no value - -DEVSVC_BASE_PATH=development-services/ - -#### Production related #### - -DOCKER_REGISTRY_PREFIX=optima-piacere-docker-dev.artifact.tecnalia.com -PROJECT_NAME= -COMPOSE_PROJECT_VERSION=y1 - -TZ=Madrid -ADMIN_PASSWORD=piacerePassword -HTTPS_PORT=8443 -SERVER_HOST=192.168.56.1.nip.io -IOP_SPRING_PROFILES_ACTIVE=prod,api-docs,no-liquibase - -# https://docs.docker.com/compose/reference/envvars/#compose_file#compose_project_name -# these are docker-compose related environment variables -COMPOSE_PROJECT_NAME=piacere-production - -#### Build related #### -DOCKER_BUILDKIT=1 -COMPOSE_DOCKER_CLI_BUILD=1 -COMPOSE_FILE=docker-compose-iop.yaml:build/docker-compose-iop.yaml:docker-compose-iop-gateway.yaml:docker-compose-traefik-selfsigned.yaml:docker-compose-jhipster-registry.yaml:development-services/build/docker-compose-keycloak-setup.yaml -EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem - diff --git a/.env.gen b/.env.gen new file mode 100644 index 0000000000000000000000000000000000000000..e53dee7b95d666828fb1daede2eaba409b76c0f2 --- /dev/null +++ b/.env.gen @@ -0,0 +1,83 @@ +# Reference documentation https://docs.docker.com/compose/environment-variables/ +# Focus default variables as production, to allow direct download and run in production +# Required external variables that must be defined externally are those that have no value + +#### Environments managed +# this is the default environment if needed uncomment and adjust +# some conventions on environment prefixes +# - _ENV_LOCAL_ .env.local purpouse is to cache build and start the setup locally using cache images exposing dev ports (i.e 3306, 5432, 8086, ...) for debug and development purposes. It is the default behaviour (_ENV_LOCAL_:build-cache:.env.local) +# - _ENV_CACHE_ .env.cache purpouse is to generate images tagged for build cache from that use BUILDKIT_INLINE_CACHE 1 (_ENV_CACHE_:build-cache:.env.cache) +# - _ENV_RELEASE_ .env.release purpouse is to generate images (that do not use BUILDKIT_INLINE_CACHE 1) tagged for the clients/pilots usage (_ENV_RELEASE_:build-release:.env.release) +# - _ENV_DEPLOY_ .env purpose is to generate non building docker-compose that uses the release to deploy on generic client (_ENV_DEPLOY_:release:.env) +# - _ENV_TEST_ .env.test the purpouse is to test from the cache images the correct behaviour without exposing ports (_ENV_TEST_:build-cache:.env.test) +# types of building +# - build-cache: it focuses in the generation of images with BUILDKIT_INLINE_CACHE 1 for its usage in the cache-from for subsequent build, for each compose-file in compose-file build it finds build/cache the same name to add it to the build, it will use cache from. +# - build-release: it focuses in the generation of images for distribution it avoid using BUILDKIT_INLINE_CACHE 1 to reduce the size, it will use cache from. +# - cache: it runs using cache images +# - release: it runs using release images +# default enviroment +# _ENVIRONMENTS=_ENV_LOCAL_:build-cache:.env.local +# to add more enviroments use split with ";" +_ENVIRONMENTS=_ENV_LOCAL_:build-cache:.env.local;_ENV_LOCAL-SECURE_:build-cache:.env.secure;_ENV_RELEASE_:build-release:.env.release;_ENV_DEPLOY_BASE_:release:.env;_ENV_PIACERE_:release:.env.piacere + +#### Common image related #### +DOCKER_REGISTRY_CACHE_PREFIX=cache.euve.digital.tecnalia.dev:5000 +DOCKER_REGISTRY_CACHE_VERSION=latest + +#### Common Build related #### +# DOCKER_BUILDKIT and COMPOSE_DOCKER_CLI_BUILD do not have effect here, we leave them as documentation +# DOCKER_BUILDKIT=1 +# COMPOSE_DOCKER_CLI_BUILD=1 + +### Common Traefik related ### +TRAEFIK_NETWORK_NAME=traefik_network +TRAEFIK_HTTPS_ENTRYPOINT_NAME=websecure +# TRAEFIK_HTTP_ENTRYPOINT_NAME=web + +#### Common Production related #### +ADMIN_USER=admin +ADMIN_PASSWORD=projectPassword +# to calculate password hash `openssl passwd -apr1 $ADMIN_PASSWORD` +# ADMIN_PASSWORD_HASH='$apr1$chTuJ7f9$.Ul8E16QYHtydKw.ehzZC.' +# to calculate password bcrypt hash `sudo apt-get update; sudo apt-get install -y apache2-utils; htpasswd -bnBC 12 "" $ADMIN_PASSWORD | tr -d ':\n'` +# ADMIN_PASSWORD_BCRYPT_HASH='$2y$12$NxJ.FkLgDZWWjc15y9bhX./GOTp67krCxWPanJLyCjofKyIN.zS96' +# HTTPS_PORT must be 443 if you use step-ca +HTTPS_PORT=443 +# server host is configured during the sync based on _ENV_LOCAL_ and _ENV_DEPLOY, _ENV_LOCAL_ will be used for test and release unless _ENV_RELEASE_ or _ENV_TEST_ specified +SERVER_HOST=ci.piacere.digital.tecnalia.dev + +#### Platform Specific #### +# TZ=Madrid +IOP_SPRING_PROFILES_ACTIVE=prod,api-docs,no-liquibase +EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem + +#### Common docker-compose related #### +# https://docs.docker.com/compose/reference/envvars/#compose_file#compose_project_name +# these are docker-compose related environment variables +COMPOSE_PROJECT_NAME=piacere-iop-production +# _ENV_LOCAL_COMPOSE_FILE_BASE= # These are oriented for local vagrant usually it contains local traefik configuration, dev services, etc +# _ENV_RELEASE_COMPOSE_FILE_BASE= # These are oriented for tagging relevant images for upload to official release repositories +# _ENV_DEPLOY_COMPOSE_FILE_BASE= # These are oriented for final deployment it contains production traefik configuration, etc +# _ENV_TEST_COMPOSE_FILE_BASE= # These are oriented for testing +# COMPOSE_FILE_BASE= # (MANDATORY) These are those main services of the project, that will apply to all the scenarios + +COMPOSE_FILE_BASE=docker-compose.yaml +COMPOSE_FILE_BASE_NETWORK=docker-compose-traefik-network-external.yaml + +COMPOSE_FILE= +# COMPOSE_FILE Is generated automatically + +IOP_CONFIG_PATH= +IOP_BASE_PATH= + +IMAGE_IOP_OPTIMIZER=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iop-optimizer:y3 +IMAGE_IOP_OPTIMIZER_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iop-optimizer:y3 + +_ENV_LOCAL_SERVER_HOST=192.168.56.1.nip.io +_ENV_LOCAL-SECURE_COMPOSE_FILE_BASE_GATEWAY=docker-compose-gateway.yaml +_ENV_LOCAL-SECURE_KEYCLOAK_URL=https://auth.192.168.56.1.nip.io + +_ENV_PIACERE_COMPOSE_FILE_BASE_PIACERE_BUILD=piacere-build/docker-compose.yaml +_ENV_PIACERE_COMPOSE_FILE_BASE_PIACERE_RELEASE=release/docker-compose.yaml +_ENV_PIACERE_COMPOSE_FILE_BASE_ARTIFACTORY=docker-compose-artifactory.yaml +_ENV_PIACERE_COMPOSE_FILE_BASE_TRAEFIK_NETWORK=docker-compose-traefik-network-internal.yaml diff --git a/.env.int b/.env.int deleted file mode 100644 index 59252526af2af3c265396fd25e914f1e1d645097..0000000000000000000000000000000000000000 --- a/.env.int +++ /dev/null @@ -1,32 +0,0 @@ -# Reference documentation https://docs.docker.com/compose/environment-variables/ -# Focus default variables as production, to allow direct download and run in production -# Required external variables that must be defined externally are those that have no value - -DEVSVC_BASE_PATH=development-services/ -DEVSVC_SETUP_BASE_PATH= - -#### Production related #### - -DOCKER_REGISTRY_PREFIX=optima-piacere-docker-dev.artifact.tecnalia.com -PROJECT_NAME= -COMPOSE_PROJECT_VERSION=y1 - -TZ=Madrid -ADMIN_PASSWORD=piacerePassword -HTTPS_PORT=8443 -SERVER_HOST=192.168.56.1.nip.io -KEYCLOAK_URL=https://auth.192.168.56.1.nip.io:8443 -IOP_SPRING_PROFILES_ACTIVE=prod,api-docs,no-liquibase - -# https://docs.docker.com/compose/reference/envvars/#compose_file#compose_project_name -# these are docker-compose related environment variables -COMPOSE_PROJECT_NAME=piacere-production - -#### Build related #### -DOCKER_BUILDKIT=1 -COMPOSE_DOCKER_CLI_BUILD=1 -EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem -#### Development related #### -# CERTIFICATE_SIGNING_KEY_PASSPHRASE= - -COMPOSE_FILE=docker-compose-iop.yaml:docker-compose-iop-gateway.yaml:build/docker-compose-iop.yaml:docker-compose-jhipster-registry.yaml:docker-compose-jhipster-registry-tecnalia.yaml:docker-compose-jhipster-registry-oidc.yaml:docker-compose-dev-jhipster-registry.yaml:docker-compose-iop-traefik.yaml:development-services/docker-compose-traefik-tecnalia-selfsigned.yaml:docker-compose-expose.yaml:docker-compose-redirect-http.yaml:development-services/build/docker-compose-traefik-tecnalia-selfsigned.yaml:development-services/docker-compose.yaml:development-services/docker-compose-expose.yaml:development-services/docker-compose-redirect-http.yaml:development-services/build/docker-compose.yaml:development-services/docker-compose-keycloak.yaml:development-services/docker-compose-keycloak-setup.yaml:development-services/build/docker-compose-keycloak-setup.yaml:docker-compose-traefik-tecnalia-selfsigned-sans.yaml diff --git a/.env.local b/.env.local new file mode 100644 index 0000000000000000000000000000000000000000..8b9363e5bd682db4a7fb88c17cb0cdd51b02e0f2 --- /dev/null +++ b/.env.local @@ -0,0 +1,13 @@ +DOCKER_REGISTRY_CACHE_PREFIX=cache.euve.digital.tecnalia.dev:5000 +DOCKER_REGISTRY_CACHE_VERSION=latest +TRAEFIK_NETWORK_NAME=traefik_network +TRAEFIK_HTTPS_ENTRYPOINT_NAME=websecure +ADMIN_USER=admin +ADMIN_PASSWORD=projectPassword +HTTPS_PORT=443 +SERVER_HOST=192.168.56.1.nip.io +IOP_SPRING_PROFILES_ACTIVE=prod,api-docs,no-liquibase +EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem +COMPOSE_PROJECT_NAME=piacere-iop-production +IOP_BASE_PATH= +COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:build/docker-compose.yaml:build/inline-cache/docker-compose.yaml:build/image/docker-compose.yaml diff --git a/.env.piacere b/.env.piacere new file mode 100644 index 0000000000000000000000000000000000000000..9a18ac618735523fcfa61564ce523ff8a875033a --- /dev/null +++ b/.env.piacere @@ -0,0 +1,12 @@ +TRAEFIK_NETWORK_NAME=traefik_network +TRAEFIK_HTTPS_ENTRYPOINT_NAME=websecure +ADMIN_USER=admin +ADMIN_PASSWORD=projectPassword +HTTPS_PORT=443 +SERVER_HOST=ci.piacere.digital.tecnalia.dev +IOP_SPRING_PROFILES_ACTIVE=prod,api-docs,no-liquibase +COMPOSE_PROJECT_NAME=piacere-iop-production +IOP_BASE_PATH= +IMAGE_IOP_OPTIMIZER=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iop-optimizer:y3 +IMAGE_IOP_OPTIMIZER_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iop-optimizer:y3 +COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:piacere-build/docker-compose.yaml:release/docker-compose.yaml:docker-compose-artifactory.yaml:docker-compose-traefik-network-internal.yaml diff --git a/.env.release b/.env.release new file mode 100644 index 0000000000000000000000000000000000000000..be5f2ae480f034e0745f1666134d8bec9b1c94f5 --- /dev/null +++ b/.env.release @@ -0,0 +1,14 @@ +DOCKER_REGISTRY_CACHE_PREFIX=cache.euve.digital.tecnalia.dev:5000 +DOCKER_REGISTRY_CACHE_VERSION=latest +TRAEFIK_NETWORK_NAME=traefik_network +TRAEFIK_HTTPS_ENTRYPOINT_NAME=websecure +ADMIN_USER=admin +ADMIN_PASSWORD=projectPassword +HTTPS_PORT=443 +SERVER_HOST=ci.piacere.digital.tecnalia.dev +IOP_SPRING_PROFILES_ACTIVE=prod,api-docs,no-liquibase +EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem +COMPOSE_PROJECT_NAME=piacere-iop-production +IOP_BASE_PATH= +IMAGE_IOP_OPTIMIZER=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iop-optimizer:y3 +COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:build/docker-compose.yaml:release/docker-compose.yaml diff --git a/.env.secure b/.env.secure index 3287ef0e13a9818eada3debbac1f176961370581..3282e5c55fafc02fc417af808805f133ff98d038 100644 --- a/.env.secure +++ b/.env.secure @@ -1,33 +1,14 @@ -# Reference documentation https://docs.docker.com/compose/environment-variables/ -# Focus default variables as production, to allow direct download and run in production -# Required external variables that must be defined externally are those that have no value - -DEVSVC_BASE_PATH=development-services/ -DEVSVC_SETUP_BASE_PATH= - -#### Production related #### - -DOCKER_REGISTRY_PREFIX=optima-piacere-docker-dev.artifact.tecnalia.com -PROJECT_NAME= -COMPOSE_PROJECT_VERSION=y1 - -TZ=Madrid -ADMIN_PASSWORD=piacerePassword -HTTPS_PORT=8443 -SERVER_HOST=192.168.56.1.nip.io -KEYCLOAK_URL=https://auth.192.168.56.1.nip.io:8443 +DOCKER_REGISTRY_CACHE_PREFIX=cache.euve.digital.tecnalia.dev:5000 +DOCKER_REGISTRY_CACHE_VERSION=latest +TRAEFIK_NETWORK_NAME=traefik_network +TRAEFIK_HTTPS_ENTRYPOINT_NAME=websecure +ADMIN_USER=admin +ADMIN_PASSWORD=projectPassword +HTTPS_PORT=443 +SERVER_HOST=ci.piacere.digital.tecnalia.dev IOP_SPRING_PROFILES_ACTIVE=prod,api-docs,no-liquibase - -# https://docs.docker.com/compose/reference/envvars/#compose_file#compose_project_name -# these are docker-compose related environment variables -COMPOSE_PROJECT_NAME=piacere-production -COMPOSE_FILE=docker-compose-iop.yaml:build/docker-compose-iop.yaml:docker-compose-iop-gateway.yaml:docker-compose-jhipster-registry.yaml:docker-compose-jhipster-registry-tecnalia.yaml:docker-compose-jhipster-registry-oidc.yaml:development-services/docker-compose-traefik-tecnalia-selfsigned.yaml:docker-compose-expose.yaml:docker-compose-redirect-http.yaml:development-services/build/docker-compose-traefik-tecnalia-selfsigned.yaml:development-services/docker-compose-expose.yaml:development-services/docker-compose-redirect-http.yaml:development-services/docker-compose-keycloak.yaml:development-services/docker-compose-keycloak-setup.yaml:development-services/build/docker-compose-keycloak-setup.yaml - -#### Build related #### -DOCKER_BUILDKIT=1 -COMPOSE_DOCKER_CLI_BUILD=1 EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem - -#### Development related #### -# CERTIFICATE_SIGNING_KEY_PASSPHRASE= - +COMPOSE_PROJECT_NAME=piacere-iop-production +IOP_BASE_PATH= +KEYCLOAK_URL=https://auth.192.168.56.1.nip.io +COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-gateway.yaml:build/docker-compose.yaml:build/docker-compose-gateway.yaml:build/inline-cache/docker-compose.yaml:build/inline-cache/docker-compose-gateway.yaml:build/image/docker-compose.yaml:build/image/docker-compose-gateway.yaml diff --git a/.gitignore b/.gitignore index 1d98bcb4c91bbba35a4281470da68b9f6a2fe28e..0f3ab686d7800c98a99aa954b451609ba60ec68a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ **/.project **/.factorypath **/*.log -**/*.lck \ No newline at end of file +**/*.lck +.temp* \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 564a1b7c7994cc606ec06a0b6e7a2c16951bc8d3..fe7bdac91952569d8fc8e4379cb76b2b3e959700 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,90 +1,133 @@ -stages: - - build - - deploy - - stop - # - debug +include: + - project: piacere/private/t23-ci-setup + ref: main + file: + - gitlab-ci-scripts/utils.gitlab-ci.yml + + # Image tag variables generation job ------------- + # Stage: variable-generation --------------------- + - gitlab-ci-scripts/generate-variables.gitlab-ci.yml + + # Downstream t23-ci-setup pipeline trigger job --- + # Stage: integration-tests-publish-deploy -------- + - gitlab-ci-scripts/trigger-downstream.gitlab-ci.yml variables: - GIT_SUBMODULE_STRATEGY: normal + #------------------------ + # Component image tag data + # ------------------------ + COMPONENT_WP: wp5 + IOP_OPTIMIZER_IMAGE_NAME: iop-optimizer + + # ------------------------------------------ + # Space-separated component image abbreviation list + # used to generate image tags and related variables. + # It is also passed to the downstream integration tests, + # publication and deployment pipeline. + # ------------------------------------------ + IMAGE_NAMES: "$IOP_OPTIMIZER_IMAGE_NAME" -.common_variables: - variables: - TZ: Madrid - SERVER_HOST: iop.poc.piacere.esilab.org - HTTPS_PORT: 8443 - SMTP_USER_EMAIL: piacere@esilab.org - PROJECT_NAME: piacere-iop - GIT_SUBMODULES: init - COMPOSE_FILE: "docker-compose.yaml:development-services/docker-compose-traefik-tecnalia-selfsigned.yaml:development-services/docker-compose-redirect-http:development-services/docker-compose.yaml:development-services/docker-compose-expose.yaml" +# The quality stage does not apply here, +# since the base images come from Docker Hub. +# There are no unit tests either. -.main: - extends: - - .common_variables +stages: + - variable-generation + - quality + - build + - security + - unit-tests + - integration-tests-publish-deploy + +# Quality jobs ---------------------- + +check-sonar: + image: maven:3.8.1-jdk-11 + stage: quality variables: # these variables take precedence over .env # CERTIFICATE_SIGNING_KEY_PASSPHRASE and ADMIN_PASSWORD defined in variables at settings/ci_cd COMPOSE_PROJECT_NAME: piacere-iop - COMPOSE_PROJECT_VERSION: main + DOCKER_REGISTRY_CACHE_VERSION: main ADD_DEFAULT_CA: "true" + SONAR_FORCEAUTHENTICATION: "false" only: - main + services: + # Provide a Sonar service as a job service. + - name: sonarqube:8.9.2-community + alias: iop-optimizer-sonar + script: + - cd git/iop-optimizer + # Run the sonar quality check (override the sonar.host.url param). + - ./mvnw -Pprod,api-docs clean verify sonar:sonar -Dsonar.host.url=http://iop-optimizer-sonar:9000 -DskipTests -Dmodernizer.skip -Dskip.npm -Dskip.yarn -Dskip.bower -Dskip.grunt -Dskip.gulp -Dskip.jspm -Dskip.karma -Dskip.webpack + allow_failure: true tags: - docker - - docker-compose - - integration - - iop - - shell -.build: +# Build jobs ---------------------- + +.build-docker-compose: + # image: docker/compose:1.29.2 # this is too old + image: docker:23.0.1 + stage: build + services: + # - docker:20.10.21-dind # not sure if this is the latest + - docker:dind variables: + GIT_DEPTH: 1 GIT_SUBMODULE_STRATEGY: recursive + GIT_SUBMODULE_DEPTH: 1 + DOCKER_BUILDKIT: 1 + COMPOSE_DOCKER_CLI_BUILD: 1 + DOCKER_COMPOSE_PATH: "." + DOCKER_COMPOSE_ENV_FILE_CACHE: ".env.piacere" + DOCKER_COMPOSE_ENV_FILE: ".env.piacere" + before_script: + - !reference [.artifactory-login] script: - - export COMPOSE_FILE=$COMPOSE_FILE:build/docker-compose.yaml:development-services/build/docker-compose.yaml:development-services/build/docker-compose-traefik-tecnalia-selfsigned.yaml - - echo "build images" - - docker-compose build --parallel - -.deploy: - script: - - echo "Deploy to the environment" - - docker-compose up -d --remove-orphans + - apk add docker-compose + - cd $DOCKER_COMPOSE_PATH + - docker-compose --env-file $DOCKER_COMPOSE_ENV_FILE_CACHE --project-directory ./ pull || true + - docker-compose --env-file $DOCKER_COMPOSE_ENV_FILE_CACHE --project-directory ./ config + - docker-compose --env-file $DOCKER_COMPOSE_ENV_FILE --project-directory ./ build + - docker-compose --env-file $DOCKER_COMPOSE_ENV_FILE --project-directory ./ push + - docker-compose --env-file $DOCKER_COMPOSE_ENV_FILE --project-directory ./ config | grep image + tags: + - docker -.stop: +build-temp-docker-compose: + extends: + - .build-docker-compose variables: - GIT_STRATEGY: none - script: - - echo "Stops the environment" - - docker-compose down --remove-orphans + IMAGE_IOP_OPTIMIZER: "$TMP_IMAGE_IOP_OPTIMIZER" -build_main: - stage: build +build-release-docker-compose: extends: - - .main - - .build + - .build-docker-compose + when: manual -deploy_main: - stage: deploy - extends: - - .main - - .deploy - environment: - name: main - url: https://$SERVER_HOST:$HTTPS_PORT - on_stop: stop_main +# Security job in tests stage------------------------ +# security-trivy-iop-optimizer: +# stage: security +# variables: +# TMP_IMAGE: "$TMP_IMAGE_IOP" +# trigger: !reference [.trigger-security-trivy] +# needs: +# - job: build-temp-docker-compose +# - job: generate-variables +# artifacts: true -stop_main: - stage: stop - extends: - - .main - - .stop - environment: - name: main - action: stop - when: manual +# Tests jobs ------------------------ -# job-docker-compose-config: -# stage: debug -# extends: -# - .main -# when: manual -# script: -# - docker-compose config +run-iop-optimizer-tests: + image: maven:3.8.1-jdk-11 + stage: unit-tests + script: + - cd git/iop-optimizer + # Run modernizer (to potentially view the logs for violations) + # but allow it to fail so that tests may be performed. + # https://github.com/gaul/modernizer-maven-plugin/blob/master/README.md#configuration + - mvn verify -Pprod,api-docs -Dmodernizer.failOnViolations=false + tags: + - docker diff --git a/.gitmodules b/.gitmodules index 83c0d1bc218b82dc17e2bbc7f02c05c1d75a796a..390ea555f3b45653cedf73e384cc1d9a934a797c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "development-services"] - path = development-services - url = ../../../smartdatalab/libraries/docker-compose/development-services.git +[submodule "git/jhipster-registry"] + path = git/jhipster-registry + url = ../../../smartdatalab/libraries/docker-compose/jhipster-registry-deploy.git diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..a043ebb460993cc3910eccc085b4eb218e16abde --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2022 Tecnalia + + 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. diff --git a/build/docker-compose-gateway.yaml b/build/docker-compose-gateway.yaml new file mode 100644 index 0000000000000000000000000000000000000000..654f6d75856440dcfcb53f79dcd3cd8a894a7987 --- /dev/null +++ b/build/docker-compose-gateway.yaml @@ -0,0 +1,9 @@ +services: + iop-gateway: + build: + context: ${IOP_BASE_PATH}git/iop-gateway + dockerfile: Dockerfile + args: + EXTRA_CA_URL: ${EXTRA_CA_URL:?err} + cache_from: + - ${DOCKER_REGISTRY_CACHE_PREFIX}/piacere/iop-gateway:${DOCKER_REGISTRY_CACHE_VERSION:?err} diff --git a/build/docker-compose-iop.yaml b/build/docker-compose-iop.yaml deleted file mode 100644 index ce0fc2c04b2ee16bc9cfa207ac8ef31193b80a1f..0000000000000000000000000000000000000000 --- a/build/docker-compose-iop.yaml +++ /dev/null @@ -1,21 +0,0 @@ -# This configuration is intended for development purpose, it's **your** responsibility to harden it for production -version: '3.8' -services: - - iop-gateway: - build: - context: ${IOP_BUILD_RELATIVE_FOLDER}git/iop-gateway - dockerfile: Dockerfile - args: - BUILDKIT_INLINE_CACHE: 1 - EXTRA_CA_URL: ${EXTRA_CA_URL:?err} - - iop-optimizer: - build: - context: ${IOP_BUILD_RELATIVE_FOLDER}git/iop-optimizer - dockerfile: Dockerfile - args: - BUILDKIT_INLINE_CACHE: 1 - EXTRA_CA_URL: ${EXTRA_CA_URL:?err} - - \ No newline at end of file diff --git a/build/docker-compose.yaml b/build/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e85c360e9ed83e445fccc10e1ac9c6dddd2679f4 --- /dev/null +++ b/build/docker-compose.yaml @@ -0,0 +1,11 @@ +services: + iop-optimizer: + build: + context: ${IOP_BASE_PATH}git/iop-optimizer + dockerfile: Dockerfile + cache_from: + - ${DOCKER_REGISTRY_CACHE_PREFIX}/piacere/iop-optimizer:${DOCKER_REGISTRY_CACHE_VERSION:?err} + args: + EXTRA_CA_URL: ${EXTRA_CA_URL:?err} + + \ No newline at end of file diff --git a/build/image/docker-compose-gateway.yaml b/build/image/docker-compose-gateway.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0b2234c096183834c5d2fd7e9761aa980c3c9e3c --- /dev/null +++ b/build/image/docker-compose-gateway.yaml @@ -0,0 +1,3 @@ +services: + iop-gateway: + image: ${DOCKER_REGISTRY_CACHE_PREFIX}/piacere/iop-gateway:${DOCKER_REGISTRY_CACHE_VERSION:?err} diff --git a/build/image/docker-compose.yaml b/build/image/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a18407ad325a6bd64f9cfa94dc82f05d1f4ca97a --- /dev/null +++ b/build/image/docker-compose.yaml @@ -0,0 +1,3 @@ +services: + iop-optimizer: + image: ${DOCKER_REGISTRY_CACHE_PREFIX}/piacere/iop-optimizer:${DOCKER_REGISTRY_CACHE_VERSION:?err} diff --git a/build/inline-cache/docker-compose-gateway.yaml b/build/inline-cache/docker-compose-gateway.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0534e21dd2357e8e79a7317f1e8f44f650bc8296 --- /dev/null +++ b/build/inline-cache/docker-compose-gateway.yaml @@ -0,0 +1,5 @@ +services: + iop-gateway: + build: + args: + BUILDKIT_INLINE_CACHE: 1 # For multistage docker diff --git a/build/inline-cache/docker-compose.yaml b/build/inline-cache/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9df3062d67c6e1de2e3f307dc8ae5f4138c5c858 --- /dev/null +++ b/build/inline-cache/docker-compose.yaml @@ -0,0 +1,5 @@ +services: + iop-optimizer: + build: + args: + BUILDKIT_INLINE_CACHE: 1 # For multistage docker diff --git a/central-config/jhipster/application.yml b/central-config/jhipster/application.yml deleted file mode 100644 index 86db899b48aabbbfab33f88fd40fd28c3cbd9d06..0000000000000000000000000000000000000000 --- a/central-config/jhipster/application.yml +++ /dev/null @@ -1,41 +0,0 @@ -# Common configuration shared between all applications -global: - password: ${GLOBAL_PASSWORD:admin} - registry: - url: ${GLOBAL_REGISTRY_URL:http://admin:${global.password}@jhipster-registry:8761} - -configserver: - name: Docker JHipster Registry - status: Connected to the JHipster Registry running in Docker using confiserver at jhipster registry ${global.registry.url} - -jhipster: - registry: - password: ${global.password} - security: - authentication: - jwt: - # This token must be encoded using Base64 and be at least 256 bits long (you can type `openssl rand -base64 64` on your command line to generate a 512 bits one) - # As this is the PRODUCTION configuration, you MUST change the default key, and store it securely: - # - In the JHipster Registry (which includes a Spring Cloud Config server) - # - In a separate `application-prod.yml` file, in the same folder as your executable JAR file - # - In the `JHIPSTER_SECURITY_AUTHENTICATION_JWT_BASE64_SECRET` environment variable - base64-secret: MjFhOTY5YjFiYjZjZGM0YTlhZjM1OGYwZmU2MjE1ZTJiNTNmM2Q0OTdiMDhmNDQzNjRjZWQyZDM0YmI0YjkwMGI4ZDc0ZGE0MGM3Yzg0M2U2Y2Q0ZDE4MDcwNzc4ODQyMjczOWYyODNlY2RmOTQzNGQzOTc3NDc0MDdkNjlkN2I= - # Token is valid 24 hours - token-validity-in-seconds: 86400 - token-validity-in-seconds-for-remember-me: 2592000 - -spring: - security: - user: - password: ${global.password} - -eureka: - instance: - # not sure the reason for this - prefer-ip-address: true - client: - service-url: - defaultZone: ${global.registry.url}/eureka/ - -server: - forward-headers-strategy: framework \ No newline at end of file diff --git a/central-config/jhipster/registry.yml b/central-config/jhipster/registry.yml deleted file mode 100644 index 3ba07ce41f0184400806715090ef9f40b4749070..0000000000000000000000000000000000000000 --- a/central-config/jhipster/registry.yml +++ /dev/null @@ -1,9 +0,0 @@ -jhipster: - cors: - # allowed-origins: "${JHIPSTER_CORS_ALLOWEDORIGINS:https://jhipster-registry.192.168.56.1.nip.io:8443}" this is valid expression - allowed-origins: "${JHIPSTER_CORS_ALLOWEDORIGINS:*}" - allowed-methods: "*" - allowed-headers: "*" - exposed-headers: "Authorization,Link,X-Total-Count" - allow-credentials: "true" - max-age: 1800 diff --git a/central-config/iop/application.yml b/data/jhipster-registry/central-config/iop/application.yml similarity index 100% rename from central-config/iop/application.yml rename to data/jhipster-registry/central-config/iop/application.yml diff --git a/central-config/iop/iopGateway.yml b/data/jhipster-registry/central-config/iop/iopGateway.yml similarity index 100% rename from central-config/iop/iopGateway.yml rename to data/jhipster-registry/central-config/iop/iopGateway.yml diff --git a/central-config/iop/iopOptimizer.yml b/data/jhipster-registry/central-config/iop/iopOptimizer.yml similarity index 100% rename from central-config/iop/iopOptimizer.yml rename to data/jhipster-registry/central-config/iop/iopOptimizer.yml diff --git a/doc/.gitkeep b/doc/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/doc/1._intro.rst b/doc/1._intro.rst new file mode 100644 index 0000000000000000000000000000000000000000..5d296183aa80ef7a76af876237caebf3c48155df --- /dev/null +++ b/doc/1._intro.rst @@ -0,0 +1,20 @@ +.. _Introduction: + +************ +Introduction +************ + +The task **T5.3** coined as *Best configuration deployments based on optimization algorithms*, +is devoted to the implementation of an automatic optimization tool (**IOP**) in charge of selecting +the optimal IaC infrastructural and resource configuration based on a set of constraints. + +So, the **IOP** currently includes the following tools and services: + +- **IEC**: the Infrastructural Elements Catalogue component is a persistence +component that stores information required by different PIACERE components. As a persistence component +there are two critical aspects to be covered: how the information is added and how the information is retrieved. +- **Optimization module**: the optimizer will use optimization algorithms, seeking for an optimized deployment +configuration of the IaC on the appropriate infrastructural elements that best meet the predefined constraints +(e.g., types of infrastructural elements, NFRs, and so on). The IOP will success if it is able to propose the +most optimized deployment configuration of the infrastructural code taking into consideration the constraints +predefined. To this end, several deployment configurations will be shown and ranked. \ No newline at end of file diff --git a/doc/2._iec.rst b/doc/2._iec.rst new file mode 100644 index 0000000000000000000000000000000000000000..8208a1bbf17d736773feb28067bffa313f381b2f --- /dev/null +++ b/doc/2._iec.rst @@ -0,0 +1,15 @@ +.. _IEC: + +************ +IEC +************ + +... + + + + + + + + diff --git a/doc/3._optimizer.rst b/doc/3._optimizer.rst new file mode 100644 index 0000000000000000000000000000000000000000..6c01db6e96763b4c502c2af91132dedf71606ac6 --- /dev/null +++ b/doc/3._optimizer.rst @@ -0,0 +1,287 @@ +.. _Optimization Module: + +************ +Optimization Module +************ + +The optimization problem formulated in PIACERE and solved by the IOP consists on having +a service to be deployed, with the principal challenge of finding an optimized deployment +configuration of the IaC on the appropriate infrastructural elements that best meet the +predefined constraints. In this context,it is the IOP component which is the responsible +for finding the best possible infrastructure given the input data received. + +=========================== +How to run the IOP? +=========================== + +In order to run the IOP, an **String** should be introduced as input. This input should be +formated in DOML language with all the details about the optimization introduced (this is +explained later). Several examples of DOML can be found in the following links, which are +fully operative for the IOP. + +• Example with one objective (DOML 1.0): https://git.code.tecnalia.com/piacere/private/t23-integration-example/-/blob/main/example/basic.doml +• Example with one objective (DOML 1.0): https://git.code.tecnalia.com/piacere/private/t23-integration-example/-/blob/main/example/two_objectives.doml +• Example with one objective (DOML 1.0): https://git.code.tecnalia.com/piacere/private/t23-integration-example/-/blob/main/example/three_objectives.doml +• DOML 2.0 example: https://git.code.tecnalia.com/piacere/private/t31-doml-concepts/-/blob/main/tests/domlTests/nginx-aws-ec2.doml + +As mentioned, the DOML file should be introduced as **String**, using the same format as the +files above depicted. + +=========================== +How the optimization information is introduced in the input DOML +=========================== + +This input data is provided in DOML format and will include the optimization objectives +(such as the cost, performance, or availability), and optimization requirements. Then, +the IOP performs the matchmaking for the infrastructure via the execution of optimization +intelligent techniques by using the information taken as input against the available +infrastructure and historical data, available from the IEC. + +Having said that, in order to correctly run the optimization module, the following structure +should be added to the input DOML + +------------------------------------------------------------------------------------------------------------------------ +optimization opt { + objectives { + + } + nonfunctional_requirements { + + } +} +------------------------------------------------------------------------------------------------------------------------ + +At this moment, three different objectives can be contemplated in the IOP: minimize the **cost**, +maximize the **availability** and maximize the **performance**. Any combination of these objectives +can be introduced. Here is an example of the full three objectives and how they should be introduced: + +------------------------------------------------------------------------------------------------------------------------ + objectives { + "cost" => min + "availability" => max + "performance" => max + } +------------------------------------------------------------------------------------------------------------------------ + +Regarding the non funcional requirements, five different kind of requirements are contemplated in +the current version of the IOP: assign a maximum cost for the overall configuration, assign a minimum +availability for the overall configuration, assign a minimum performance for the overall configuration +restrict the region of the selected elements and restrict the providers of the elements. Here is an +example of the five requirements, and how they should be introduced: + +------------------------------------------------------------------------------------------------------------------------ + nonfunctional_requirements { + req1 "Cost <= 200" max 200.0 => "cost"; + req2 "Availability >= 98.0%" min 98.0 => "availability"; + req3 "Performance >= 10.0%" min 98.0 => "performance"; + req4 "Region" values "00EU" => "region"; + req5 "Provider" values "AMAZ" => "provider"; + } +------------------------------------------------------------------------------------------------------------------------ + +Thus, this could be a possible input for the IOP, represented in the input DOML. + +------------------------------------------------------------------------------------------------------------------------ +optimization opt { + objectives { + "cost" => min + "availability" => max + } + nonfunctional_requirements { + req1 "Cost <= 400" max 400.0 => "cost"; + req2 "Performance >= 60%" min 60.0 => "performance"; + req3 "Region" values "00EU" => "region"; + } +} +------------------------------------------------------------------------------------------------------------------------ + +A special attention should be made here to the multi-element optimization. In order to contemplate the multi-element +optimization, the user can introduce the following structure as a new requirement: + +------------------------------------------------------------------------------------------------------------------------ + +nonfunctional_requirements { + req1 "elements" => ""; +} + +------------------------------------------------------------------------------------------------------------------------ + +Using this structure, the use is able to introduce the combination of elements he/she is searching for. For example, if +the user needs to deploy a service with 3 different virtual machines and 1 database, the element part should be: + +------------------------------------------------------------------------------------------------------------------------ + +nonfunctional_requirements { + req1 "elements" => "VM, VM, VM, Database"; +} + +------------------------------------------------------------------------------------------------------------------------ + +That is, the elements requirement should be introduced as a list of Strings, being VM the acronym of Virtual Machine. In +order to facilitate the usage of this multi-optimization feature, several aspects should be taken into account: + + +• The IOP is flexible to the order of the elements part. That is, if the user needs to deploy 2 virtual machines and 2 +storages, he/she can define the elements part without adapting to any established order. In other words, the following +three examples represent the same situation above mentioned: + +------------------------------------------------------------------------------------------------------------------------ + +req1 "elements" => "VM, VM, storage, storage"; + +req1 "elements" => " storage, storage, VM, VM"; + +req1 "elements" => "VM, storage, VM, storage"; + +------------------------------------------------------------------------------------------------------------------------ + +• The number of units per element can be equal to 0. In these cases, the elements parts should not contain the elements +that are not desired. For example, if the user needs the best configuration for three different virtual machines, not +needing any storage nor database, so the elements part should be defined as follows: + +------------------------------------------------------------------------------------------------------------------------ + +req1 "elements" => "VM, VM, VM"; + +------------------------------------------------------------------------------------------------------------------------ + +• The elements part of the nonfunctional_requirements is optional. In case the user does not introduce this information, +the IOP consider the basic problem. That is, the finding of the best configuration combining one single unit per element +of the IEC. + +=========================== +How the IOP returns the results +=========================== + +Once the IOP conduct its optimization, it returns a complete DOML. This DOML is the one introduced +as input, with the optimization results introduced. First, the IOP complements the "optimization opt" +part of the DOML adding the found solutions. This is an example: + +------------------------------------------------------------------------------------------------------------------------ +optimization opt { + objectives { + "cost" => min + "performance" => max + "availability" => max + } + nonfunctional_requirements { + req1 "Cost <= 400" max 400.0 => "cost"; + req2 "Performance >= 60%" min 60.0 => "performance"; + req3 "Region" values "00EU" => "region"; + } + solution sol2 { + objectives { + cost 192.0 euro + performance 65.83333333333333 metric + availability 105.0 % + } + decisions ["[Storage1_Spain, VM_1_CS]"] + } + solution sol3 { + objectives { + cost 201.0 euro + performance 65.93333333333334 metric + availability 103.0 % + } + decisions ["[Storage4_Europe, VM_1_CS]"] + } +} +------------------------------------------------------------------------------------------------------------------------ +In this example, the IOP returns two different solutions, composed each one of a Virtual Machine and a +Storage element. For each solutions, the value of each objective and the elements chosen are returned. + +Furthermore, the IOP introduces the features of each found solution in the *concretizations* part of +the DOML. If *concretizations* part is not present in the input DOML, the IOP creates it. This is an +example of returning concretizations. + +------------------------------------------------------------------------------------------------------------------------ +concrete_infrastructure con_infra { + provider openstack { + vm concrete_vm { + properties { + vm_name = "nginx-host"; + vm_key_name = "user1"; + vm_flavor = "t2.nano"; + vm_Availability = 98; + vm_Response_time_Virtual_Machine_Performance = 3; + vm_Memory = 0.5; + vm_Zone = "IEEU"; + vm_Frequency_per_Core = 1500; + vm_Virtual_CPU_Cores = 1; + vm_provider_OU = "AMAZ"; + vm_public_IP_type = "IPV4"; + vm_Cost_Currency = 4.53; + vm_Instance_Storage = 40; + vm_Optimized_for = "GEPU"; + vm_Region = "00EU"; + } + maps vm1 + } + + vm_image concrete_vm_image { + properties { + name = "ubuntu-20.04.3"; + } + maps v_img + } + + net concrete_net { + properties { + name = "ostack2"; + } + maps net1 + } + } + } +------------------------------------------------------------------------------------------------------------------------ + +Finally, the last aspect to highlight in this documentation is related to how the IOP ranks the solutions provided as +output. As mentioned, if the problem to solve has two or three different objectives to optimize, the problem converts into +a multi-objective one. This situation implies that more than one optimal solution exists. Indeed, the number of optimal +solutions are all the ones that meet the users requirements and that are placer in the Pareto front of the problem. + +For this reason, the IOP provides the different deployment configurations found using one of the optimization objectives +as reference. In this sense, and in order to do it flexible enough, the IOP adapts to the needs of the user, who can +define which is the objective considered as reference. For doing that, the input DOML is used. More concretely, the +objectives part of the optimization opt section of the DOML is used, deeming the first value as reference objective. + +Thus, if the user inserts the following objectives as input: + +------------------------------------------------------------------------------------------------------------------------ + +objectives { + "cost" => min + "availability" => max + "performance" => max +} + +------------------------------------------------------------------------------------------------------------------------ +All the deployments returned by the IOP will be ranked using the cost as reference, choosing the solution with the less +cost the first one to appear. On the contrary, if the user introduces the following objectives: + +------------------------------------------------------------------------------------------------------------------------ + +objectives { + "performance" => max + "availability" => max +} + +------------------------------------------------------------------------------------------------------------------------ + +The performance will be the reference to rank the returned solutions, choosing these solutions with the best performance +as the best ones. + +=========================== +How to install the IOP +=========================== + +The whole IOP is built in a compressed folder, which can be imported by any JAVA development framework such as NetBeans of +Eclipse. Furthermore, the project can also be imported as a Maven project, being this option even more comfortable than just +importing the whole project folder. Related also with this last aspect, jMetal framework is imported to the project and used +by the IOP using Maven functionality. + +The entry point of the IOP if the user wants to run it via JAVA code is the class named as OptimizerServiceIT.java, which is +part of the package com.piacere.iop.optimizer.service, within the test branch of the code. The method that runs the AOT is the +one coined as optimizedService.run(call). This is the method that it is called by the PIACERE components to make the IOP run +and to find the most optimized deployment configurations. + diff --git a/doc/4._contact.rst b/doc/4._contact.rst new file mode 100644 index 0000000000000000000000000000000000000000..4e8e4f8b1170438c26ddc51dcdf00cc38ea659dc --- /dev/null +++ b/doc/4._contact.rst @@ -0,0 +1,12 @@ +.. _Get in touch: + +************ +Get in touch +************ + +The IOP has been developed by the TECNALIA team. + +• Eneko Osaba: eneko.osaba@tecnalia.com +• Gorka Benguria: gorka.benguria@tecnalia.com +• Iñaki Etxaniz: inaki.etxaniz@tecnalia.com +• Juncal Alonso: juncal.alonso@tecnalia.com \ No newline at end of file diff --git a/doc/KR-9.feature b/doc/KR-9.feature new file mode 100644 index 0000000000000000000000000000000000000000..1d17bad5a3da4a78c0af89b2e802bcbcd2ac998a --- /dev/null +++ b/doc/KR-9.feature @@ -0,0 +1,154 @@ +Feature: PIACERE Design time + + As a PIACERE user I want to find an optimized deployment configuration of the IaC. + +Scenario: IOP: Minimizing the cost, maximizing the availability and the performance. Two VM and two DB to deploy, with two requirements (KR9) [Scenario 1] +Given A verified DOML document + +# In this first scenario, I want to optimize three different objectives: minimize the cost, +# maximize the availability and maximize the availability. The elements that I want to deploy are +# two databases and two virtual machines. I want to rank the solutions using the cost as reference. +# Additionally, I have some two requirements. I want that the overall deployment cost does not overpass +# 500 dollars, and I want the overall availability to be more than 96. +# For this reason, in the last part of my verified DOML, I add the following content: + +#optimization opt { +# objectives { +# "cost" => min +# "performance" => max +# "availability" => max +# } +# nonfunctional_requirements { +# req1 "Cost <= 500" max 500.0 => "cost"; +# req2 "Availability >= 96.0%" min 96.0 => "availability"; +# req3 "elements" => "DB, DB, VM, VM"; +# } +#} + +# More information about how these objectives and requirements should be introduced is available in the +# corresponding documentation of the IOP component, and also in D5.8. + +And the user has already introduced the optimization objectives and requirements +When user navigates to the DOML document, +And right-click on the file +And selects "Optimise" +Then The IOP is invoked +And runs the optimisation algorithm +And returns the optimised IaC examples + +# The IOP returns the same input DOML, but with the optimization results added. In the optimization opt +# section, the solutions are added. +# +#optimization opt { +# objectives { +# "cost" => min +# "performance" => max +# "availability" => max +# } +# nonfunctional_requirements { +# req1 "Cost <= 500.0" max 500.0 => "cost"; +# req2 "Availability >= 96.0%" min 96.0 => "availability"; +# req3 "elements" => "DB, DB, VM, VM"; +# } +# solution sol2 { +# objectives { +# cost 198.0 euro +# performance 40.0 metric +# availability 98.35 % +# } +# decisions ["[db.dynamo.4, db.m3.medium, C4_Europe, m1.small]"] +# } +# solution sol3 { +# objectives { +# cost 228.0 euro +# performance 38.0 metric +# availability 98.5 % +# } +# decisions ["[db.m3.medium, db.dynamo.3, C4_Europe, C2_UnitedKingdom]"] +# } +#} +# +# Furthermore, in the concretization section, the information about the elements of each solution is shown. + +And the user evaluates and verifies the output results + +# More information about how the solutions provided by the IOP are returned is available in the corresponding +# documentation of the IOP component and in the deliverable D5.8. Solutions provided by the IOP should be compliant +# with the information depicted there. +# REQUIREMENTS: This last step, the analysis of the results, should be also conducted to verify that the requirements RQ03, RQ04 +# and RQ98 have been correctly fulfilled. These are the requirements that are involved in the verification of the use cases. + +Scenario: IOP: Minimizing the cost, maximizing the availability. Three VM to deploy with three requirements (KR9) [Scenario 2] +Given A verified DOML document + +# In this second scenario, I want to optimize two different objectives: minimize the cost, and maximize the availability. +# The elements that I want to deploy are three virtual machines. I want to rank the solutions using the cost as reference. +# Additionally, I have some requirements. I want that the overall deployment cost does not overpass 400 dollars, and +# I want the overall performance to be more than 10. Furthermore, I want all the element to be deployed in Europe +# For this reason, in the last part of my verified DOML, I add the following content: + +#optimization opt { +# objectives { +# "cost" => min +# "availability" => max +# } +# nonfunctional_requirements { +# req1 "Cost <= 400" max 400.0 => "cost"; +# req2 "Region" values "00EU" => "region"; +# req3 "Performance >= 10.0%" min 10.0 => "performance"; +# req4 "elements" => "VM, VM, VM"; +# } +#} + +# More information about how these objectives and requirements should be introduced is available in the +# corresponding documentation of the IOP component, and also in D5.8. + +And the user has already introduced the optimization objectives and requirements +When user navigates to the DOML document, +And right-click on the file +And selects "Optimise" +Then The IOP is invoked +And runs the optimisation algorithm +And returns the optimised IaC examples + +# The IOP returns the same input DOML, but with the optimization results added. In the optimization opt +# section, the solutions are added. +# +#optimization opt { +# objectives { +# "cost" => min +# "availability" => max +# } +# nonfunctional_requirements { +# req1 "Cost <= 400.0" max 400.0 => "cost"; +# req2 "Region" values "00EU" => "region"; +# req3 "Performance >= 10.0%" min 10.0 => "performance"; +# req4 "elements" => "VM, VM, VM"; +# } +# solution sol2 { +# objectives { +# cost 39.53 euro +# availability 98.83333333333333 % +# } +# decisions ["[C1_Spain, m1.small, t2.nano]"] +# } +# solution sol3 { +# objectives { +# cost 59.53 euro +# availability 99.03333333333335 % +# } +# decisions ["[C1_Spain, C2_UnitedKingdom, t2.nano]"] +# } +# +# Furthermore, in the concretization section, the information about the elements of each solution is shown. + +And the user evaluates and verifies the output results + +# More information about how the solutions provided by the IOP are returned is available in the corresponding +# documentation of the IOP component and in the deliverable D5.8. Solutions provided by the IOP should be compliant +# with the information depicted there. +# REQUIREMENTS: This last step, the analysis of the results, should be also conducted to verify that the requirements RQ03, RQ04 +# and RQ98 have been correctly fulfilled. These are the requirements that are involved in the verification of the use cases. + + + diff --git a/docker-compose-artifactory.yaml b/docker-compose-artifactory.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fc22c4a9c24a5cb692d7b588f90bd4bcaf553d91 --- /dev/null +++ b/docker-compose-artifactory.yaml @@ -0,0 +1,5 @@ +services: + iop-optimizer: + build: + labels: + com.jfrog.artifactory.retention.maxCount: 6 diff --git a/docker-compose-dev-jhipster-registry.yaml b/docker-compose-dev-jhipster-registry.yaml deleted file mode 100644 index 80b771b3684c2a5431a60b0832ab79e07c3aab7a..0000000000000000000000000000000000000000 --- a/docker-compose-dev-jhipster-registry.yaml +++ /dev/null @@ -1,14 +0,0 @@ -version: '3.8' - -services: - traefik: - networks: - default: - aliases: - - jhipster-registry.${SERVER_HOST} - - jhipster-registry: - labels: - - "traefik.enable=true" - - "traefik.http.routers.jhipster-registry.entrypoints=websecure" - - "traefik.http.routers.jhipster-registry.rule=Host(`jhipster-registry.${SERVER_HOST:?err}`)" diff --git a/docker-compose-expose.yaml b/docker-compose-expose.yaml deleted file mode 100644 index 5ad955c50445188734ce111dda2269d99f197dd6..0000000000000000000000000000000000000000 --- a/docker-compose-expose.yaml +++ /dev/null @@ -1,7 +0,0 @@ -version: "3.8" - -services: - ## Common structure - traefik: - ports: - - ${HTTPS_PORT:?err}:${HTTPS_PORT:?err} diff --git a/docker-compose-iop-gateway.yaml b/docker-compose-gateway.yaml similarity index 62% rename from docker-compose-iop-gateway.yaml rename to docker-compose-gateway.yaml index e116d1e91e7b4f3ff98d4d62c2e15a19011866af..23370b5543d4d46822728f37e01576b339182d91 100644 --- a/docker-compose-iop-gateway.yaml +++ b/docker-compose-gateway.yaml @@ -1,27 +1,19 @@ -# This configuration is intended for development purpose, it's **your** responsibility to harden it for production -version: '3.8' services: - traefik: - networks: - default: - aliases: - - iop.${SERVER_HOST} - iop-gateway: # image: iop-gateway - image: ${DOCKER_REGISTRY_PREFIX}${PROJECT_NAME}/wp5/iop-gateway:${COMPOSE_PROJECT_VERSION:?err} restart: always - depends_on: - - jhipster-registry environment: GLOBAL_PASSWORD: ${ADMIN_PASSWORD} # GLOBAL_REGISTRY_URL: http://admin:${ADMIN_PASSWORD}@jhipster-registry:8761 JHIPSTER_CORS_ALLOWEDORIGINS: "https://iop.${SERVER_HOST:?err}:${HTTPS_PORT}" # Unlike the Jhipster registry, for some reason it cannot work without oidc info - SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_OIDC_ISSUER_URI: ${KEYCLOAK_URL}/auth/realms/jhipster + SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_OIDC_ISSUER_URI: ${KEYCLOAK_URL}/auth/realms/piacere SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_ID: web-app SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_SECRET: web-app + networks: + traefik_network: labels: - "traefik.enable=true" + - "traefik.docker.network=${TRAEFIK_NETWORK_NAME:?err}" - "traefik.http.routers.iop-gateway.rule=Host(`secure.iop.${SERVER_HOST:?err}`)" - - "traefik.http.routers.iop-gateway.entrypoints=websecure" + - "traefik.http.routers.iop-gateway.entrypoints=${TRAEFIK_HTTPS_ENTRYPOINT_NAME:?err}" diff --git a/docker-compose-iop-traefik.yaml b/docker-compose-iop-traefik.yaml deleted file mode 100644 index 91245495e5eed19f166a2b4e0f7a4a5b5690f1b5..0000000000000000000000000000000000000000 --- a/docker-compose-iop-traefik.yaml +++ /dev/null @@ -1,14 +0,0 @@ -version: '3.8' - -services: - traefik: - networks: - default: - aliases: - - jhipster-registry.${SERVER_HOST} - - iop-optimizer: - labels: - - "traefik.enable=true" - - "traefik.http.routers.iop-optimizer.entrypoints=websecure" - - "traefik.http.routers.iop-optimizer.rule=Host(`iop.${SERVER_HOST:?err}`)" diff --git a/docker-compose-jhipster-network-external.yaml b/docker-compose-jhipster-network-external.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ee06a4c25a5e23175ab6790899279029bea5d93c --- /dev/null +++ b/docker-compose-jhipster-network-external.yaml @@ -0,0 +1,13 @@ +services: + iop-optimizer: + networks: + jhipster_network: + iop-gateway: + networks: + jhipster_network: + +networks: + jhipster_network: + name: jhipster_network + external: true + diff --git a/docker-compose-jhipster-registry-oidc.yaml b/docker-compose-jhipster-registry-oidc.yaml deleted file mode 100644 index 7016c2a929b58839374961abab2ec1f4a2e789c2..0000000000000000000000000000000000000000 --- a/docker-compose-jhipster-registry-oidc.yaml +++ /dev/null @@ -1,10 +0,0 @@ -version: '3.8' - -services: - - jhipster-registry: - environment: - SPRING_PROFILES_ACTIVE: prod,oauth2 - SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_OIDC_ISSUER_URI: ${KEYCLOAK_URL}/auth/realms/jhipster - SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_ID: jhipster-registry - SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_SECRET: jhipster-registry diff --git a/docker-compose-jhipster-registry-tecnalia.yaml b/docker-compose-jhipster-registry-tecnalia.yaml deleted file mode 100644 index e3342e8852baaeede72b36fbf23299288e01e962..0000000000000000000000000000000000000000 --- a/docker-compose-jhipster-registry-tecnalia.yaml +++ /dev/null @@ -1,9 +0,0 @@ -version: '3.8' - -services: - - jhipster-registry: - command: - - /bin/sh - - -c - - ( [ -f /ca.pem ] || ( curl -s ${EXTRA_CA_URL:?err} --output /ca.pem && openssl x509 -in /ca.pem -text && keytool -import -noprompt -trustcacerts -alias ca -file /ca.pem -cacerts -storepass changeit ) ) && echo \"The JHipster Registry will start in $${JHIPSTER_SLEEP}s...\" && sleep $${JHIPSTER_SLEEP} && java $${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /jhipster-registry.jar diff --git a/docker-compose-jhipster-registry-volumes.yaml b/docker-compose-jhipster-registry-volumes.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f8c9546ceb376b1b994158144f57f5ba55c05c42 --- /dev/null +++ b/docker-compose-jhipster-registry-volumes.yaml @@ -0,0 +1,5 @@ +services: + jhipster-registry: + volumes: + - ./${JHIPSTER_REGISTRY_CONFIG_PATH}data/jhipster-registry/central-config/jhipster-registry:/central-config/jhipster-registry + - ./${IOP_CONFIG_PATH}data/jhipster-registry/central-config/iop:/central-config/iop diff --git a/docker-compose-jhipster-registry.yaml b/docker-compose-jhipster-registry.yaml deleted file mode 100644 index 22000b1cce2dccc17f328f8539fe2eae2bf4661c..0000000000000000000000000000000000000000 --- a/docker-compose-jhipster-registry.yaml +++ /dev/null @@ -1,26 +0,0 @@ -version: '3.8' - -services: - - traefik: - networks: - default: - aliases: - - jhipster-registry.${SERVER_HOST} - - jhipster-registry: - image: jhipster/jhipster-registry:v6.8.0 - restart: always - environment: - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_TYPE: native - # usually LOCATION use to point to file:./central-config, but, looking forward to the possibility to use a unique jhipster-registry for all the project we use the label feature that allow us to contain multiple configurations organized in folders iec, sh, iop - SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_0_SEARCH_LOCATIONS: file:./central-config/{label} - # if we migrate to a single jhipster-registry for all project we will need create a new folder global to hold the jhipster-registry configuration and assing global as LABEL - SPRING_CLOUD_CONFIG_LABEL: jhipster - SPRING_CLOUD_CONFIG_NAME: registry - GLOBAL_PASSWORD: ${ADMIN_PASSWORD} - JHIPSTER_CORS_ALLOWEDORIGINS: "https://jhipster-registry.${SERVER_HOST:?err}:${HTTPS_PORT}" - volumes: - - ./central-config/jhipster:/central-config/jhipster - - ./central-config/iop:/central-config/iop - diff --git a/docker-compose-redirect-http.yaml b/docker-compose-redirect-http.yaml deleted file mode 100644 index e86a0b4ba0c053478ccb4c86b8a7f552bff7ec95..0000000000000000000000000000000000000000 --- a/docker-compose-redirect-http.yaml +++ /dev/null @@ -1,14 +0,0 @@ -version: '3.8' - -services: - traefik: - labels: - # global redirect to https - - "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)" - - "traefik.http.routers.http-catchall.entrypoints=web" - - "traefik.http.routers.http-catchall.middlewares=redirect-to-https" - - "traefik.http.routers.http-catchall.service=api@internal" - - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" - - "traefik.http.middlewares.redirect-to-https.redirectscheme.port=${HTTPS_PORT:?err}" - ports: - - 80:80 diff --git a/docker-compose-traefik-aliases.yaml b/docker-compose-traefik-aliases.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4e3ae2f025e2c11f661d3cb77e3fdc3d11e0e55d --- /dev/null +++ b/docker-compose-traefik-aliases.yaml @@ -0,0 +1,7 @@ +services: + traefik: + networks: + traefik_network: + aliases: + - iop.${SERVER_HOST} + - secure.iop.${SERVER_HOST} diff --git a/docker-compose-traefik-network-external.yaml b/docker-compose-traefik-network-external.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6149618e9408dec1168a12175ab70e38c67cc86c --- /dev/null +++ b/docker-compose-traefik-network-external.yaml @@ -0,0 +1,4 @@ +networks: + traefik_network: + name: traefik_network + external: true diff --git a/docker-compose-traefik-network-internal.yaml b/docker-compose-traefik-network-internal.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0d7a2cf849a8488fdbe66d2cd423e4777a3e2bce --- /dev/null +++ b/docker-compose-traefik-network-internal.yaml @@ -0,0 +1,3 @@ +networks: + traefik_network: + name: ${TRAEFIK_NETWORK_NAME:?err} diff --git a/docker-compose-traefik-selfsigned.yaml b/docker-compose-traefik-selfsigned.yaml deleted file mode 100644 index 42c8f328ffe42c2aa0a93bb3d9a91f7d4ae7b6c7..0000000000000000000000000000000000000000 --- a/docker-compose-traefik-selfsigned.yaml +++ /dev/null @@ -1,30 +0,0 @@ -version: "3.8" - -services: - ## Common structure - traefik: - image: traefik:v2.5.2 - restart: always - hostname: ${SERVER_HOST} - command: - --api=true - --api.insecure=true - --serverstransport.insecureskipverify=true - --ping=true - --providers.docker=true - --providers.docker.constraints="Label(`com.docker.compose.project`, `${COMPOSE_PROJECT_NAME}`)" - --providers.docker.exposedbydefault=false - --entrypoints.web.address=:80 - --entrypoints.websecure.address=:${HTTPS_PORT:?err} - --entrypoints.websecure.http.tls=true - # --log.level=DEBUG - volumes: - - /var/run/docker.sock:/var/run/docker.sock - networks: - default: - aliases: - - ${SERVER_HOST:?err} - -networks: - default: - \ No newline at end of file diff --git a/docker-compose-traefik-tecnalia-selfsigned-sans.yaml b/docker-compose-traefik-tecnalia-selfsigned-sans.yaml index 7e47fb6cc0130d8728f7457ec4cd403895f531bf..24b2e27a8272e3d8ec1f873be396509777f58a90 100644 --- a/docker-compose-traefik-tecnalia-selfsigned-sans.yaml +++ b/docker-compose-traefik-tecnalia-selfsigned-sans.yaml @@ -1,5 +1,3 @@ -version: "3.8" - services: ## Common structure traefik: diff --git a/docker-compose-iop.yaml b/docker-compose.yaml similarity index 52% rename from docker-compose-iop.yaml rename to docker-compose.yaml index 3e2ac546401fa52ea01e470a09e8e745af3796bd..210db910f947401bc8512893fa888b21e6baf600 100644 --- a/docker-compose-iop.yaml +++ b/docker-compose.yaml @@ -1,24 +1,19 @@ -# This configuration is intended for development purpose, it's **your** responsibility to harden it for production -version: '3.8' services: - traefik: - networks: - default: - aliases: - - optimizer.iop.${SERVER_HOST} - iop-optimizer: - image: ${DOCKER_REGISTRY_PREFIX}${PROJECT_NAME}/wp5/iop-optimizer:${COMPOSE_PROJECT_VERSION:?err} restart: always environment: GLOBAL_PASSWORD: ${ADMIN_PASSWORD} # GLOBAL_REGISTRY_URL: http://admin:${ADMIN_PASSWORD}@jhipster-registry:8761 JHIPSTER_CORS_ALLOWEDORIGINS: "https://iop.${SERVER_HOST:?err}:${HTTPS_PORT}" # Unlike the Jhipster registry, for some reason it cannot work without oidc info - SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_OIDC_ISSUER_URI: ${KEYCLOAK_URL}/auth/realms/jhipster - SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_ID: internal - SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_SECRET: internal SPRING_PROFILES_ACTIVE: ${IOP_SPRING_PROFILES_ACTIVE:?err} BACKEND_CATALOG_URL: https://iec.${SERVER_HOST:?err}:${HTTPS_PORT}/services/iecbackend/api/root-services/catalogue # MANAGEMENT_METRICS_EXPORT_PROMETHEUS_ENABLED: "true" - \ No newline at end of file + networks: + traefik_network: + labels: + - "traefik.enable=true" + - "traefik.docker.network=${TRAEFIK_NETWORK_NAME:?err}" + - "traefik.http.routers.iop-optimizer.entrypoints=${TRAEFIK_HTTPS_ENTRYPOINT_NAME:?err}" + - "traefik.http.routers.iop-optimizer.rule=Host(`iop.${SERVER_HOST:?err}`)" + diff --git a/git/iop-optimizer/pom.xml b/git/iop-optimizer/pom.xml index a47be7efae7ae5228b52ab719eea3364063957fa..adf7ee81582db67c7c538a346ea5d9b4046f1d92 100644 --- a/git/iop-optimizer/pom.xml +++ b/git/iop-optimizer/pom.xml @@ -288,11 +288,6 @@ <artifactId>jmetal-algorithm</artifactId> <version>5.1</version> </dependency> - <dependency> - <groupId>org.moeaframework</groupId> - <artifactId>moeaframework</artifactId> - <version>2.13</version> - </dependency> <!-- https://mvnrepository.com/artifact/org.eclipse.core/runtime --> <dependency> <groupId>org.eclipse.core</groupId> diff --git a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/GWASFGADiscreteOptRunner.java b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/GWASFGADiscreteOptRunner.java index c6c296ceb202d210892d4aa13e2af2ba2c02963e..0b12245c66072ced8acc1e8bd83bd83463f91ca4 100644 --- a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/GWASFGADiscreteOptRunner.java +++ b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/GWASFGADiscreteOptRunner.java @@ -12,10 +12,12 @@ **********************************************************************/ package com.piacere.iop.optimizer.algorithm.jmetal.discrete; +import java.util.ArrayList; import java.util.List; import org.uma.jmetal.algorithm.Algorithm; import org.uma.jmetal.algorithm.multiobjective.gwasfga.GWASFGA; +import org.uma.jmetal.algorithm.multiobjective.nsgaii.NSGAIIBuilder; import org.uma.jmetal.operator.CrossoverOperator; import org.uma.jmetal.operator.MutationOperator; import org.uma.jmetal.operator.SelectionOperator; @@ -27,10 +29,14 @@ import org.uma.jmetal.util.AlgorithmRunner; import org.uma.jmetal.util.JMetalLogger; import org.uma.jmetal.util.comparator.RankingAndCrowdingDistanceComparator; import org.uma.jmetal.util.evaluator.impl.SequentialSolutionListEvaluator; +import org.uma.jmetal.util.fileoutput.impl.DefaultFileOutputContext; + import com.piacere.iop.optimizer.problems.JMETAL_ProblemDiscrete; import com.piacere.iop.optimizer.problems.JMETAL_ProblemJMDiscrete; +import com.piacere.iop.optimizer.util.IOPSolutionListOutput; public class GWASFGADiscreteOptRunner { + private JMETAL_ProblemDiscrete problem; private JMETAL_ProblemJMDiscrete problemJMDiscrete ; Algorithm<List<IntegerSolution>> algorithm; CrossoverOperator<IntegerSolution> crossover; @@ -38,6 +44,7 @@ public class GWASFGADiscreteOptRunner { SelectionOperator<List<IntegerSolution>, IntegerSolution> selection; public GWASFGADiscreteOptRunner(JMETAL_ProblemDiscrete problem) { + this.problem = problem; problemJMDiscrete = new JMETAL_ProblemJMDiscrete(problem) ; double crossoverProbability = 0.9 ; @@ -50,23 +57,56 @@ public class GWASFGADiscreteOptRunner { selection = new BinaryTournamentSelection<IntegerSolution>(new RankingAndCrowdingDistanceComparator<IntegerSolution>()); } + + public ArrayList<String> runDOML(ArrayList<String> objectives) { + algorithm = new GWASFGA<IntegerSolution>(problemJMDiscrete, 50, 250, crossover, mutation, selection,new SequentialSolutionListEvaluator<IntegerSolution>()); - public void run() { - algorithm = new GWASFGA<IntegerSolution>(problemJMDiscrete, 100, 250, crossover, mutation, selection,new SequentialSolutionListEvaluator<IntegerSolution>()); - - AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm) - .execute() ; + AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm) + .execute() ; - List<IntegerSolution> population = algorithm.getResult() ; - long computingTime = algorithmRunner.getComputingTime() ; + List<IntegerSolution> population = algorithm.getResult() ; + long computingTime = algorithmRunner.getComputingTime() ; - JMetalLogger.logger.info("Total execution time: " + computingTime + "ms"); - -// new SolutionListOutput(population) -// .setSeparator("\t") -// .setVarFileOutputContextDiscrete(new DefaultFileOutputContext("results/jMetal_VARDiscrete_GWASFGADiscrete.tsv")) -// .setVarFileOutputContext(new DefaultFileOutputContext("results/jMetal_VAR_GWASFGADiscrete.tsv")) -// .setFunFileOutputContext(new DefaultFileOutputContext("results/jMetal_FUN_GWASFGADiscrete.tsv")) -// .print(); + JMetalLogger.logger.info("Total execution time: " + computingTime + "ms"); + + List<IntegerSolution> populationOrdered = new ArrayList<IntegerSolution>(); + boolean inserted = false; + + for (int i=0; i<population.size();i++) { + if (populationOrdered.isEmpty()) { + populationOrdered.add(population.get(i)); + } + else { + inserted = false; + for (int j=0; j<populationOrdered.size();j++) { + if(objectives.get(0).contains("cost")) { + if(Math.abs(populationOrdered.get(j).getObjective(0))>Math.abs(population.get(i).getObjective(0)) && inserted == false) { + populationOrdered.add(j,population.get(i)); + inserted = true; + } + }else { + if(Math.abs(populationOrdered.get(j).getObjective(0))<Math.abs(population.get(i).getObjective(0)) && inserted == false) { + populationOrdered.add(j,population.get(i)); + inserted = true; + } + } + + } + + if (inserted==false) { + populationOrdered.add(population.get(i)); + } + } + } + + IOPSolutionListOutput SLO = new IOPSolutionListOutput(problem,populationOrdered); + SLO.setSeparator("\t"); + SLO.setVarFileOutputContextDiscrete(new DefaultFileOutputContext("C:/W/results/jMetal_VAR_GWASFGA_"+ System.currentTimeMillis() +".tsv")); + SLO.setVarFileOutputContext(new DefaultFileOutputContext("C:/W/results/jMetal_VAR_GWASFGA_Solution_"+ System.currentTimeMillis() +".tsv")); + SLO.setFunFileOutputContext(new DefaultFileOutputContext("C:/W/results/jMetal_FUN_GWASFGA_"+ System.currentTimeMillis() +".tsv")); + SLO.print(); + ArrayList<String> doml = SLO.generateDOMLDiscrete(problem.getObjectives()); + return doml; + } } diff --git a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/MOCellDiscreteOptRunner.java b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/MOCellDiscreteOptRunner.java index ab1b8c17de78659101248062d9f45bca8f9e48cf..3826ebc0a6cc2c15288c4b259549e90088e664db 100644 --- a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/MOCellDiscreteOptRunner.java +++ b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/MOCellDiscreteOptRunner.java @@ -12,10 +12,12 @@ **********************************************************************/ package com.piacere.iop.optimizer.algorithm.jmetal.discrete; +import java.util.ArrayList; import java.util.List; import org.uma.jmetal.algorithm.Algorithm; import org.uma.jmetal.algorithm.multiobjective.mocell.MOCellBuilder; +import org.uma.jmetal.algorithm.multiobjective.wasfga.WASFGA; import org.uma.jmetal.operator.CrossoverOperator; import org.uma.jmetal.operator.MutationOperator; import org.uma.jmetal.operator.SelectionOperator; @@ -26,10 +28,15 @@ import org.uma.jmetal.solution.IntegerSolution; import org.uma.jmetal.util.AlgorithmRunner; import org.uma.jmetal.util.JMetalLogger; import org.uma.jmetal.util.comparator.RankingAndCrowdingDistanceComparator; +import org.uma.jmetal.util.evaluator.impl.SequentialSolutionListEvaluator; +import org.uma.jmetal.util.fileoutput.impl.DefaultFileOutputContext; + import com.piacere.iop.optimizer.problems.JMETAL_ProblemDiscrete; import com.piacere.iop.optimizer.problems.JMETAL_ProblemJMDiscrete; +import com.piacere.iop.optimizer.util.IOPSolutionListOutput; public class MOCellDiscreteOptRunner { + private JMETAL_ProblemDiscrete problem; private JMETAL_ProblemJMDiscrete problemJMDiscrete ; Algorithm<List<IntegerSolution>> algorithm; CrossoverOperator<IntegerSolution> crossover; @@ -37,6 +44,7 @@ public class MOCellDiscreteOptRunner { SelectionOperator<List<IntegerSolution>, IntegerSolution> selection; public MOCellDiscreteOptRunner(JMETAL_ProblemDiscrete problem) { + this.problem = problem; problemJMDiscrete = new JMETAL_ProblemJMDiscrete(problem) ; double crossoverProbability = 0.9 ; @@ -49,27 +57,59 @@ public class MOCellDiscreteOptRunner { selection = new BinaryTournamentSelection<IntegerSolution>(new RankingAndCrowdingDistanceComparator<IntegerSolution>()); } - - public void run() { + + public ArrayList<String> runDOML(ArrayList<String> objectives) { algorithm = new MOCellBuilder<IntegerSolution>(problemJMDiscrete, crossover, mutation) - .setSelectionOperator(selection) - .setMaxEvaluations(10000) - .setPopulationSize(100) - .build(); + .setSelectionOperator(selection) + .setMaxEvaluations(250) + .setPopulationSize(50) + .build(); AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm) .execute() ; - List<IntegerSolution> population = algorithm.getResult() ; + List<IntegerSolution> population = algorithm.getResult(); long computingTime = algorithmRunner.getComputingTime() ; JMetalLogger.logger.info("Total execution time: " + computingTime + "ms"); - -// new SolutionListOutput(population) -// .setSeparator("\t") -// .setVarFileOutputContextDiscrete(new DefaultFileOutputContext("results/jMetal_VARDiscrete_MOCellDiscrete.tsv")) -// .setVarFileOutputContext(new DefaultFileOutputContext("results/jMetal_VAR_MOCellDiscrete.tsv")) -// .setFunFileOutputContext(new DefaultFileOutputContext("results/jMetal_FUN_MOCellDiscrete.tsv")) -// .print(); + + List<IntegerSolution> populationOrdered = new ArrayList<IntegerSolution>(); + boolean inserted = false; + + for (int i=0; i<population.size();i++) { + if (populationOrdered.isEmpty()) { + populationOrdered.add(population.get(i)); + } + else { + inserted = false; + for (int j=0; j<populationOrdered.size();j++) { + if(objectives.get(0).contains("cost")) { + if(Math.abs(populationOrdered.get(j).getObjective(0))>Math.abs(population.get(i).getObjective(0)) && inserted == false) { + populationOrdered.add(j,population.get(i)); + inserted = true; + } + }else { + if(Math.abs(populationOrdered.get(j).getObjective(0))<Math.abs(population.get(i).getObjective(0)) && inserted == false) { + populationOrdered.add(j,population.get(i)); + inserted = true; + } + } + + } + + if (inserted==false) { + populationOrdered.add(population.get(i)); + } + } + } + + IOPSolutionListOutput SLO = new IOPSolutionListOutput(problem,populationOrdered); + SLO.setSeparator("\t"); + SLO.setVarFileOutputContextDiscrete(new DefaultFileOutputContext("C:/W/results/jMetal_VAR_MoCell_"+ System.currentTimeMillis() +".tsv")); + SLO.setVarFileOutputContext(new DefaultFileOutputContext("C:/W/results/jMetal_VAR_MoCell_Solution_"+ System.currentTimeMillis() +".tsv")); + SLO.setFunFileOutputContext(new DefaultFileOutputContext("C:/W/results/jMetal_FUN_MoCell_"+ System.currentTimeMillis() +".tsv")); + SLO.print(); + ArrayList<String> doml = SLO.generateDOMLDiscrete(problem.getObjectives()); + return doml; } } diff --git a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/MOMBI2DiscreteOptRunner.java b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/MOMBI2DiscreteOptRunner.java index 66cd4dc41c0c8c9db0ee10dfa4d6aed3088b5ae9..8762a9e403a24bf9cd4a94f913544a5765b1e146 100644 --- a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/MOMBI2DiscreteOptRunner.java +++ b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/MOMBI2DiscreteOptRunner.java @@ -12,9 +12,11 @@ **********************************************************************/ package com.piacere.iop.optimizer.algorithm.jmetal.discrete; +import java.util.ArrayList; import java.util.List; import org.uma.jmetal.algorithm.Algorithm; +import org.uma.jmetal.algorithm.multiobjective.mombi.MOMBI; import org.uma.jmetal.algorithm.multiobjective.mombi.MOMBI2; import org.uma.jmetal.operator.CrossoverOperator; import org.uma.jmetal.operator.MutationOperator; @@ -27,10 +29,14 @@ import org.uma.jmetal.util.AlgorithmRunner; import org.uma.jmetal.util.JMetalLogger; import org.uma.jmetal.util.comparator.RankingAndCrowdingDistanceComparator; import org.uma.jmetal.util.evaluator.impl.SequentialSolutionListEvaluator; +import org.uma.jmetal.util.fileoutput.impl.DefaultFileOutputContext; + import com.piacere.iop.optimizer.problems.JMETAL_ProblemDiscrete; import com.piacere.iop.optimizer.problems.JMETAL_ProblemJMDiscrete; +import com.piacere.iop.optimizer.util.IOPSolutionListOutput; public class MOMBI2DiscreteOptRunner { + private JMETAL_ProblemDiscrete problem; private JMETAL_ProblemJMDiscrete problemJMDiscrete ; Algorithm<List<IntegerSolution>> algorithm; CrossoverOperator<IntegerSolution> crossover; @@ -38,6 +44,7 @@ public class MOMBI2DiscreteOptRunner { SelectionOperator<List<IntegerSolution>, IntegerSolution> selection; public MOMBI2DiscreteOptRunner(JMETAL_ProblemDiscrete problem) { + this.problem = problem; problemJMDiscrete = new JMETAL_ProblemJMDiscrete(problem) ; double crossoverProbability = 0.9 ; @@ -50,24 +57,58 @@ public class MOMBI2DiscreteOptRunner { selection = new BinaryTournamentSelection<IntegerSolution>(new RankingAndCrowdingDistanceComparator<IntegerSolution>()); } - - public void run() { - algorithm = new MOMBI2<IntegerSolution>(problemJMDiscrete,54,crossover,mutation,selection,new SequentialSolutionListEvaluator<IntegerSolution>(), - "mombi2-weights/weight/weight_03D_12.sld"); - - AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm) - .execute() ; - - List<IntegerSolution> population = algorithm.getResult() ; - long computingTime = algorithmRunner.getComputingTime() ; - - JMetalLogger.logger.info("Total execution time: " + computingTime + "ms"); - -// new SolutionListOutput(population) -// .setSeparator("\t") -// .setVarFileOutputContextDiscrete(new DefaultFileOutputContext("results/jMetal_VARDiscrete_MOMBI2Discrete.tsv")) -// .setVarFileOutputContext(new DefaultFileOutputContext("results/jMetal_VAR_MOMBI2Discrete.tsv")) -// .setFunFileOutputContext(new DefaultFileOutputContext("results/jMetal_FUN_MOMBI2Discrete.tsv")) -// .print(); - } + + public ArrayList<String> runDOML(ArrayList<String> objectives) { + algorithm = new MOMBI2<IntegerSolution>(problemJMDiscrete,54,crossover,mutation,selection,new SequentialSolutionListEvaluator<IntegerSolution>(), + "mombi2-weights/weight/weight_03D_12.sld"); + + //weight_02D_200.sld + + AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm) + .execute() ; + + List<IntegerSolution> population = algorithm.getResult() ; + long computingTime = algorithmRunner.getComputingTime() ; + + JMetalLogger.logger.info("Total execution time: " + computingTime + "ms"); + + List<IntegerSolution> populationOrdered = new ArrayList<IntegerSolution>(); + boolean inserted = false; + + for (int i=0; i<population.size();i++) { + if (populationOrdered.isEmpty()) { + populationOrdered.add(population.get(i)); + } + else { + inserted = false; + for (int j=0; j<populationOrdered.size();j++) { + if(objectives.get(0).contains("cost")) { + if(Math.abs(populationOrdered.get(j).getObjective(0))>Math.abs(population.get(i).getObjective(0)) && inserted == false) { + populationOrdered.add(j,population.get(i)); + inserted = true; + } + }else { + if(Math.abs(populationOrdered.get(j).getObjective(0))<Math.abs(population.get(i).getObjective(0)) && inserted == false) { + populationOrdered.add(j,population.get(i)); + inserted = true; + } + } + + } + + if (inserted==false) { + populationOrdered.add(population.get(i)); + } + } + } + + IOPSolutionListOutput SLO = new IOPSolutionListOutput(problem,populationOrdered); + SLO.setSeparator("\t"); + SLO.setVarFileOutputContextDiscrete(new DefaultFileOutputContext("C:/W/results/jMetal_VAR_MOMBI2_"+ System.currentTimeMillis() +".tsv")); + SLO.setVarFileOutputContext(new DefaultFileOutputContext("C:/W/results/jMetal_VAR_MOMBI2_Solution_"+ System.currentTimeMillis() +".tsv")); + SLO.setFunFileOutputContext(new DefaultFileOutputContext("C:/W/results/jMetal_FUN_MOMBI2_"+ System.currentTimeMillis() +".tsv")); + SLO.print(); + ArrayList<String> doml = SLO.generateDOMLDiscrete(problem.getObjectives()); + return doml; + } } diff --git a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/MOMBIDiscreteOptRunner.java b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/MOMBIDiscreteOptRunner.java index 3feb2cf933ca085be093eb8526b67a4bc7212de2..d21cebf8f96d9893bb051791b8f59be234c17e70 100644 --- a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/MOMBIDiscreteOptRunner.java +++ b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/MOMBIDiscreteOptRunner.java @@ -12,10 +12,12 @@ **********************************************************************/ package com.piacere.iop.optimizer.algorithm.jmetal.discrete; +import java.util.ArrayList; import java.util.List; import org.uma.jmetal.algorithm.Algorithm; import org.uma.jmetal.algorithm.multiobjective.mombi.MOMBI; +import org.uma.jmetal.algorithm.multiobjective.wasfga.WASFGA; import org.uma.jmetal.operator.CrossoverOperator; import org.uma.jmetal.operator.MutationOperator; import org.uma.jmetal.operator.SelectionOperator; @@ -27,10 +29,14 @@ import org.uma.jmetal.util.AlgorithmRunner; import org.uma.jmetal.util.JMetalLogger; import org.uma.jmetal.util.comparator.RankingAndCrowdingDistanceComparator; import org.uma.jmetal.util.evaluator.impl.SequentialSolutionListEvaluator; +import org.uma.jmetal.util.fileoutput.impl.DefaultFileOutputContext; + import com.piacere.iop.optimizer.problems.JMETAL_ProblemDiscrete; import com.piacere.iop.optimizer.problems.JMETAL_ProblemJMDiscrete; +import com.piacere.iop.optimizer.util.IOPSolutionListOutput; public class MOMBIDiscreteOptRunner { + private JMETAL_ProblemDiscrete problem; private JMETAL_ProblemJMDiscrete problemJMDiscrete ; Algorithm<List<IntegerSolution>> algorithm; CrossoverOperator<IntegerSolution> crossover; @@ -38,6 +44,7 @@ public class MOMBIDiscreteOptRunner { SelectionOperator<List<IntegerSolution>, IntegerSolution> selection; public MOMBIDiscreteOptRunner(JMETAL_ProblemDiscrete problem) { + this.problem = problem; problemJMDiscrete = new JMETAL_ProblemJMDiscrete(problem) ; double crossoverProbability = 0.9 ; @@ -51,23 +58,58 @@ public class MOMBIDiscreteOptRunner { selection = new BinaryTournamentSelection<IntegerSolution>(new RankingAndCrowdingDistanceComparator<IntegerSolution>()); } - public void run() { - algorithm = new MOMBI<IntegerSolution>(problemJMDiscrete,54,crossover,mutation,selection,new SequentialSolutionListEvaluator<IntegerSolution>(), - "mombi2-weights/weight/weight_03D_12.sld"); - - AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm) - .execute() ; - - List<IntegerSolution> population = algorithm.getResult() ; - long computingTime = algorithmRunner.getComputingTime() ; - - JMetalLogger.logger.info("Total execution time: " + computingTime + "ms"); - -// new SolutionListOutput(population) -// .setSeparator("\t") -// .setVarFileOutputContextDiscrete(new DefaultFileOutputContext("results/jMetal_VARDiscrete_MOMBI2Discrete.tsv")) -// .setVarFileOutputContext(new DefaultFileOutputContext("results/jMetal_VAR_MOMBI2Discrete.tsv")) -// .setFunFileOutputContext(new DefaultFileOutputContext("results/jMetal_FUN_MOMBI2Discrete.tsv")) -// .print(); + public ArrayList<String> runDOML(ArrayList<String> objectives) { + algorithm = new MOMBI<IntegerSolution>(problemJMDiscrete,54,crossover,mutation,selection,new SequentialSolutionListEvaluator<IntegerSolution>(), + "mombi2-weights/weight/weight_03D_12.sld"); + + //weight_02D_200.sld + + AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm) + .execute() ; + + List<IntegerSolution> population = algorithm.getResult() ; + long computingTime = algorithmRunner.getComputingTime() ; + + JMetalLogger.logger.info("Total execution time: " + computingTime + "ms"); + + List<IntegerSolution> populationOrdered = new ArrayList<IntegerSolution>(); + boolean inserted = false; + + for (int i=0; i<population.size();i++) { + if (populationOrdered.isEmpty()) { + populationOrdered.add(population.get(i)); + } + else { + inserted = false; + for (int j=0; j<populationOrdered.size();j++) { + if(objectives.get(0).contains("cost")) { + if(Math.abs(populationOrdered.get(j).getObjective(0))>Math.abs(population.get(i).getObjective(0)) && inserted == false) { + populationOrdered.add(j,population.get(i)); + inserted = true; + } + }else { + if(Math.abs(populationOrdered.get(j).getObjective(0))<Math.abs(population.get(i).getObjective(0)) && inserted == false) { + populationOrdered.add(j,population.get(i)); + inserted = true; + } + } + + } + + if (inserted==false) { + populationOrdered.add(population.get(i)); + } + } + } + + IOPSolutionListOutput SLO = new IOPSolutionListOutput(problem,populationOrdered); + SLO.setSeparator("\t"); + SLO.setVarFileOutputContextDiscrete(new DefaultFileOutputContext("C:/W/results/jMetal_VAR_MOMBI_"+ System.currentTimeMillis() +".tsv")); + SLO.setVarFileOutputContext(new DefaultFileOutputContext("C:/W/results/jMetal_VAR_MOMBI_Solution_"+ System.currentTimeMillis() +".tsv")); + SLO.setFunFileOutputContext(new DefaultFileOutputContext("C:/W/results/jMetal_FUN_MOMBI.tsv_"+ System.currentTimeMillis() +".tsv")); + SLO.print(); + ArrayList<String> doml = SLO.generateDOMLDiscrete(problem.getObjectives()); + return doml; } + } diff --git a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/NSGAIIDiscreteOptRunner.java b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/NSGAIIDiscreteOptRunner.java index 4da8eb9b3bf57a18ff153ad092cbce2087ac25d6..805156dd465dccf457fcfe98e17155cf1f1af9b0 100644 --- a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/NSGAIIDiscreteOptRunner.java +++ b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/NSGAIIDiscreteOptRunner.java @@ -12,6 +12,7 @@ **********************************************************************/ package com.piacere.iop.optimizer.algorithm.jmetal.discrete; +import java.util.ArrayList; import java.util.List; import org.json.simple.JSONObject; @@ -41,7 +42,7 @@ public class NSGAIIDiscreteOptRunner { SelectionOperator<List<IntegerSolution>, IntegerSolution> selection; public NSGAIIDiscreteOptRunner(JMETAL_ProblemDiscrete problem) { - this.problem = problem; + this.problem = problem; problemJMDiscrete = new JMETAL_ProblemJMDiscrete(problem) ; double crossoverProbability = 0.9 ; @@ -54,29 +55,61 @@ public class NSGAIIDiscreteOptRunner { selection = new BinaryTournamentSelection<IntegerSolution>(new RankingAndCrowdingDistanceComparator<IntegerSolution>()); } + + public ArrayList<String> runDOML(ArrayList<String> objectives) { + algorithm = new NSGAIIBuilder<IntegerSolution>(problemJMDiscrete, crossover, mutation) + .setSelectionOperator(selection) + .setMaxEvaluations(50000) + .setPopulationSize(200) + .build(); - public JSONObject run() { - algorithm = new NSGAIIBuilder<IntegerSolution>(problemJMDiscrete, crossover, mutation) - .setSelectionOperator(selection) - .setMaxEvaluations(10000) - .setPopulationSize(100) - .build(); + AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm) + .execute() ; - AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm) - .execute() ; + List<IntegerSolution> population = algorithm.getResult(); + long computingTime = algorithmRunner.getComputingTime() ; - List<IntegerSolution> population = algorithm.getResult() ; - long computingTime = algorithmRunner.getComputingTime() ; - - JMetalLogger.logger.info("Total execution time: " + computingTime + "ms"); - - IOPSolutionListOutput SLO = new IOPSolutionListOutput(problem,population); - SLO.setSeparator("\t"); - SLO.setVarFileOutputContextDiscrete(new DefaultFileOutputContext("results/jMetal_VAR_NSGAIIContinuous.tsv")); - SLO.setVarFileOutputContext(new DefaultFileOutputContext("results/jMetal_VAR_NSGAII.tsv")); - SLO.setFunFileOutputContext(new DefaultFileOutputContext("results/jMetal_FUN_NSGAII.tsv")); - JSONObject json = SLO.generateJSONDiscrete(); - return json; - + JMetalLogger.logger.info("Total execution time: " + computingTime + "ms"); + + List<IntegerSolution> populationOrdered = new ArrayList<IntegerSolution>(); + boolean inserted = false; + + for (int i=0; i<population.size();i++) { + if (populationOrdered.isEmpty()) { + populationOrdered.add(population.get(i)); + } + else { + inserted = false; + for (int j=0; j<populationOrdered.size();j++) { + if(objectives.get(0).contains("cost")) { + if(Math.abs(populationOrdered.get(j).getObjective(0))>Math.abs(population.get(i).getObjective(0)) && inserted == false) { + populationOrdered.add(j,population.get(i)); + inserted = true; + } + }else { + if(Math.abs(populationOrdered.get(j).getObjective(0))<Math.abs(population.get(i).getObjective(0)) && inserted == false) { + populationOrdered.add(j,population.get(i)); + inserted = true; + } + } + + } + + if (inserted==false) { + populationOrdered.add(population.get(i)); + } + } + } + + IOPSolutionListOutput SLO = new IOPSolutionListOutput(problem,populationOrdered); + //SLO.setSeparator("\t"); + //SLO.setVarFileOutputContextDiscrete(new DefaultFileOutputContext("C:/W/results/jMetal_VAR_NSGAII_"+ System.currentTimeMillis() +".tsv")); + //SLO.setVarFileOutputContext(new DefaultFileOutputContext("C:/W/results/jMetal_VAR_NSGAII_Solution_"+ System.currentTimeMillis() +".tsv")); + //SLO.setFunFileOutputContext(new DefaultFileOutputContext("C:/W/results/jMetal_FUN_NSGAII_"+ System.currentTimeMillis() +".tsv")); + //SLO.print(); + ArrayList<String> doml = SLO.generateDOMLDiscrete(problem.getObjectives()); + return doml; + } + } diff --git a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/NSGAIIIDiscreteOptRunner.java b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/NSGAIIIDiscreteOptRunner.java index 8104c066459512ef462858f99a00f8167f2dbb78..5f07551557120ea9bd2569ad65c79d8287c6bf6e 100644 --- a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/NSGAIIIDiscreteOptRunner.java +++ b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/NSGAIIIDiscreteOptRunner.java @@ -12,9 +12,12 @@ **********************************************************************/ package com.piacere.iop.optimizer.algorithm.jmetal.discrete; +import java.util.ArrayList; import java.util.List; +import org.json.simple.JSONObject; import org.uma.jmetal.algorithm.Algorithm; +import org.uma.jmetal.algorithm.multiobjective.nsgaii.NSGAIIBuilder; import org.uma.jmetal.algorithm.multiobjective.nsgaiii.NSGAIIIBuilder; import org.uma.jmetal.operator.CrossoverOperator; import org.uma.jmetal.operator.MutationOperator; @@ -26,10 +29,14 @@ import org.uma.jmetal.solution.IntegerSolution; import org.uma.jmetal.util.AlgorithmRunner; import org.uma.jmetal.util.JMetalLogger; import org.uma.jmetal.util.comparator.RankingAndCrowdingDistanceComparator; +import org.uma.jmetal.util.fileoutput.impl.DefaultFileOutputContext; + import com.piacere.iop.optimizer.problems.JMETAL_ProblemDiscrete; import com.piacere.iop.optimizer.problems.JMETAL_ProblemJMDiscrete; +import com.piacere.iop.optimizer.util.IOPSolutionListOutput; public class NSGAIIIDiscreteOptRunner { + private JMETAL_ProblemDiscrete problem; private JMETAL_ProblemJMDiscrete problemJMDiscrete ; Algorithm<List<IntegerSolution>> algorithm; CrossoverOperator<IntegerSolution> crossover; @@ -37,6 +44,7 @@ public class NSGAIIIDiscreteOptRunner { SelectionOperator<List<IntegerSolution>, IntegerSolution> selection; public NSGAIIIDiscreteOptRunner(JMETAL_ProblemDiscrete problem) { + this.problem = problem; problemJMDiscrete = new JMETAL_ProblemJMDiscrete(problem) ; double crossoverProbability = 0.9 ; @@ -51,27 +59,60 @@ public class NSGAIIIDiscreteOptRunner { } - public void run() { - algorithm = new NSGAIIIBuilder<IntegerSolution>(problemJMDiscrete) - .setCrossoverOperator(crossover) - .setMutationOperator(mutation) - .setSelectionOperator(selection) - .setMaxIterations(55) - .build() ; - - AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm) - .execute() ; - - List<IntegerSolution> population = algorithm.getResult() ; - long computingTime = algorithmRunner.getComputingTime() ; - - JMetalLogger.logger.info("Total execution time: " + computingTime + "ms"); - -// new SolutionListOutput(population) -// .setSeparator("\t") -// .setVarFileOutputContextDiscrete(new DefaultFileOutputContext("results/jMetal_VARDiscrete_NSGAIIIDiscrete.tsv")) -// .setVarFileOutputContext(new DefaultFileOutputContext("results/jMetal_VAR_NSGAIIIDiscrete.tsv")) -// .setFunFileOutputContext(new DefaultFileOutputContext("results/jMetal_FUN_NSGAIIIDiscrete.tsv")) -// .print(); + public ArrayList<String> runDOML(ArrayList<String> objectives) { + algorithm = new NSGAIIIBuilder<IntegerSolution>(problemJMDiscrete) + .setCrossoverOperator(crossover) + .setMutationOperator(mutation) + .setSelectionOperator(selection) + .setMaxIterations(50000) + .setPopulationSize(500) + .build() ; + + AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm) + .execute() ; + + List<IntegerSolution> population = algorithm.getResult() ; + long computingTime = algorithmRunner.getComputingTime() ; + + JMetalLogger.logger.info("Total execution time: " + computingTime + "ms"); + + List<IntegerSolution> populationOrdered = new ArrayList<IntegerSolution>(); + boolean inserted = false; + + for (int i=0; i<population.size();i++) { + if (populationOrdered.isEmpty()) { + populationOrdered.add(population.get(i)); + } + else { + inserted = false; + for (int j=0; j<populationOrdered.size();j++) { + if(objectives.get(0).contains("cost")) { + if(Math.abs(populationOrdered.get(j).getObjective(0))>Math.abs(population.get(i).getObjective(0)) && inserted == false) { + populationOrdered.add(j,population.get(i)); + inserted = true; + } + }else { + if(Math.abs(populationOrdered.get(j).getObjective(0))<Math.abs(population.get(i).getObjective(0)) && inserted == false) { + populationOrdered.add(j,population.get(i)); + inserted = true; + } + } + + } + + if (inserted==false) { + populationOrdered.add(population.get(i)); + } + } + } + + IOPSolutionListOutput SLO = new IOPSolutionListOutput(problem,populationOrdered); + //SLO.setSeparator("\t"); + //SLO.setVarFileOutputContextDiscrete(new DefaultFileOutputContext("C:/W/results/jMetal_VAR_NSGAIII_"+ System.currentTimeMillis() +".tsv")); + //SLO.setVarFileOutputContext(new DefaultFileOutputContext("C:/W/results/jMetal_VAR_NSGAIII_Solution_"+ System.currentTimeMillis() +".tsv")); + //SLO.setFunFileOutputContext(new DefaultFileOutputContext("C:/W/results/jMetal_FUN_NSGAIII_"+ System.currentTimeMillis() +".tsv")); + //SLO.print(); + ArrayList<String> doml = SLO.generateDOMLDiscrete(problem.getObjectives()); + return doml; } } diff --git a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/SMSEMOADiscreteOptRunner.java b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/SMSEMOADiscreteOptRunner.java index 6ab4e57fb9860434a6d181e19e50ec56954671e9..be12dc80b88428305801a657b9938dad5eaba5ce 100644 --- a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/SMSEMOADiscreteOptRunner.java +++ b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/SMSEMOADiscreteOptRunner.java @@ -12,9 +12,11 @@ **********************************************************************/ package com.piacere.iop.optimizer.algorithm.jmetal.discrete; +import java.util.ArrayList; import java.util.List; import org.uma.jmetal.algorithm.Algorithm; +import org.uma.jmetal.algorithm.multiobjective.nsgaii.NSGAIIBuilder; import org.uma.jmetal.algorithm.multiobjective.smsemoa.SMSEMOABuilder; import org.uma.jmetal.operator.CrossoverOperator; import org.uma.jmetal.operator.MutationOperator; @@ -27,10 +29,14 @@ import org.uma.jmetal.qualityindicator.impl.hypervolume.PISAHypervolume; import org.uma.jmetal.solution.IntegerSolution; import org.uma.jmetal.util.AlgorithmRunner; import org.uma.jmetal.util.JMetalLogger; +import org.uma.jmetal.util.fileoutput.impl.DefaultFileOutputContext; + import com.piacere.iop.optimizer.problems.JMETAL_ProblemDiscrete; import com.piacere.iop.optimizer.problems.JMETAL_ProblemJMDiscrete; +import com.piacere.iop.optimizer.util.IOPSolutionListOutput; public class SMSEMOADiscreteOptRunner { + private JMETAL_ProblemDiscrete problem; private JMETAL_ProblemJMDiscrete problemJMDiscrete ; Algorithm<List<IntegerSolution>> algorithm; CrossoverOperator<IntegerSolution> crossover; @@ -39,6 +45,7 @@ public class SMSEMOADiscreteOptRunner { private Hypervolume<IntegerSolution> hypervolume; public SMSEMOADiscreteOptRunner(JMETAL_ProblemDiscrete problem) { + this.problem = problem; problemJMDiscrete = new JMETAL_ProblemJMDiscrete(problem) ; double crossoverProbability = 0.9 ; @@ -56,27 +63,61 @@ public class SMSEMOADiscreteOptRunner { } - public void run() { - algorithm = new SMSEMOABuilder<IntegerSolution>(problemJMDiscrete, crossover, mutation) - .setSelectionOperator(selection) - .setMaxEvaluations(25000) - .setPopulationSize(100) - .setHypervolumeImplementation(hypervolume) - .build() ; - - AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm) - .execute() ; - - List<IntegerSolution> population = algorithm.getResult() ; - long computingTime = algorithmRunner.getComputingTime() ; - JMetalLogger.logger.info("Total execution time: " + computingTime + "ms"); - -// new SolutionListOutput(population) -// .setSeparator("\t") -// .setVarFileOutputContextDiscrete(new DefaultFileOutputContext("results/jMetal_VARDiscrete_SMSEMOADiscrete.tsv")) -// .setVarFileOutputContext(new DefaultFileOutputContext("results/jMetal_VAR_SMSEMOADiscrete.tsv")) -// .setFunFileOutputContext(new DefaultFileOutputContext("results/jMetal_FUN_SMSEMOADiscrete.tsv")) -// .print(); - } + public ArrayList<String> runDOML(ArrayList<String> objectives) { + algorithm = new SMSEMOABuilder<IntegerSolution>(problemJMDiscrete, crossover, mutation) + .setSelectionOperator(selection) + .setMaxEvaluations(250) + .setPopulationSize(50) + .setHypervolumeImplementation(hypervolume) + .build() ; + + AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm) + .execute() ; + + List<IntegerSolution> population = algorithm.getResult() ; + long computingTime = algorithmRunner.getComputingTime() ; + + JMetalLogger.logger.info("Total execution time: " + computingTime + "ms"); + + List<IntegerSolution> populationOrdered = new ArrayList<IntegerSolution>(); + boolean inserted = false; + + for (int i=0; i<population.size();i++) { + if (populationOrdered.isEmpty()) { + populationOrdered.add(population.get(i)); + } + else { + inserted = false; + for (int j=0; j<populationOrdered.size();j++) { + if(objectives.get(0).contains("cost")) { + if(Math.abs(populationOrdered.get(j).getObjective(0))>Math.abs(population.get(i).getObjective(0)) && inserted == false) { + populationOrdered.add(j,population.get(i)); + inserted = true; + } + }else { + if(Math.abs(populationOrdered.get(j).getObjective(0))<Math.abs(population.get(i).getObjective(0)) && inserted == false) { + populationOrdered.add(j,population.get(i)); + inserted = true; + } + } + + } + + if (inserted==false) { + populationOrdered.add(population.get(i)); + } + } + } + + IOPSolutionListOutput SLO = new IOPSolutionListOutput(problem,populationOrdered); + SLO.setSeparator("\t"); + SLO.setVarFileOutputContextDiscrete(new DefaultFileOutputContext("C:/W/results/jMetal_VAR_SMSEMOA_"+ System.currentTimeMillis() +".tsv")); + SLO.setVarFileOutputContext(new DefaultFileOutputContext("C:/W/results/jMetal_VAR_SMSEMOA_Solution_"+ System.currentTimeMillis() +".tsv")); + SLO.setFunFileOutputContext(new DefaultFileOutputContext("C:/W/results/jMetal_FUN_SMSEMOA_"+ System.currentTimeMillis() +".tsv")); + SLO.print(); + ArrayList<String> doml = SLO.generateDOMLDiscrete(problem.getObjectives()); + return doml; + + } } diff --git a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/SPEA2DiscreteOptRunner.java b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/SPEA2DiscreteOptRunner.java index 86838c0b4aba511d777161530789cb3fcf103acc..bfde0b130feeb9f819853f93a9fb57aaa4f68611 100644 --- a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/SPEA2DiscreteOptRunner.java +++ b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/SPEA2DiscreteOptRunner.java @@ -12,9 +12,11 @@ **********************************************************************/ package com.piacere.iop.optimizer.algorithm.jmetal.discrete; +import java.util.ArrayList; import java.util.List; import org.uma.jmetal.algorithm.Algorithm; +import org.uma.jmetal.algorithm.multiobjective.gwasfga.GWASFGA; import org.uma.jmetal.algorithm.multiobjective.spea2.SPEA2Builder; import org.uma.jmetal.operator.CrossoverOperator; import org.uma.jmetal.operator.MutationOperator; @@ -26,10 +28,15 @@ import org.uma.jmetal.solution.IntegerSolution; import org.uma.jmetal.util.AlgorithmRunner; import org.uma.jmetal.util.JMetalLogger; import org.uma.jmetal.util.comparator.RankingAndCrowdingDistanceComparator; +import org.uma.jmetal.util.evaluator.impl.SequentialSolutionListEvaluator; +import org.uma.jmetal.util.fileoutput.impl.DefaultFileOutputContext; + import com.piacere.iop.optimizer.problems.JMETAL_ProblemDiscrete; import com.piacere.iop.optimizer.problems.JMETAL_ProblemJMDiscrete; +import com.piacere.iop.optimizer.util.IOPSolutionListOutput; public class SPEA2DiscreteOptRunner { + private JMETAL_ProblemDiscrete problem; private JMETAL_ProblemJMDiscrete problemJMDiscrete ; Algorithm<List<IntegerSolution>> algorithm; CrossoverOperator<IntegerSolution> crossover; @@ -37,6 +44,7 @@ public class SPEA2DiscreteOptRunner { SelectionOperator<List<IntegerSolution>, IntegerSolution> selection; public SPEA2DiscreteOptRunner(JMETAL_ProblemDiscrete problem) { + this.problem = problem; problemJMDiscrete = new JMETAL_ProblemJMDiscrete(problem) ; double crossoverProbability = 0.9 ; @@ -54,7 +62,7 @@ public class SPEA2DiscreteOptRunner { algorithm = new SPEA2Builder<IntegerSolution>(problemJMDiscrete, crossover, mutation) .setSelectionOperator(selection) .setMaxIterations(250) - .setPopulationSize(100) + .setPopulationSize(50) .build(); AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm) @@ -72,4 +80,60 @@ public class SPEA2DiscreteOptRunner { // .setFunFileOutputContext(new DefaultFileOutputContext("results/jMetal_FUN_SPEA2Discrete.tsv")) // .print(); } + + public ArrayList<String> runDOML(ArrayList<String> objectives) { + algorithm = new SPEA2Builder<IntegerSolution>(problemJMDiscrete, crossover, mutation) + .setSelectionOperator(selection) + .setMaxIterations(250) + .setPopulationSize(50) + .build(); + + AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm) + .execute() ; + + List<IntegerSolution> population = algorithm.getResult() ; + long computingTime = algorithmRunner.getComputingTime() ; + + JMetalLogger.logger.info("Total execution time: " + computingTime + "ms"); + + List<IntegerSolution> populationOrdered = new ArrayList<IntegerSolution>(); + boolean inserted = false; + + for (int i=0; i<population.size();i++) { + if (populationOrdered.isEmpty()) { + populationOrdered.add(population.get(i)); + } + else { + inserted = false; + for (int j=0; j<populationOrdered.size();j++) { + if(objectives.get(0).contains("cost")) { + if(Math.abs(populationOrdered.get(j).getObjective(0))>Math.abs(population.get(i).getObjective(0)) && inserted == false) { + populationOrdered.add(j,population.get(i)); + inserted = true; + } + }else { + if(Math.abs(populationOrdered.get(j).getObjective(0))<Math.abs(population.get(i).getObjective(0)) && inserted == false) { + populationOrdered.add(j,population.get(i)); + inserted = true; + } + } + + } + + if (inserted==false) { + populationOrdered.add(population.get(i)); + } + } + } + + IOPSolutionListOutput SLO = new IOPSolutionListOutput(problem,populationOrdered); + SLO.setSeparator("\t"); + SLO.setVarFileOutputContextDiscrete(new DefaultFileOutputContext("C:/W/results/jMetal_VAR_SPEA2_"+ System.currentTimeMillis() +".tsv")); + SLO.setVarFileOutputContext(new DefaultFileOutputContext("C:/W/results/jMetal_VAR_SPEA2_Solution_"+ System.currentTimeMillis() +".tsv")); + SLO.setFunFileOutputContext(new DefaultFileOutputContext("C:/W/results/jMetal_FUN_SPEA2_"+ System.currentTimeMillis() +".tsv")); + SLO.print(); + ArrayList<String> doml = SLO.generateDOMLDiscrete(problem.getObjectives()); + return doml; + } + } diff --git a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/WASFGADiscreteOptRunner.java b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/WASFGADiscreteOptRunner.java index 8fa883dd11d74fdb551a216a8d972eebe20e6632..da99ebb423ae38318416ed93a948b20b9d7af1fc 100644 --- a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/WASFGADiscreteOptRunner.java +++ b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/algorithm/jmetal/discrete/WASFGADiscreteOptRunner.java @@ -16,6 +16,7 @@ import java.util.ArrayList; import java.util.List; import org.uma.jmetal.algorithm.Algorithm; +import org.uma.jmetal.algorithm.multiobjective.spea2.SPEA2Builder; import org.uma.jmetal.algorithm.multiobjective.wasfga.WASFGA; import org.uma.jmetal.operator.CrossoverOperator; import org.uma.jmetal.operator.MutationOperator; @@ -28,10 +29,14 @@ import org.uma.jmetal.util.AlgorithmRunner; import org.uma.jmetal.util.JMetalLogger; import org.uma.jmetal.util.comparator.RankingAndCrowdingDistanceComparator; import org.uma.jmetal.util.evaluator.impl.SequentialSolutionListEvaluator; +import org.uma.jmetal.util.fileoutput.impl.DefaultFileOutputContext; + import com.piacere.iop.optimizer.problems.JMETAL_ProblemDiscrete; import com.piacere.iop.optimizer.problems.JMETAL_ProblemJMDiscrete; +import com.piacere.iop.optimizer.util.IOPSolutionListOutput; public class WASFGADiscreteOptRunner { + private JMETAL_ProblemDiscrete problem; private JMETAL_ProblemJMDiscrete problemJMDiscrete ; Algorithm<List<IntegerSolution>> algorithm; CrossoverOperator<IntegerSolution> crossover; @@ -40,6 +45,7 @@ public class WASFGADiscreteOptRunner { private List<Double> referencePoint = null; public WASFGADiscreteOptRunner(JMETAL_ProblemDiscrete problem) { + this.problem = problem; problemJMDiscrete = new JMETAL_ProblemJMDiscrete(problem) ; double crossoverProbability = 0.9 ; @@ -57,22 +63,54 @@ public class WASFGADiscreteOptRunner { referencePoint.add(0.0); } - public void run() { - algorithm = new WASFGA<IntegerSolution>(problemJMDiscrete, 100, 250, crossover, mutation, selection,new SequentialSolutionListEvaluator<IntegerSolution>(), referencePoint); + public ArrayList<String> runDOML(ArrayList<String> objectives) { + algorithm = new WASFGA<IntegerSolution>(problemJMDiscrete, 50, 250, crossover, mutation, selection,new SequentialSolutionListEvaluator<IntegerSolution>(), referencePoint); - AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm) - .execute() ; + AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm) + .execute() ; - List<IntegerSolution> population = algorithm.getResult() ; - long computingTime = algorithmRunner.getComputingTime() ; + List<IntegerSolution> population = algorithm.getResult() ; + long computingTime = algorithmRunner.getComputingTime() ; - JMetalLogger.logger.info("Total execution time: " + computingTime + "ms"); - -// new SolutionListOutput(population) -// .setSeparator("\t") -// .setVarFileOutputContextDiscrete(new DefaultFileOutputContext("results/jMetal_VARDiscrete_WASFGADiscrete.tsv")) -// .setVarFileOutputContext(new DefaultFileOutputContext("results/jMetal_VAR_WASFGADiscrete.tsv")) -// .setFunFileOutputContext(new DefaultFileOutputContext("results/jMetal_FUN_WASFGADiscrete.tsv")) -// .print(); + JMetalLogger.logger.info("Total execution time: " + computingTime + "ms"); + + List<IntegerSolution> populationOrdered = new ArrayList<IntegerSolution>(); + boolean inserted = false; + + for (int i=0; i<population.size();i++) { + if (populationOrdered.isEmpty()) { + populationOrdered.add(population.get(i)); + } + else { + inserted = false; + for (int j=0; j<populationOrdered.size();j++) { + if(objectives.get(0).contains("cost")) { + if(Math.abs(populationOrdered.get(j).getObjective(0))>Math.abs(population.get(i).getObjective(0)) && inserted == false) { + populationOrdered.add(j,population.get(i)); + inserted = true; + } + }else { + if(Math.abs(populationOrdered.get(j).getObjective(0))<Math.abs(population.get(i).getObjective(0)) && inserted == false) { + populationOrdered.add(j,population.get(i)); + inserted = true; + } + } + + } + + if (inserted==false) { + populationOrdered.add(population.get(i)); + } + } + } + + IOPSolutionListOutput SLO = new IOPSolutionListOutput(problem,populationOrdered); + SLO.setSeparator("\t"); + SLO.setVarFileOutputContextDiscrete(new DefaultFileOutputContext("C:/W/results/jMetal_VAR_WASFGA_"+ System.currentTimeMillis() +".tsv")); + SLO.setVarFileOutputContext(new DefaultFileOutputContext("C:/W/results/jMetal_VAR_WASFGA_Solution_"+ System.currentTimeMillis() +".tsv")); + SLO.setFunFileOutputContext(new DefaultFileOutputContext("C:/W/results/jMetal_FUN_WASFGA_"+ System.currentTimeMillis() +".tsv")); + SLO.print(); + ArrayList<String> doml = SLO.generateDOMLDiscrete(problem.getObjectives()); + return doml; } } diff --git a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/problems/JMETAL_Problem.java b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/problems/JMETAL_Problem.java index f3963d4274846ee329a39f35649d143e0c06c496..7643c47a8e1b54cf6845877aea8c0434165502aa 100644 --- a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/problems/JMETAL_Problem.java +++ b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/problems/JMETAL_Problem.java @@ -34,7 +34,7 @@ public class JMETAL_Problem{ public void setMapOfElements() throws Exception { if (this.mapOfElements == null) { - this.mapOfElements = this.dataReaderService.parseCatalog(""); + this.mapOfElements = this.dataReaderService.parseCatalog("",""); } } diff --git a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/problems/JMETAL_ProblemDiscrete.java b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/problems/JMETAL_ProblemDiscrete.java index ac20525c712dfe56760a8164f75d55351c0504a0..4ad31f29914b3ffa55458f46ceff0c122cd6281b 100644 --- a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/problems/JMETAL_ProblemDiscrete.java +++ b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/problems/JMETAL_ProblemDiscrete.java @@ -13,10 +13,12 @@ package com.piacere.iop.optimizer.problems; import java.util.ArrayList; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import com.piacere.iop.optimizer.service.DataReaderService; +import com.piacere.iop.optimizer.service.OptimizerService; public class JMETAL_ProblemDiscrete{ @@ -25,10 +27,13 @@ public class JMETAL_ProblemDiscrete{ private Double minPerformance = Double.MIN_VALUE; private ArrayList<String> objectives; private String region; + private String provider; + private int[] memoryIntegerList; + public ArrayList<Integer> numVariables; private Map<String, Map<String, Map<String, String>>> mapOfElements = null; private DataReaderService dataReaderService; - public JMETAL_ProblemDiscrete(DataReaderService dataReaderService,Double maxCost, Double minAvailability, Double minPerformance, String region, ArrayList<String> objectives){ + public JMETAL_ProblemDiscrete(DataReaderService dataReaderService,Double maxCost, Double minAvailability, Double minPerformance, String region, String provider, ArrayList<String> objectives, ArrayList<Integer> nV, int[] mL){ this.dataReaderService = dataReaderService; // mapOfElements = reader.mapOfElements; this.maxCost = maxCost; @@ -36,6 +41,9 @@ public class JMETAL_ProblemDiscrete{ this.minPerformance = minPerformance; this.objectives = objectives; this.region = region; + this.provider = provider; + this.numVariables = nV; + this.memoryIntegerList = mL; } public Map<String, Map<String, Map<String, String>>> getMapOfElements() { @@ -44,17 +52,17 @@ public class JMETAL_ProblemDiscrete{ public void setMapOfElements() throws Exception { if (this.mapOfElements == null) { - this.mapOfElements = this.dataReaderService.parseCatalog(region); + this.mapOfElements = this.dataReaderService.parseCatalog(region,provider); } } - public void reduceMapOfElementsTo(String element) throws Exception { + public void reduceMapOfElementsTo(ArrayList<String> elements) throws Exception { if (this.mapOfElements == null) { - this.mapOfElements = this.dataReaderService.parseCatalog(region); + this.mapOfElements = this.dataReaderService.parseCatalog(region,provider); } ArrayList<String> keySet = new ArrayList<String>(); for (Entry<String, Map<String, Map<String, String>>> entry : this.mapOfElements.entrySet()) { - if (!entry.getKey().equals(element)) { + if (!elements.contains(entry.getKey())) { keySet.add(entry.getKey()); } } @@ -67,6 +75,7 @@ public class JMETAL_ProblemDiscrete{ public double[] evaluate(int[] X) throws Exception { setMapOfElements(); + boolean penalize = false; //transformar el X en un ArrayList ArrayList<String> solution = new ArrayList<String>(); @@ -74,30 +83,72 @@ public class JMETAL_ProblemDiscrete{ double[] result = new double[this.objectives.size()]; - if(this.objectives.size()==3) { - result[0] = this.calculateCost(mapOfElements, solution); - result[1] = -1*this.calculateAvailability(mapOfElements, solution); - result[2] = -1*this.calculatePerformance(mapOfElements, solution); - } - else if(this.objectives.size()==2) { - if(objectives.contains("cost")) { - result[0] = this.calculateCost(mapOfElements, solution); - if(objectives.contains("availability")) { - result[1] = -1*this.calculateAvailability(mapOfElements, solution); - }else { - result[1] = -1*this.calculatePerformance(mapOfElements, solution); + for(int i=0;i<this.objectives.size();i++) { + if(objectives.get(i).contains("cost")) { + result[i] = this.calculateCost(mapOfElements, solution); + }else if (objectives.get(i).contains("availability")) { + result[i] = -1*this.calculateAvailability(mapOfElements, solution); + }else if (objectives.get(i).contains("performance")) { + result[i] = -1*this.calculatePerformance(mapOfElements, solution); + } + } + + // Chequearemos la memoria en caso de que los requirements esten metidos + + if (this.memoryIntegerList!=null) { + penalize = this.checkMemory(mapOfElements,solution); + } + + //ESTO ESTA HECHO PARA CONTEMPLAR REQUIREMENTS QUE NO ESTAN ENTRE LOS OBJETIVOS + + if (penalize==true) { + result[0] = Double.MAX_VALUE; + } + + if(maxCost<Double.MAX_VALUE) { + if(this.calculateCost(mapOfElements, solution)==Double.MAX_VALUE) { + if(objectives.get(0).contains("cost")) { + result[0] = Double.MAX_VALUE; + }else if(objectives.get(0).contains("availability")) { + result[0] = Double.MIN_VALUE; + }else if(objectives.get(0).contains("performance")) { + result[0] = Double.MIN_VALUE; + } + } + }else if(minAvailability > Double.MIN_VALUE) { + if(this.calculateAvailability(mapOfElements, solution)==Double.MIN_VALUE) { + if(objectives.get(0).contains("cost")) { + result[0] = Double.MAX_VALUE; + }else if(objectives.get(0).contains("availability")) { + result[0] = Double.MIN_VALUE; + }else if(objectives.get(0).contains("performance")) { + result[0] = Double.MIN_VALUE; + } + } + }else if(minPerformance > Double.MIN_VALUE) { + if(this.calculatePerformance(mapOfElements, solution)==Double.MIN_VALUE) { + if(objectives.get(0).contains("cost")) { + result[0] = Double.MAX_VALUE; + }else if(objectives.get(0).contains("availability")) { + result[0] = Double.MIN_VALUE; + }else if(objectives.get(0).contains("performance")) { + result[0] = Double.MIN_VALUE; } - }else { - result[0] = -1*this.calculateAvailability(mapOfElements, solution); - result[1] = -1*this.calculatePerformance(mapOfElements, solution); } - }else if(this.objectives.size()==1) { - if(objectives.contains("cost")) { - result[0] = this.calculateCost(mapOfElements, solution); - }else if(objectives.contains("availability")) { - result[0] = -1*this.calculateAvailability(mapOfElements, solution); - }else{ - result[0] = -1*this.calculatePerformance(mapOfElements, solution); + } + + for (int i=0;i<solution.size();i++) { + for (int j=i+1;j<solution.size();j++) { + if (solution.get(i).equals(solution.get(j))) { + if(objectives.get(0).contains("cost")) { + result[0] = Double.MAX_VALUE; + }else if(objectives.get(0).contains("availability")) { + result[0] = Double.MIN_VALUE; + }else if(objectives.get(0).contains("performance")) { + result[0] = Double.MIN_VALUE; + } + + } } } @@ -106,12 +157,31 @@ public class JMETAL_ProblemDiscrete{ public double calculateCost(Map<String, Map<String, Map<String, String>>> mapOfElements, ArrayList<String> solution){ + ArrayList<Integer> cummulated_variables = new ArrayList<Integer>(); + int aux_cummulated_variables = 0; + int index_variable=0; + + for(int i=0; i<numVariables.size();i++) { + aux_cummulated_variables = aux_cummulated_variables + numVariables.get(i); + cummulated_variables.add(aux_cummulated_variables); + } + double cost = 0.0; Set<String> keySet = mapOfElements.keySet(); - for(int i=0; i<keySet.size();i++){ - cost = cost + Double.parseDouble(mapOfElements.get((String) keySet.toArray()[i]).get(solution.get(i)).get("Cost/Currency")); + for(int i=0; i<solution.size();i++){ + + for(int j=0;j<cummulated_variables.size();j++) { + if(i<cummulated_variables.get(j)) { + index_variable=j; + break; + } + } + + Map<String, String> map = mapOfElements.get((String) keySet.toArray()[index_variable]).get(solution.get(i)); + + cost = cost + Double.parseDouble(map.get("Cost/Currency")); } if(cost>maxCost) { @@ -124,21 +194,38 @@ public class JMETAL_ProblemDiscrete{ public double calculatePerformance(Map<String, Map<String, Map<String, String>>> mapOfElements, ArrayList<String> solution){ + ArrayList<Integer> cummulated_variables = new ArrayList<Integer>(); + int aux_cummulated_variables = 0; + int index_variable=0; + + for(int i=0; i<numVariables.size();i++) { + aux_cummulated_variables = aux_cummulated_variables + numVariables.get(i); + cummulated_variables.add(aux_cummulated_variables); + } + double performance = 0.0; Set<String> keySet = mapOfElements.keySet(); Set<String> keySet2; String performanceKey = "Performance"; - for(int i=0; i<keySet.size();i++){ - keySet2 = mapOfElements.get((String) keySet.toArray()[i]).get(solution.get(i)).keySet(); + for(int i=0; i<solution.size();i++){ + + for(int j=0;j<cummulated_variables.size();j++) { + if(i<cummulated_variables.get(j)) { + index_variable=j; + break; + } + } + + keySet2 = mapOfElements.get((String) keySet.toArray()[index_variable]).get(solution.get(i)).keySet(); for(int j=0; j<keySet2.size();j++){ String key = keySet2.toArray()[j].toString(); if (key.contains("Performance")){ performanceKey = (String) keySet2.toArray()[j]; } } - performance = performance + Double.parseDouble(mapOfElements.get((String) keySet.toArray()[i]).get(solution.get(i)).get(performanceKey)); + performance = performance + Double.parseDouble(mapOfElements.get((String) keySet.toArray()[index_variable]).get(solution.get(i)).get(performanceKey)); } if(performance<minPerformance) { @@ -151,26 +238,98 @@ public class JMETAL_ProblemDiscrete{ public double calculateAvailability(Map<String, Map<String, Map<String, String>>> mapOfElements, ArrayList<String> solution){ + ArrayList<Integer> cummulated_variables = new ArrayList<Integer>(); + int aux_cummulated_variables = 0; + int index_variable=0; + + for(int i=0; i<numVariables.size();i++) { + aux_cummulated_variables = aux_cummulated_variables + numVariables.get(i); + cummulated_variables.add(aux_cummulated_variables); + } + double availability = 0.0; Set<String> keySet = mapOfElements.keySet(); - for(int i=0; i<keySet.size();i++){ - availability = availability + Double.parseDouble(mapOfElements.get((String) keySet.toArray()[i]).get(solution.get(i)).get("Availability")); + for(int i=0; i<solution.size();i++){ + + for(int j=0;j<cummulated_variables.size();j++) { + if(i<cummulated_variables.get(j)) { + index_variable=j; + break; + } + } + + availability = availability + Double.parseDouble(mapOfElements.get((String) keySet.toArray()[index_variable]).get(solution.get(i)).get("Availability")); } - if(availability/3<minAvailability) { + if(availability/solution.size()<minAvailability) { availability = Double.MIN_VALUE; }else { - availability = availability/3; + availability = availability/solution.size(); } return availability; } + public Boolean checkMemory(Map<String, Map<String, Map<String, String>>> mapOfElements, ArrayList<String> solution){ + + Double auxMemory; + + for(int i=0; i<solution.size();i++){ + + Map<String, String> map = mapOfElements.get("Virtual Machine").get(solution.get(i)); + + auxMemory = Double.parseDouble(map.get("Memory")); + + if(auxMemory>this.memoryIntegerList[i]) { + return true; + } + + } + + return false; + + } + public ArrayList<String> translateXdiscrete(int[] X) throws Exception{ setMapOfElements(); + + ArrayList<Integer> cummulated_variables = new ArrayList<Integer>(); + int aux_cummulated_variables = 0; + int index_variable=0; + + for(int i=0; i<numVariables.size();i++) { + aux_cummulated_variables = aux_cummulated_variables + numVariables.get(i); + cummulated_variables.add(aux_cummulated_variables); + } + + ArrayList<String> solution = new ArrayList<String>(); + + Set<String> keySet = mapOfElements.keySet(); + + for(int i=0; i<X.length;i++){ + + for(int j=0;j<cummulated_variables.size();j++) { + if(i<cummulated_variables.get(j)) { + index_variable=j; + break; + } + } + + Set<String> keySet2 = mapOfElements.get((String) keySet.toArray()[index_variable]).keySet(); + int index = (int) X[i]; + + solution.add((String) keySet2.toArray()[index]); + } + + return solution; + + } + + public ArrayList<String> translateXdiscrete_forSolution(int[] X) throws Exception{ + setMapOfElements(); ArrayList<String> solution = new ArrayList<String>(); @@ -180,13 +339,299 @@ public class JMETAL_ProblemDiscrete{ Set<String> keySet2 = mapOfElements.get((String) keySet.toArray()[i]).keySet(); int index = (int) X[i]; - solution.add((String) keySet2.toArray()[index]); + solution.add("\""+(String) keySet2.toArray()[index]+"\""); } return solution; } + public String getConcretizations(int[] X) throws Exception{ + + setMapOfElements(); + ArrayList<String[]> infraElements = OptimizerService.infrastructureElements; + int[] elementstoAssign = new int[3]; + int[] elementsAssigned = new int[3]; + + for(int i=0;i<elementstoAssign.length;i++) { + elementstoAssign[i] = 0; + elementsAssigned[i] = 0; + } + + for(int i=0;i<infraElements.size();i++) { + if(infraElements.get(i)[0].equals("vm")) { + elementstoAssign[0] = elementstoAssign[0]+1; + } + } + + String solution = ""; + String elementName = ""; + String name = ""; + String parameter = ""; + String value = ""; + + ArrayList<String> variables = new ArrayList<String>(); + + for (int i=0;i<this.numVariables.size();i++) { + if(i==0) { + for(int j=0;j<this.numVariables.get(i);j++) { + variables.add("Storage"); + } + } + else if(i==1) { + for(int j=0;j<this.numVariables.get(i);j++) { + variables.add("Database"); + } + } + else if(i==2) { + for(int j=0;j<this.numVariables.get(i);j++) { + variables.add("Virtual Machine"); + } + } + } + + Set<String> keySet = mapOfElements.keySet(); + + for(int i=0; i<variables.size(); i++) { + + int elementKey=0; + + if(variables.get(i).contains("Storage")) { + elementKey=0; + }else if(variables.get(i).contains("Database")) { + elementKey=1; + }else if(variables.get(i).contains("Machine")) { + elementKey=2; + } + + elementName = (String) keySet.toArray()[elementKey]; + Set<String> keySet2 = mapOfElements.get(elementName).keySet(); + int index = (int) X[i]; + + name = (String) keySet2.toArray()[index]; + + Map<String, String> element = mapOfElements.get((String) keySet.toArray()[elementKey]).get((String) keySet2.toArray()[index]); + + name = name.replace(".","_"); + + if(elementName.contains("Virtual Machine")) { + solution = solution.concat("\t\t\tvm " + name + "{\n\t\t\t\tproperties {\n"); + solution = solution.concat("\t\t\t\t\tvm_flavor = \"" + name + "\";\n"); + solution = solution.concat("\t\t\t\t\tvm_name = \"" + name + "\";\n"); + Set<String> keySet3 = element.keySet(); + + for(int j=0; j<keySet3.size();j++){ + if(!element.get((String) keySet3.toArray()[j]).equals("")) { + parameter = (String) keySet3.toArray()[j]; + if(this.isNumber(element.get((String) keySet3.toArray()[j]))) { + value = element.get((String) keySet3.toArray()[j]); + }else { + value = "\"" + element.get((String) keySet3.toArray()[j]) + "\""; + } + + parameter = parameter.replace(":",""); + value = value.replace(":",""); + parameter = parameter.replace(" ","_"); + value = value.replace(" ","_"); + parameter = parameter.replace("/","_"); + value = value.replace("/","_"); + parameter = parameter.replace("__","_"); + value = value.replace("__","_"); + parameter = parameter.replace("(",""); + value = value.replace("(","_"); + parameter = parameter.replace(")",""); + value = value.replace(")",""); + parameter = parameter.replace(".","_"); + + if(parameter.contains("Public")) { + solution = solution.concat("\t\t\t\t\tvm_public_IP_type = " + value + ";\n"); + }else if(parameter.contains("Provider")) { + solution = solution.concat("\t\t\t\t\tvm_provider_OU = " + value + ";\n"); + }else { + solution = solution.concat("\t\t\t\t\tvm_"+ parameter + " = " + value + ";\n"); + } + } + } + //solution = solution.concat("\t\t\t\t}maps vm1\n"); + solution = solution.concat("\t\t\t\t}\n"); + + int vm_visited = 0; + boolean checked = false; + if(elementsAssigned[0]<elementstoAssign[0]){ + for(int k=0;k<infraElements.size();k++) { + if(infraElements.get(k)[0].equals("vm")) { + if (vm_visited == elementsAssigned[0] && checked==false) { + solution = solution.concat("\t\t\t\tmaps "+ infraElements.get(k)[1] + "\n"); + elementsAssigned[0] = elementsAssigned[0]+1; + checked = true; + }else { + vm_visited = vm_visited+1; + } + + } + } + } + + solution = solution.concat("\t\t\t}\n"); + + }else if(elementName.contains("Database")) { + solution = solution.concat("\t\t\tdbms " + name + " {\n\t\t\t\tproperties {\n"); + solution = solution.concat("\t\t\t\t\tdb_flavor = \"" + name + "\";\n"); + solution = solution.concat("\t\t\t\t\tdb_name = \"" + name + "\";\n"); + Set<String> keySet3 = element.keySet(); + + for(int j=0; j<keySet3.size();j++){ + parameter = (String) keySet3.toArray()[j]; + if(this.isNumber(element.get((String) keySet3.toArray()[j]))) { + value = element.get((String) keySet3.toArray()[j]); + }else { + value = "\"" + element.get((String) keySet3.toArray()[j]) + "\""; + } + + parameter = parameter.replace(":",""); + value = value.replace(":",""); + parameter = parameter.replace(" ","_"); + value = value.replace(" ","_"); + parameter = parameter.replace("-",""); + value = value.replace("-",""); + parameter = parameter.replace("/","_"); + value = value.replace("/","_"); + parameter = parameter.replace("(",""); + value = value.replace("(","_"); + parameter = parameter.replace(")",""); + value = value.replace(")",""); + parameter = parameter.replace(".","_"); + + + if(!element.get((String) keySet3.toArray()[j]).equals("")) { + if(parameter.contains("Provider")) { + solution = solution.concat("\t\t\t\t\tdb_provider_OU = " + value + ";\n"); + }else { + solution = solution.concat("\t\t\t\t\tdb_"+ (String) parameter + " = " + value + ";\n"); + } + } + } + //solution = solution.concat("\t\t\t\t}maps db1\n"); + solution = solution.concat("\t\t\t\t}\n"); + solution = solution.concat("\t\t\t}\n"); + + }else if(elementName.contains("Storage")) { + solution = solution.concat("\t\t\tstorage " + name + " {\n\t\t\t\tproperties {\n"); + solution = solution.concat("\t\t\t\t\tst_flavor = \"" + name + "\";\n"); + solution = solution.concat("\t\t\t\t\tst_name = \"" + name + "\";\n"); + Set<String> keySet3 = element.keySet(); + + for(int j=0; j<keySet3.size();j++){ + if(!element.get((String) keySet3.toArray()[j]).equals("")) { + parameter = (String) keySet3.toArray()[j]; + + if(this.isNumber(element.get((String) keySet3.toArray()[j]))) { + value = element.get((String) keySet3.toArray()[j]); + }else { + value = "\"" + element.get((String) keySet3.toArray()[j]) + "\""; + } + + parameter = parameter.replace(":",""); + value = value.replace(":",""); + parameter = parameter.replace(" ","_"); + value = value.replace(" ","_"); + parameter = parameter.replace("-",""); + value = value.replace("-",""); + parameter = parameter.replace("/","_"); + value = value.replace("/","_"); + parameter = parameter.replace("__","_"); + value = value.replace("__","_"); + parameter = parameter.replace("(",""); + value = value.replace("(","_"); + parameter = parameter.replace(")",""); + value = value.replace(")",""); + parameter = parameter.replace(".","_"); + + if(parameter.contains("Provider")) { + solution = solution.concat("\t\t\t\t\tst_provider_OU = " + value + ";\n"); + }else{ + solution = solution.concat("\t\t\t\t\tst_"+ (String) parameter + " = " + value + ";\n"); + } + } + } + //solution = solution.concat("\t\t\t\t}maps st1\n"); + solution = solution.concat("\t\t\t\t}\n"); + solution = solution.concat("\t\t\t}\n"); + + } + } + + boolean inserted=false; + for(int k=0;k<infraElements.size();k++) { + if(infraElements.get(k)[0].equals("net") && inserted==false) { + //inserted = true; + solution = solution.concat("\t\t\tnet opt_network_"+ infraElements.get(k)[1] + "{\n"); + solution = solution.concat("\t\t\t\tmaps " + infraElements.get(k)[1] + "\n"); + solution = solution.concat("\t\t\t}\n"); + } + } + + return solution; + + } + + public void vitaminateCatalog() { + Map<String, Map<String, Map<String, String>>> auxMapOfElements = new HashMap<String, Map<String, Map<String, String>>>(); + Map<String, Map<String, String>> auxMapOfElements2 = new HashMap<String, Map<String, String>>(); + + HashMap<String, String> element = null; + System.out.println("LET'S EXTEND THE IEC"); + for (String key : this.mapOfElements.keySet()) { + auxMapOfElements2 = new HashMap<String, Map<String, String>>(); + for (String key2 : this.mapOfElements.get(key).keySet()) { + //FIRST ELEMENT + element = (HashMap<String, String>) this.mapOfElements.get(key).get(key2); + element = (HashMap<String, String>) element.clone(); + if(key.equals("Storage")) { + element.put("Availability", String.valueOf(Double.parseDouble(element.get("Availability"))*0.95)); + element.put("Request - Response time: Storage Performance", String.valueOf(Double.parseDouble(element.get("Request - Response time: Storage Performance"))+2)); + element.put("Cost/Currency", String.valueOf(Double.parseDouble(element.get("Cost/Currency"))+20)); + }else if (key.equals("Database")) { + element.put("Availability", String.valueOf(Double.parseDouble(element.get("Availability"))*0.95)); + element.put("Transaction Unit (DTU): Database Performance", String.valueOf(Double.parseDouble(element.get("Transaction Unit (DTU): Database Performance"))+2)); + element.put("Cost/Currency", String.valueOf(Double.parseDouble(element.get("Cost/Currency"))+20)); + }else if (key.equals("Virtual Machine")) { + element.put("Availability", String.valueOf(Double.parseDouble(element.get("Availability"))*0.95)); + element.put("Response time: Virtual Machine Performance", String.valueOf(Double.parseDouble(element.get("Response time: Virtual Machine Performance"))+2)); + element.put("Cost/Currency", String.valueOf(Double.parseDouble(element.get("Cost/Currency"))+20)); + } + + auxMapOfElements2.put(key2+"-2", element); + + //FIRST ELEMENT + + element = (HashMap<String, String>) this.mapOfElements.get(key).get(key2); + element = (HashMap<String, String>) element.clone(); + if(key.equals("Storage")) { + element.put("Availability", String.valueOf(Double.parseDouble(element.get("Availability"))*0.98)); + element.put("Request - Response time: Storage Performance", String.valueOf(Double.parseDouble(element.get("Request - Response time: Storage Performance"))+5)); + element.put("Cost/Currency", String.valueOf(Double.parseDouble(element.get("Cost/Currency"))+40)); + }else if (key.equals("Database")) { + element.put("Availability", String.valueOf(Double.parseDouble(element.get("Availability"))*0.98)); + element.put("Transaction Unit (DTU): Database Performance", String.valueOf(Double.parseDouble(element.get("Transaction Unit (DTU): Database Performance"))+5)); + element.put("Cost/Currency", String.valueOf(Double.parseDouble(element.get("Cost/Currency"))+40)); + }else if (key.equals("Virtual Machine")) { + element.put("Availability", String.valueOf(Double.parseDouble(element.get("Availability"))*0.98)); + element.put("Response time: Virtual Machine Performance", String.valueOf(Double.parseDouble(element.get("Response time: Virtual Machine Performance"))+5)); + element.put("Cost/Currency", String.valueOf(Double.parseDouble(element.get("Cost/Currency"))+40)); + } + + auxMapOfElements2.put(key2+"-3", element); + + + } + //auxMapOfElements.put(key, auxMapOfElements2); + this.mapOfElements.get(key).putAll(auxMapOfElements2); + } + + System.out.println("EXTENSION FINISHED"); + } + public ArrayList<String> getObjectives() { return objectives; } @@ -194,4 +639,14 @@ public class JMETAL_ProblemDiscrete{ public void setObjectives(ArrayList<String> objectives) { this.objectives = objectives; } + + public static boolean isNumber(String str) { + try { + double v = Double.parseDouble(str); + return true; + } catch (NumberFormatException nfe) { + } + return false; + } + } diff --git a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/problems/JMETAL_ProblemJMDiscrete.java b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/problems/JMETAL_ProblemJMDiscrete.java index 3382c0f7678db3a00bc5f15e48bdf5dad55e64e5..029330d62cb73c8f233d0e7ce52de55d750ac113 100644 --- a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/problems/JMETAL_ProblemJMDiscrete.java +++ b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/problems/JMETAL_ProblemJMDiscrete.java @@ -24,10 +24,18 @@ public class JMETAL_ProblemJMDiscrete extends AbstractIntegerProblem { public JMETAL_ProblemJMDiscrete(JMETAL_ProblemDiscrete problem) { this.problem = problem; this.setName("Problem"); + int variables = 0; Set<String> keySet = problem.getMapOfElements().keySet(); - this.setNumberOfVariables(keySet.size()); + for(int i=0;i<problem.numVariables.size();i++){ + + variables = variables + problem.numVariables.get(i); + + } + + //this.setNumberOfVariables(keySet.size()); + this.setNumberOfVariables(variables); this.setNumberOfObjectives(problem.getObjectives().size()); this.setNumberOfConstraints(0); @@ -35,11 +43,35 @@ public class JMETAL_ProblemJMDiscrete extends AbstractIntegerProblem { List<Integer> lowerLimit = new ArrayList<Integer>(); List<Integer> upperLimit = new ArrayList<Integer>(); - for(int i=0; i<keySet.size();i++){ + ArrayList<Integer> cummulated_variables = new ArrayList<Integer>(); + int aux_cummulated_variables = 0; + int index=0; + + for(int i=0; i<problem.numVariables.size();i++) { + aux_cummulated_variables = aux_cummulated_variables + problem.numVariables.get(i); + cummulated_variables.add(aux_cummulated_variables); + } + + for(int i=0; i<variables;i++){ + + for(int j=0;j<cummulated_variables.size();j++) { + if(i<cummulated_variables.get(j)) { + index=j; + break; + } + } + + Set<String> keySet2 = problem.getMapOfElements().get((String) keySet.toArray()[index]).keySet(); + lowerLimit.add(0); + upperLimit.add(keySet2.size()-1); + } + + /*for(int i=0; i<keySet.size();i++){ Set<String> keySet2 = problem.getMapOfElements().get((String) keySet.toArray()[i]).keySet(); lowerLimit.add(0); upperLimit.add(keySet2.size()-1); - } + }*/ + setLowerLimit(lowerLimit); setUpperLimit(upperLimit); } diff --git a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/service/CatalogService.java b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/service/CatalogService.java index 98b00f30623958a123be669892b8b160983da367..add060cad70cee23b4c634c03ba9f760802bd0e7 100644 --- a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/service/CatalogService.java +++ b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/service/CatalogService.java @@ -7,6 +7,7 @@ import java.io.FileReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; @@ -166,7 +167,7 @@ public JSONArray getStaticCatalog() throws FileNotFoundException, Exception { JSONParser parser = new JSONParser(); Object unitsObj; try { - unitsObj = parser.parse(new FileReader(file)); + unitsObj = parser.parse(new FileReader(file, StandardCharsets.UTF_8)); //unitsObj = parser.parse(file); } catch (Exception e) { throw new Exception("Error parsing static catalog data"); diff --git a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/service/DataReaderService.java b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/service/DataReaderService.java index e6f73c55fd7832666e0b814e82c4f5fce23f30bf..1fce0d7357d8bd12292e52c916af59d65d3d4ee7 100644 --- a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/service/DataReaderService.java +++ b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/service/DataReaderService.java @@ -19,7 +19,7 @@ public class DataReaderService { this.catalogService = catalogService; } - public Map<String, Map<String, Map<String, String>>> parseCatalog(String region) throws Exception { + public Map<String, Map<String, Map<String, String>>> parseCatalog(String region,String provider) throws Exception { Map<String, Map<String, Map<String, String>>> mapOfElements = new HashMap<String, Map<String, Map<String, String>>>(); JSONArray catalogJsonArray = null; try { @@ -96,6 +96,25 @@ public class DataReaderService { } } } + + if (provider==null) { + provider = "AWS"; + } + + for(String k : mapOfElements.keySet()) { + Map<String, Map<String, String>> m1 = mapOfElements.get(k); + + for(String k1 : m1.keySet()) { + Map<String, String> l1 = m1.get(k1); + + if(!l1.get("Provider").equals(provider)) { + elementsRemove.add(k1); + } + } + for(int i=0;i<elementsRemove.size();i++) { + m1.remove(elementsRemove.get(i)); + } + } return mapOfElements; } diff --git a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/service/OptimizerService.java b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/service/OptimizerService.java index f158a3d06d8e60f1228e2011977cb88892e4e53b..30172fd8f07c3a5a75e02cc033879362919ae43d 100644 --- a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/service/OptimizerService.java +++ b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/service/OptimizerService.java @@ -9,7 +9,16 @@ import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import org.springframework.stereotype.Service; + +import com.piacere.iop.optimizer.algorithm.jmetal.discrete.GWASFGADiscreteOptRunner; +import com.piacere.iop.optimizer.algorithm.jmetal.discrete.MOCellDiscreteOptRunner; +import com.piacere.iop.optimizer.algorithm.jmetal.discrete.MOMBI2DiscreteOptRunner; +import com.piacere.iop.optimizer.algorithm.jmetal.discrete.MOMBIDiscreteOptRunner; import com.piacere.iop.optimizer.algorithm.jmetal.discrete.NSGAIIDiscreteOptRunner; +import com.piacere.iop.optimizer.algorithm.jmetal.discrete.NSGAIIIDiscreteOptRunner; +import com.piacere.iop.optimizer.algorithm.jmetal.discrete.SMSEMOADiscreteOptRunner; +import com.piacere.iop.optimizer.algorithm.jmetal.discrete.SPEA2DiscreteOptRunner; +import com.piacere.iop.optimizer.algorithm.jmetal.discrete.WASFGADiscreteOptRunner; import com.piacere.iop.optimizer.problems.JMETAL_ProblemDiscrete; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; @@ -33,6 +42,8 @@ public class OptimizerService { private DataReaderService dataReaderService; private Boolean doml = true; private Boolean parser = true; + public static String provider=null; + public static ArrayList<String[]> infrastructureElements = new ArrayList<String[]>(); public OptimizerService(DataReaderService dataReaderService) { super(); @@ -45,6 +56,10 @@ public class OptimizerService { Double availability=Double.MIN_VALUE; Double performance = Double.MIN_VALUE; String region=null; + int[] memoryIntegerList = null; + int VMamount = 0; + int STamount = 0; + int DBamount = 0; ArrayList<String> objectivesList = new ArrayList<String>(); @@ -110,62 +125,418 @@ public class OptimizerService { }*/ }else { - String[] arr = inputData.split(" "); + String[] arr = inputData.split("\n"); Boolean objectives = false; Boolean requirements = false; + Boolean elements = false; + String[] elementList; + String[] memoryList; for(int i=0;i<arr.length;i++) { String ss = arr[i]; //objectives - if(ss.contains("objectives")) + if(ss.contains("objectives") && ss.contains("*")==false) objectives = true; if(objectives==true) { - if(ss.contains("cost")) { - objectivesList.add("cost"); - }else if(ss.contains("availability")) { - objectivesList.add("availability"); - }else if(ss.contains("performance")) { - objectivesList.add("performance"); + if(ss.contains("cost") && ss.contains("*")==false) { + if(!objectivesList.contains("cost")) { + objectivesList.add("cost"); + } + + }else if(ss.contains("availability") && ss.contains("*")==false) { + if(!objectivesList.contains("availability")) { + objectivesList.add("availability"); + } + + }else if(ss.contains("performance") && ss.contains("*")==false) { + if(!objectivesList.contains("performance")) { + objectivesList.add("performance"); + } } } - if(objectives==true && ss.contains("}")) { + if(objectives==true && ss.contains("}") && ss.contains("*")==false) { objectives = false; } //requirements - if(ss.contains("requirements")) { + if(ss.contains("requirements") && ss.contains("*")==false) { requirements = true; + objectives = false; } - if(requirements==true && ss.contains("}")) { - requirements = false; - } - if(requirements==true && ss.contains("availability") && ss.contains(";")) { - ss = arr[i-2]; + + if(requirements==true && ss.contains("availability") && ss.contains("=") && ss.contains("*")==false) { + ss = ss.substring(ss.indexOf("=")+1,ss.indexOf("%")); availability = Double.valueOf(ss); } - if(requirements==true && ss.contains("performance") && ss.contains(";")) { - ss = arr[i-2]; + if(requirements==true && ss.contains("performance") && ss.contains("=") && ss.contains("*")==false) { + ss = ss.substring(ss.indexOf("=")+1,ss.indexOf("%")); performance = Double.valueOf(ss); } - if(requirements==true && ss.contains("cost") && ss.contains(";")) { - ss = arr[i-2]; + if(requirements==true && ss.contains("cost") && ss.contains("=") && ss.contains("*")==false) { + ss = ss.substring(ss.indexOf("=")+1,ss.indexOf("m")-2); cost = Double.valueOf(ss); } - if(requirements==true && ss.contains("region") && ss.contains(";")) { - ss = arr[i-2]; - ss = ss.substring(ss.indexOf("\"")+1); - ss = ss.substring(0,ss.indexOf("\"")); - region = ss; + if(requirements==true && ss.contains("region") && ss.contains("=") && ss.contains("*")==false) { + ss = ss.substring(ss.indexOf("s")+3,ss.indexOf("=")-2); + if(ss.equals("00EU")) { + region = "Europe"; + }else { + region = ss; + } + } + if(requirements==true && ss.contains("provider") && ss.contains("=") && ss.contains("*")==false) { + ss = ss.substring(ss.indexOf("s")+3,ss.indexOf("=")-2); + if(ss.equals("OPEN")) { + provider = "openstack"; + } + else if(ss.equals("AMAZ")) { + provider = "aws"; + }else { + provider = ss; + } } + if(requirements==true && ss.contains("elements") && ss.contains("=>") && ss.contains("*")==false) { + ss = ss.substring(ss.indexOf(">")+1,ss.length()); + ss.replace("\"", ""); + elementList = ss.split(","); + for(int j=0;j<elementList.length;j++){ + if(elementList[j].contains("VM")) { + VMamount = VMamount+1; + }else if(elementList[j].contains("Storage") || elementList[j].contains("storage")) { + STamount = STamount+1; + }else if(elementList[j].contains("DB")) { + DBamount = DBamount+1; + } + } + } + + if(requirements==true && ss.contains("max_VM_memory") && ss.contains("=>") && ss.contains("*")==false) { + ss = ss.substring(ss.indexOf(">")+1,ss.length()); + ss.replace("\"", ""); + memoryList = ss.split(","); + memoryIntegerList = new int[memoryList.length]; + for(int j=0;j<memoryList.length;j++){ + memoryIntegerList[j] = Integer.parseInt(memoryList[j].replace(" ","").replace(";", "").replace("\"", "").replace("\r", "")); + } + } } } - JMETAL_ProblemDiscrete p = new JMETAL_ProblemDiscrete(this.dataReaderService,cost,availability,performance,region,objectivesList); + if(VMamount==0 && STamount==0 && DBamount==0) { + STamount = 1; + DBamount = 1; + VMamount = 1; + } + + ArrayList<Integer> numVariables = new ArrayList<Integer>(); + numVariables.add(STamount); + numVariables.add(DBamount); + numVariables.add(VMamount); + + if(provider==null){ + provider="aws"; + } + + JMETAL_ProblemDiscrete p = new JMETAL_ProblemDiscrete(this.dataReaderService,cost,availability,performance,region,provider,objectivesList,numVariables,memoryIntegerList); p.setMapOfElements(); - p.reduceMapOfElementsTo("Virtual Machine"); - System.out.println("Running NSGA-II Opt") ; - JSONObject json= new NSGAIIDiscreteOptRunner(p).run(); + //p.vitaminateCatalog(); + ArrayList<String> elements = new ArrayList<String>(); + //elements.add("Virtual Machine"); + //elements.add("Storage"); + //p.reduceMapOfElementsTo(elements); + + //JSONObject json= new NSGAIIDiscreteOptRunner(p).runJSON(); + + ArrayList<String> DOMLOutput = new ArrayList<String>(); + + infrastructureElements = this.checkElementsConcretizations(inputData); + + if(objectivesList.size()>2) { + System.out.println("Running NSGA-III Opt") ; + DOMLOutput = new NSGAIIDiscreteOptRunner(p).runDOML(objectivesList); + /*System.out.println("Running NSGA-II Opt") ; + DOMLOutput = new NSGAIIDiscreteOptRunner(p).runDOML(objectivesList); + System.out.println("Running GWASFGA Opt") ; + DOMLOutput = new GWASFGADiscreteOptRunner(p).runDOML(objectivesList); + System.out.println("Running WASFGA Opt") ; + DOMLOutput = new WASFGADiscreteOptRunner(p).runDOML(objectivesList); + System.out.println("Running MoCell Opt") ; + DOMLOutput = new MOCellDiscreteOptRunner(p).runDOML(objectivesList); + System.out.println("Running SMSEMOA Opt") ; + DOMLOutput = new SMSEMOADiscreteOptRunner(p).runDOML(objectivesList); + System.out.println("Running MOMBI Opt") ; + DOMLOutput = new MOMBIDiscreteOptRunner(p).runDOML(objectivesList); + System.out.println("Running MOMBI2 Opt") ; + DOMLOutput = new MOMBI2DiscreteOptRunner(p).runDOML(objectivesList); + System.out.println("Running SPEA2 Opt") ; + DOMLOutput = new SPEA2DiscreteOptRunner(p).runDOML(objectivesList);*/ + }else { + System.out.println("Running NSGA-II Opt") ; + DOMLOutput = new NSGAIIDiscreteOptRunner(p).runDOML(objectivesList); + /*System.out.println("Running NSGA-III Opt") ; + DOMLOutput = new NSGAIIIDiscreteOptRunner(p).runDOML(objectivesList); + System.out.println("Running GWASFGA Opt") ; + DOMLOutput = new GWASFGADiscreteOptRunner(p).runDOML(objectivesList); + System.out.println("Running WASFGA Opt") ; + DOMLOutput = new WASFGADiscreteOptRunner(p).runDOML(objectivesList); + System.out.println("Running MoCell Opt") ; + DOMLOutput = new MOCellDiscreteOptRunner(p).runDOML(objectivesList); + System.out.println("Running SMSEMOA Opt") ; + DOMLOutput = new SMSEMOADiscreteOptRunner(p).runDOML(objectivesList); + System.out.println("Running MOMBI Opt") ; + DOMLOutput = new MOMBIDiscreteOptRunner(p).runDOML(objectivesList); + System.out.println("Running MOMBI2 Opt") ; + DOMLOutput = new MOMBI2DiscreteOptRunner(p).runDOML(objectivesList); + System.out.println("Running SPEA2 Opt") ; + DOMLOutput = new SPEA2DiscreteOptRunner(p).runDOML(objectivesList);*/ + } + + int k = inputData.length()-1; + char chara = inputData.charAt(k); + + while (chara!='}') { + k = k-1; + chara = inputData.charAt(k); + } + + //String DOMLSolution = inputData.substring(0, k).concat(DOMLOutput.get(0)).concat("}"); + String DOMLSolution = this.introduceSolutionsOutputDOML(inputData,DOMLOutput.get(0)); - return json.toJSONString(); + String[] arr = DOMLSolution.split("\n"); + String concatSolutionConcretizations = ""; + String solution = ""; + Boolean concretizations = false; + Boolean introduced = false; + for(int i=0;i<arr.length;i++) { + String ss = arr[i]; + + //objectives + if(ss.contains("concretizations")){ + concretizations = true; + } + if(concretizations == true && ss.contains("active") && introduced==false) { + concatSolutionConcretizations = DOMLOutput.get(1); + solution = solution.concat(concatSolutionConcretizations).concat(" "); + introduced = true; + //ss = ss.replace("con_infra", "con_infra2"); + } + + if(concretizations == true && ss.contains("active") && !ss.contains("//") && !ss.contains("*")) { + ss = "\tactive opt_infra1\r"; + } + + solution = solution.concat(ss).concat("\n"); + } + + if (concretizations == false) { + concatSolutionConcretizations = "\nconcretizations {" + DOMLOutput.get(1) + "\topt_infra1\n}"; + DOMLSolution = DOMLSolution.concat(concatSolutionConcretizations); + }else { + DOMLSolution = solution; + } + + if (DOMLOutput.get(0) == "") { + return null; + } + + return DOMLSolution; + + } + + public boolean checkOptimization(String doml) { + + String[] arr = doml.split("\n"); + for(int i=0;i<arr.length;i++) { + String ss = arr[i]; + //objectives + if(ss.contains("optimization opt") && ss.contains("*")==false) + return true; + } + + return false; } + + public boolean checkBadObjectives(String doml) { + + + String[] arr = doml.split("\n"); + Boolean objectives = false; + for(int i=0;i<arr.length;i++) { + String ss = arr[i]; + //objectives + if(objectives==true && ss.contains("}") && ss.contains("*")==false) { + objectives = false; + } + if(objectives==true && !ss.isBlank()) { + if(!ss.contains("\"cost\"") && !ss.contains("\"availability\"") && !ss.contains("\"performance\"") && ss.contains("*")==false) { + return false; + } + } + if(ss.contains("objectives") && ss.contains("*")==false) + objectives = true; + } + + return true; + + } + + public boolean checkEmptyObjectives(String doml) { + ArrayList<String> objectivesList = new ArrayList<String>(); + + String[] arr = doml.split("\n"); + Boolean objectives = false; + for(int i=0;i<arr.length;i++) { + String ss = arr[i]; + //objectives + if(ss.contains("objectives") && ss.contains("*")==false) + objectives = true; + if(objectives==true && !ss.isBlank()) { + if(ss.contains("cost") && ss.contains("*")==false) { + if(!objectivesList.contains("cost")) { + objectivesList.add("cost"); + } + + }else if(ss.contains("availability") && ss.contains("*")==false) { + if(!objectivesList.contains("availability")) { + objectivesList.add("availability"); + } + + }else if(ss.contains("performance") && ss.contains("*")==false) { + if(!objectivesList.contains("performance")) { + objectivesList.add("performance"); + } + } + } + if(objectives==true && ss.contains("}") && ss.contains("*")==false) { + objectives = false; + } + } + + if(objectivesList.size()==0) { + return true; + }else { + return false; + } + } + + public boolean checkRequirements(String doml) { + + String[] arr = doml.split("\n"); + Boolean objectives = false; + Boolean requirements = false; + for(int i=0;i<arr.length;i++) { + String ss = arr[i]; + + if(ss.contains("objectives") && ss.contains("*")==false) + objectives = true; + + if(requirements==true && ss.contains("}") && ss.contains("*")==false) { + requirements = false; + objectives = false; + } + + + if(requirements==true && !ss.isBlank()) { + if(!ss.contains("cost") && !ss.contains("max_VM_memory") && !ss.contains("availability") && !ss.contains("performance") && !ss.contains("region") && !ss.contains("provider") && !ss.contains("elements") && ss.contains("*")==false) { + return false; + } + } + + //requirements + if(ss.contains("nonfunctional_requirements") && objectives==true && ss.contains("*")==false) { + requirements = true; + } + } + return true; + } + + public boolean checkElements(String doml) { + + String[] arr = doml.split("\n"); + Boolean requirements = false; + for(int i=0;i<arr.length;i++) { + String ss = arr[i]; + String[] elementList; + if(requirements==true && ss.contains("elements") && ss.contains("*")==false) { + ss = ss.substring(ss.indexOf(">")+1,ss.length()); + ss.replace("\"", ""); + elementList = ss.split(","); + for(int j=0;j<elementList.length;j++){ + if(!elementList[j].contains("VM") && !elementList[j].contains("Storage") && !elementList[j].contains("storage") && !elementList[j].contains("DB")) { + return false; + } + } + } + //requirements + if(ss.contains("nonfunctional_requirements")) { + requirements = true; + } + } + return true; + } + + public String introduceSolutionsOutputDOML(String doml,String DOMLOutput) { + + String[] arr = doml.split("\n"); + String solution = ""; + Boolean objectives = false; + Boolean requirements = false; + for(int i=0;i<arr.length;i++) { + String ss = arr[i]; + + if(ss.contains("objectives")) + objectives = true; + + if(requirements==true && ss.contains("}")) { + solution = solution.concat(ss).concat("\n"); + solution = solution.concat(DOMLOutput).concat("\n"); + requirements = false; + }else { + solution = solution.concat(ss).concat("\n"); + } + + if(ss.contains("nonfunctional_requirements") && objectives==true) { + requirements=true; + } + + } + return solution; + } + + public ArrayList<String[]> checkElementsConcretizations(String doml){ + + String[] arr = doml.split("\n"); + String[] auxElement = new String[2]; + ArrayList<String[]> solutions = new ArrayList<String[]>(); + boolean infrastructure = false; + for(int i=0;i<arr.length;i++) { + String ss = arr[i]; + + if(ss.contains("infrastructure") && ss.contains("{") && ss.contains("*")==false && ss.contains("concrete_infrastructure")==false) + infrastructure = true; + + if(infrastructure==true && ss.contains("vm ") && ss.contains("{") && ss.contains("*")==false && ss.contains("host")==false) { + auxElement = new String[2]; + auxElement[0] = "vm"; + auxElement[1] = ss.substring(ss.indexOf("m")+2,ss.indexOf("{")-1); + solutions.add(auxElement); + + } + if(infrastructure==true && ss.contains("net ") && ss.contains("{") && ss.contains("*")==false && ss.contains("subnet")==false) { + auxElement = new String[2]; + auxElement[0] = "net"; + auxElement[1] = ss.substring(ss.indexOf("t")+2,ss.indexOf("{")-1); + solutions.add(auxElement); + } + + if(infrastructure==true && ss.contains("deployment") && ss.contains("{") && ss.contains("*")==false) { + infrastructure=false; + } + + } + + return solutions; + + } + } diff --git a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/util/IOPSolutionListOutput.java b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/util/IOPSolutionListOutput.java index 345f52b1724841857a8e32f6e09ad925376ed236..7efeec88bc58157ddc20b936d999397ee8d55128 100644 --- a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/util/IOPSolutionListOutput.java +++ b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/util/IOPSolutionListOutput.java @@ -15,6 +15,7 @@ import java.io.BufferedWriter; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import org.json.simple.JSONArray; import org.json.simple.JSONObject; @@ -24,6 +25,7 @@ import org.uma.jmetal.util.fileoutput.FileOutputContext; import org.uma.jmetal.util.fileoutput.impl.DefaultFileOutputContext; import com.piacere.iop.optimizer.problems.JMETAL_ProblemDiscrete; +import com.piacere.iop.optimizer.service.OptimizerService; public class IOPSolutionListOutput { private FileOutputContext varFileContext; @@ -47,7 +49,7 @@ public class IOPSolutionListOutput { funFileContext.setSeparator(separator); this.solutionList = solutionList; selectFeasibleSolutions = false; - isObjectiveToBeMinimized = null ; + isObjectiveToBeMinimized = null; this.problem = problem; } @@ -261,7 +263,7 @@ public class IOPSolutionListOutput { variables = new ArrayList<String>(); for (int j = 0; j < numberOfObjectives; j++) { objectives.add(this.solutionList.get(i).getObjective(j)); - if(this.solutionList.get(i).getObjective(j) == Double.MAX_VALUE || this.solutionList.get(i).getObjective(j) == -Double.MIN_VALUE) { + if(this.solutionList.get(i).getObjective(j) == Double.MAX_VALUE || this.solutionList.get(i).getObjective(j) == -Double.MIN_VALUE || this.solutionList.get(i).getObjective(j) < -20000 || this.solutionList.get(i).getObjective(j) > 20000) { insert=false; } } @@ -303,7 +305,124 @@ public class IOPSolutionListOutput { return json; } - + + public ArrayList<String> generateDOMLDiscrete(ArrayList<String> objs){ + + ArrayList<Double> objectives = new ArrayList<Double>(); + ArrayList<String> variables = new ArrayList<String>(); + int numberOfObjectives = solutionList.get(0).getNumberOfObjectives(); + int numberOfVariables = solutionList.get(0).getNumberOfVariables(); + int[] solution = new int[numberOfVariables]; + boolean insert = true; + int insertedIndex = 1; + int NumberSolutionsInserted = 0; + ArrayList<int[]> solutionsInserted = new ArrayList<int[]>(); + ArrayList<String> concretizations = new ArrayList<String>(); + String outputSolution = ""; + ArrayList<String> solutionsAlreadyInserted = new ArrayList<String>(); + ArrayList<String> auxSolution = new ArrayList<String>(); + + + for (int i = 0; i < solutionList.size(); i++) { + + insert=true; + objectives = new ArrayList<Double>(); + variables = new ArrayList<String>(); + for (int j = 0; j < numberOfObjectives; j++) { + objectives.add(this.solutionList.get(i).getObjective(j)); + if(this.solutionList.get(i).getObjective(j) == Double.MAX_VALUE || this.solutionList.get(i).getObjective(j) == Double.MIN_VALUE || this.solutionList.get(i).getObjective(j) == -Double.MAX_VALUE || this.solutionList.get(i).getObjective(j) == -Double.MIN_VALUE || this.solutionList.get(i).getObjective(j) < -20000 || this.solutionList.get(i).getObjective(j) > 20000) { + insert=false; + } + } + for (int j = 0; j < numberOfVariables; j++) { + variables.add(this.solutionList.get(i).getVariableValueString(j)); + solution[j] = Integer.parseInt(solutionList.get(i).getVariableValueString(j)); + } + + if(insert==true) { + try { + auxSolution = this.problem.translateXdiscrete(solution); + } catch (Exception e) { + e.printStackTrace(); + } + Collections.sort(auxSolution); + if(solutionsAlreadyInserted.contains(auxSolution.toString())) { + insert=false; + }else { + solutionsAlreadyInserted.add(auxSolution.toString()); + } + } + + if(insert==true) { + for(int j=0;j<solutionsInserted.size();j++) { + if (Arrays.equals(solutionsInserted.get(j), solution)){ + insert=false; + } + } + if (insert!=false) + solutionsInserted.add(solution.clone()); + } + + if(insert==true && NumberSolutionsInserted<5) { + + try { + + NumberSolutionsInserted=NumberSolutionsInserted+1; + + outputSolution = outputSolution.concat("\tsolution sol" + insertedIndex + " {\n\t\tobjectives {\n"); + + insertedIndex = insertedIndex + 1; + + for(int j=0;j<objectives.size();j++){ + if(objectives.get(j)<0) { + objectives.set(j, Math.abs(objectives.get(j))); + } + } + + for(int j=0;j<objectives.size();j++){ + //outputSolution = outputSolution.concat("\t\t\t" + objectives.get(j)+ "\n"); + if(objs.get(j).contains("cost")) { + outputSolution = outputSolution.concat("\t\t\t" + objs.get(j)+ " " + objectives.get(j) + " euro" + "\n"); + }else if(objs.get(j).contains("availability")) { + outputSolution = outputSolution.concat("\t\t\t" + objs.get(j)+ " " + objectives.get(j) + " %" + "\n"); + }else if(objs.get(j).contains("performance")) { + outputSolution = outputSolution.concat("\t\t\t" + objs.get(j)+ " " + objectives.get(j) + " metric" + "\n"); + } + } + + outputSolution = outputSolution.concat("\t\t}\n\t\tdecisions [\""+ String.valueOf(this.problem.translateXdiscrete(solution)) +"\"]\n\t}\n"); + //outputSolution = outputSolution.concat("\t\t}\t\tdecisions "+ String.valueOf(this.problem.translateXdiscrete_forSolution(solution)) +"\t}"); + + if(OptimizerService.provider==null) { + concretizations.add("\n\tconcrete_infrastructure opt_infra" + (concretizations.size()+1) + "{\n\t\tprovider multi {\n" + this.problem.getConcretizations(solution) + "\n\t\t}\n\t}\n"); + + }else { + concretizations.add("\n\tconcrete_infrastructure opt_infra" + (concretizations.size()+1) + "{\n\t\tprovider "+ OptimizerService.provider + " {\n" + this.problem.getConcretizations(solution) + "\n\t\t}\n\t}\n"); + + } + + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + String solutionsConcretizations = ""; + + for (int i=0;i<concretizations.size();i++) { + solutionsConcretizations = solutionsConcretizations.concat(concretizations.get(i)); + } + + ArrayList<String> solutionList = new ArrayList<String>(); + + solutionList.add(outputSolution); + solutionList.add(solutionsConcretizations); + + return solutionList; + } + public void printObjectivesToFile(FileOutputContext context, List<? extends Solution<?>> solutionList, List<Boolean> minimizeObjective) { @@ -347,5 +466,4 @@ public class IOPSolutionListOutput { public void printVariablesToFile(String fileName) throws IOException { printVariablesToFile(new DefaultFileOutputContext(fileName), solutionList); } - } diff --git a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/util/ShowResults.java b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/util/ShowResults.java deleted file mode 100644 index 22c0d4f53839f01f95694ead0490fee8264d0aae..0000000000000000000000000000000000000000 --- a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/util/ShowResults.java +++ /dev/null @@ -1,81 +0,0 @@ -/********************************************************************* -* Copyright (c) 2021 Tecnalia. -* -* This program and the accompanying materials are made -* available under the terms of the Eclipse Public License 2.0 -* which is available at https://www.eclipse.org/legal/epl-2.0/ -* -* SPDX-License-Identifier: EPL-2.0 -* Contributors (in alphabetical order): -* Eneko Osaba -* Initially developed in the context of PIACERE European Union�s Horizon 2020 www.piacere-project.eu -**********************************************************************/ -package com.piacere.iop.optimizer.util; - -import java.io.FileNotFoundException; -import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; - -import org.moeaframework.core.NondominatedPopulation; -import org.moeaframework.core.Solution; - -public class ShowResults { - - public static void showResults(NondominatedPopulation result, String name, int objectives){ - - try { - - PrintWriter writer; - - if(objectives==3){ - writer = new PrintWriter("results/MOEA_"+name+"_FUN.tsv", "UTF-8"); - for (Solution solution : result) { - writer.print(solution.getObjective(0)+ "\t"); - writer.print(solution.getObjective(1)+ "\t"); - writer.println(solution.getObjective(2)); - } - writer.close(); - }else if (objectives==2){ - writer = new PrintWriter("results/MOEA_"+name+"_FUN.tsv", "UTF-8"); - for (Solution solution : result) { - writer.print(solution.getObjective(0)+ "\t"); - writer.println(solution.getObjective(1)); - } - writer.close(); - }else if (objectives==1){ - writer = new PrintWriter("results/MOEA_"+name+"_FUN.tsv", "UTF-8"); - for (Solution solution : result) { - writer.println(solution.getObjective(0)); - } - writer.close(); - }else if (objectives==4){ - writer = new PrintWriter("results/MOEA_"+name+"_FUN.tsv", "UTF-8"); - for (Solution solution : result) { - writer.print(solution.getObjective(0)+ "\t"); - writer.print(solution.getObjective(1)+ "\t"); - writer.print(solution.getObjective(2)+ "\t"); - writer.println(solution.getObjective(3)); - } - writer.close(); - } - - writer = new PrintWriter("results/MOEA_"+name+"_VAR.tsv", "UTF-8"); - for (Solution solution : result) { - for(int i=0;i<solution.getNumberOfVariables();i++){ - writer.print(solution.getVariable(i) + "\t"); - } - writer.println(); - - } - writer.close(); - - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (UnsupportedEncodingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - -} diff --git a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/web/rest/Optimizer.java b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/web/rest/Optimizer.java index acd8d3f7f132da1e2e8b6d4f1457e492ad62c51b..6e11b48eb8637e9fa2938470dc7812900117ee2b 100644 --- a/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/web/rest/Optimizer.java +++ b/git/iop-optimizer/src/main/java/com/piacere/iop/optimizer/web/rest/Optimizer.java @@ -31,13 +31,41 @@ public class Optimizer { log.debug("processing optimize request"); // if (true) return ResponseEntity.ok().body("PROBLEM TO BE FIXED BELLOW"); String result = null; + + //Check the input DOML for searching malformations + if(this.optimizerService.checkOptimization(doml)==false) { + return ResponseEntity.badRequest().body("The input DOML has no optimization part. It is compulsory for conducting the optimization process."); + } + + if(this.optimizerService.checkEmptyObjectives(doml)==true) { + return ResponseEntity.badRequest().body("No objectives in the input DOML. Objectives should be \\\"cost\\\", \\\"availability\\\" or \\\"performance\\\""); + } + + if(this.optimizerService.checkBadObjectives(doml)==false) { + return ResponseEntity.badRequest().body("There is an objective badly introduced in the input DOML. Objectives should be \"cost\", \"availability\" or \"performance\""); + } + + if(this.optimizerService.checkRequirements(doml)==false) { + return ResponseEntity.badRequest().body("There is a requirement badly introduced in the input DOML. Requirements should be cost, availability, performance, region, provider or elements"); + } + + if(this.optimizerService.checkElements(doml)==false) { + return ResponseEntity.badRequest().body("There is an element badly introduced in the input DOML. Elements should be VM, DB or Storage"); + } + + /////////////////////////////////////////////////// + try { result = this.optimizerService.run(doml); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); + return ResponseEntity.internalServerError().body("Internal Error"); } log.debug("REST result: {}", result); + if (result == null) { + return ResponseEntity.badRequest().body("No possible solutions found. Maybe the restrictions are so strict to find a possible solution"); + } return ResponseEntity.ok().body(result); } diff --git a/git/iop-optimizer/src/main/resources/config/bootstrap-dev.yml b/git/iop-optimizer/src/main/resources/config/bootstrap-dev.yml index 3d67fa4e89e1d62770eba672fc41b94927400d4c..0e2093b57aed99b023522c624358cf652a346026 100644 --- a/git/iop-optimizer/src/main/resources/config/bootstrap-dev.yml +++ b/git/iop-optimizer/src/main/resources/config/bootstrap-dev.yml @@ -17,7 +17,7 @@ backend: registry: host: optimizer-registry:8761 catalog: - url: https://iec-frontend.piacere.esilab.org:8444/services/iecbackend/api/root-services/catalogue + url: https://iec.ci.piacere.digital.tecnalia.dev/services/iecbackend/api/root-services/catalogue base64-secret: MjFhOTY5YjFiYjZjZGM0YTlhZjM1OGYwZmU2MjE1ZTJiNTNmM2Q0OTdiMDhmNDQzNjRjZWQyZDM0YmI0YjkwMGI4ZDc0ZGE0MGM3Yzg0M2U2Y2Q0ZDE4MDcwNzc4ODQyMjczOWYyODNlY2RmOTQzNGQzOTc3NDc0MDdkNjlkN2I= jhipster: diff --git a/git/iop-optimizer/src/main/resources/config/bootstrap-prod.yml b/git/iop-optimizer/src/main/resources/config/bootstrap-prod.yml index 33725ab506535c3f01fbeec13f5a971ec685ea0f..503bccec8de796a13cc86e4747c22e89a560e6db 100644 --- a/git/iop-optimizer/src/main/resources/config/bootstrap-prod.yml +++ b/git/iop-optimizer/src/main/resources/config/bootstrap-prod.yml @@ -9,7 +9,7 @@ backend: registry: host: optimizer-registry:8761 catalog: - url: https://iec-frontend.piacere.esilab.org:8444/services/iecbackend/api/root-services/catalogue + url: https://iec.ci.piacere.digital.tecnalia.dev/services/iecbackend/api/root-services/catalogue base64-secret: MjFhOTY5YjFiYjZjZGM0YTlhZjM1OGYwZmU2MjE1ZTJiNTNmM2Q0OTdiMDhmNDQzNjRjZWQyZDM0YmI0YjkwMGI4ZDc0ZGE0MGM3Yzg0M2U2Y2Q0ZDE4MDcwNzc4ODQyMjczOWYyODNlY2RmOTQzNGQzOTc3NDc0MDdkNjlkN2I= jhipster: diff --git a/git/iop-optimizer/src/main/resources/config/bootstrap.yml b/git/iop-optimizer/src/main/resources/config/bootstrap.yml index 3d67fa4e89e1d62770eba672fc41b94927400d4c..0e2093b57aed99b023522c624358cf652a346026 100644 --- a/git/iop-optimizer/src/main/resources/config/bootstrap.yml +++ b/git/iop-optimizer/src/main/resources/config/bootstrap.yml @@ -17,7 +17,7 @@ backend: registry: host: optimizer-registry:8761 catalog: - url: https://iec-frontend.piacere.esilab.org:8444/services/iecbackend/api/root-services/catalogue + url: https://iec.ci.piacere.digital.tecnalia.dev/services/iecbackend/api/root-services/catalogue base64-secret: MjFhOTY5YjFiYjZjZGM0YTlhZjM1OGYwZmU2MjE1ZTJiNTNmM2Q0OTdiMDhmNDQzNjRjZWQyZDM0YmI0YjkwMGI4ZDc0ZGE0MGM3Yzg0M2U2Y2Q0ZDE4MDcwNzc4ODQyMjczOWYyODNlY2RmOTQzNGQzOTc3NDc0MDdkNjlkN2I= jhipster: diff --git a/git/iop-optimizer/src/test/java/com/piacere/iop/optimizer/service/OptimizerServiceIT.java b/git/iop-optimizer/src/test/java/com/piacere/iop/optimizer/service/OptimizerServiceIT.java index 64b53398f4b8fb08258785ea133b22210b744561..7f8b7a3ffed34deeecde16d10f7b2bfb581ad743 100644 --- a/git/iop-optimizer/src/test/java/com/piacere/iop/optimizer/service/OptimizerServiceIT.java +++ b/git/iop-optimizer/src/test/java/com/piacere/iop/optimizer/service/OptimizerServiceIT.java @@ -7,6 +7,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.http.ResponseEntity; import org.springframework.security.test.context.support.WithMockUser; /** @@ -28,128 +29,409 @@ class OptimizerServiceIT { @Test void testDefaultOptimize() throws Exception { + + String call = "doml uc3_openstack\r\n" + + "\r\n" + + "application app {\r\n" + + "\r\n" + + " // need to define all sw components of the project this is a placeholder\r\n" + + " // need to understand what is really needed in this spec\r\n" + + " // need to specify all provides/consumes\r\n" + + "\r\n" + + " software_component iwg {\r\n" + + " provides { net_info }\r\n" + + " }\r\n" + + " software_component osint {\r\n" + + " provides { osint_info }\r\n" + + " consumes { net_info, get_twitter, ewcf_rest_interface }\r\n" + + " }\r\n" + + " software_component ewcf {\r\n" + + " provides { ewcf_rest_interface }\r\n" + + " consumes { get_firebase }\r\n" + + " }\r\n" + + " saas external_twitter {\r\n" + + " provides { get_twitter @ \"https://twitter_api/get\" }\r\n" + + " }\r\n" + + " saas external_firebase {\r\n" + + " provides { get_firebase @ \"https://firebase_api/get\" }\r\n" + + " }\r\n" + + "\r\n" + + "}\r\n" + + "\r\n" + + "infrastructure infra {\r\n" + + " // oam is common to all VMs\r\n" + + " // igw should have: oam, net1 to osint and net2 to external 5g \r\n" + + " \r\n" + + " // VMs region\r\n" + + " vm igw_vm {\r\n" + + " os \"Ubuntu-Focal-20.04-Daily-2022-04-19\"\r\n" + + " size \"small\"\r\n" + + " \r\n" + + " iface igw_vm_oam {\r\n" + + " belongs_to subnet_oam_igw\r\n" + + " }\r\n" + + " \r\n" + + " iface igw_vm_net1 {\r\n" + + " belongs_to subnet_net1_igw\r\n" + + " }\r\n" + + " \r\n" + + " iface igw_vm_net2 {\r\n" + + " belongs_to subnet_net2_igw\r\n" + + " }\r\n" + + " \r\n" + + " credentials ssh_key\r\n" + + " }\r\n" + + "\r\n" + + " // sint should have: oam, net1 to igw, net3 to internet\r\n" + + " vm osint_vm {\r\n" + + " os \"Ubuntu-Focal-20.04-Daily-2022-04-19\"\r\n" + + " size \"small\"\r\n" + + " \r\n" + + " iface osint_vm_oam {\r\n" + + " belongs_to subnet_oam_osint\r\n" + + " }\r\n" + + " \r\n" + + " iface osint_vm_net1 {\r\n" + + " belongs_to subnet_net1_osint\r\n" + + " }\r\n" + + " \r\n" + + " iface osint_vm_net3 {\r\n" + + " belongs_to subnet_net3_osint\r\n" + + " }\r\n" + + "\r\n" + + " credentials ssh_key\r\n" + + " }\r\n" + + "\r\n" + + " // ewcf should have: oam, net1 to osint, and net3 to internet\r\n" + + " vm ewcf_vm {\r\n" + + " os \"Ubuntu-Focal-20.04-Daily-2022-04-19\"\r\n" + + " size \"small\"\r\n" + + " \r\n" + + " iface ewcf_vm_oam {\r\n" + + " belongs_to subnet_oam_ewcf\r\n" + + " }\r\n" + + " \r\n" + + " iface ewcf_vm_net1 {\r\n" + + " belongs_to subnet_net1_ewcf\r\n" + + " }\r\n" + + " \r\n" + + " iface ewcf_vm_net3 {\r\n" + + " belongs_to subnet_net3_ewcf\r\n" + + " }\r\n" + + "\r\n" + + " credentials ssh_key\r\n" + + " }\r\n" + + "\r\n" + + " // Containers region\r\n" + + " \r\n" + + " container cont_tia {\r\n" + + " \r\n" + + " host osint_vm {\r\n" + + " \r\n" + + " // Exposed port\r\n" + + " container_port 80\r\n" + + " // Port on the VM where the container will map to\r\n" + + " vm_port 8080\r\n" + + "\r\n" + + " // Most of the interfaces should be on the internal network, but some of them need access through Internet\r\n" + + " // Containers should have two interfaces: an exposed interface to be accessed through Internet and an interface for internal access\r\n" + + " // TODO: However, we can specify only one network interface connected to the container\r\n" + + " iface osint_vm_oam\r\n" + + "\r\n" + + " }\r\n" + + " }\r\n" + + "\r\n" + + " container cont_tis {\r\n" + + " host osint_vm {\r\n" + + " container_port 80\r\n" + + " vm_port 8080\r\n" + + " iface osint_vm_oam\r\n" + + " }\r\n" + + " }\r\n" + + "\r\n" + + " container cont_twr {\r\n" + + " host osint_vm {\r\n" + + " container_port 81\r\n" + + " vm_port 8081\r\n" + + " iface osint_vm_oam\r\n" + + " }\r\n" + + " }\r\n" + + "\r\n" + + " container c1 {\r\n" + + " host igw_vm {\r\n" + + " container_port 82\r\n" + + " vm_port 8082\r\n" + + " iface igw_vm_oam\r\n" + + " }\r\n" + + " }\r\n" + + "\r\n" + + " container c2 {\r\n" + + " host igw_vm { \r\n" + + " container_port 83\r\n" + + " vm_port 8083\r\n" + + " iface igw_vm_oam\r\n" + + " }\r\n" + + " }\r\n" + + "\r\n" + + " container c3 {\r\n" + + " host igw_vm { \r\n" + + " container_port 84\r\n" + + " vm_port 8084\r\n" + + " iface igw_vm_oam\r\n" + + " }\r\n" + + " }\r\n" + + "\r\n" + + " container cont_mongodb {\r\n" + + " host ewcf_vm { \r\n" + + " container_port 85\r\n" + + " vm_port 8085\r\n" + + " iface ewcf_vm_oam\r\n" + + " }\r\n" + + " }\r\n" + + "\r\n" + + " container cont_ewcf {\r\n" + + " host ewcf_vm { \r\n" + + " container_port 86\r\n" + + " vm_port 8086\r\n" + + " iface ewcf_vm_oam\r\n" + + " }\r\n" + + " }\r\n" + + "\r\n" + + " // Network region\r\n" + + " \r\n" + + " // Internal Network\r\n" + + " net oam {\r\n" + + " protocol \"TCP/IP\"\r\n" + + " cidr \"16.0.0.0/24\"\r\n" + + " \r\n" + + " subnet subnet_oam_igw {\r\n" + + " protocol \"TCP/IP\"\r\n" + + " cidr \"16.0.1.0/26\"\r\n" + + " }\r\n" + + " \r\n" + + " subnet subnet_oam_osint {\r\n" + + " protocol \"TCP/IP\"\r\n" + + " cidr \"16.0.1.64/26\"\r\n" + + " }\r\n" + + " \r\n" + + " subnet subnet_oam_ewcf {\r\n" + + " protocol \"TCP/IP\"\r\n" + + " cidr \"16.0.1.128/26\"\r\n" + + " }\r\n" + + " }\r\n" + + " \r\n" + + " // Internal network\r\n" + + " net net1 {\r\n" + + " protocol \"TCP/IP\"\r\n" + + " cidr \"16.0.1.0/24\"\r\n" + + "\r\n" + + " // Subnets definition\r\n" + + " subnet subnet_net1_igw {\r\n" + + " connections {\r\n" + + " subnet_net1_osint\r\n" + + " }\r\n" + + " protocol \"TCP/IP\"\r\n" + + " cidr \"16.0.1.0/25\"\r\n" + + " }\r\n" + + "\r\n" + + " subnet subnet_net1_osint {\r\n" + + " connections {\r\n" + + " subnet_net1_igw\r\n" + + " subnet_net1_ewcf\r\n" + + " }\r\n" + + " protocol \"TCP/IP\"\r\n" + + " cidr \"16.0.1.64/26\"\r\n" + + " }\r\n" + + " \r\n" + + " subnet subnet_net1_ewcf {\r\n" + + " connections {\r\n" + + " subnet_net1_osint\r\n" + + " }\r\n" + + " protocol \"TCP/IP\"\r\n" + + " cidr \"16.0.1.128/26\"\r\n" + + " }\r\n" + + " }\r\n" + + " \r\n" + + " // Network connecting igw to 5G\r\n" + + " net net2 {\r\n" + + " protocol \"TCP/IP\"\r\n" + + " cidr \"16.0.2.0/24\"\r\n" + + " \r\n" + + " subnet subnet_net2_igw {\r\n" + + " protocol \"TCP/IP\"\r\n" + + " cidr \"16.0.2.0/25\"\r\n" + + " }\r\n" + + " \r\n" + + " }\r\n" + + " \r\n" + + " // Network connecting osint and ewcf to Internet\r\n" + + " net net3 {\r\n" + + " protocol \"TCP/IP\"\r\n" + + " cidr \"16.0.3.0/24\"\r\n" + + " \r\n" + + " subnet subnet_net3_osint {\r\n" + + " protocol \"TCP/IP\"\r\n" + + " cidr \"16.0.3.0/25\"\r\n" + + " }\r\n" + + " \r\n" + + " subnet subnet_net3_ewcf {\r\n" + + " protocol \"TCP/IP\"\r\n" + + " cidr \"16.0.3.128/25\"\r\n" + + " }\r\n" + + " \r\n" + + " }\r\n" + + "\r\n" + + " // credentials region\r\n" + + " key_pair ssh_key {\r\n" + + " user \"ubuntu\"\r\n" + + " keyfile \"/home/user1/.ssh/openstack.key\"\r\n" + + " algorithm \"RSA\"\r\n" + + " bits 4096\r\n" + + " }\r\n" + + " \r\n" + + " // Computing groups region\r\n" + + " \r\n" + + " // Currently not used since it is not implemented\r\n" + + " // Autoscale groups should currently be removed (leave them commented in order to be eventually reused,\r\n" + + " // even though the name could probably be different since there are not autoscale groups on Openstack)\r\n" + + " \r\n" + + "\r\n" + + " // Security region\r\n" + + "\r\n" + + " // security group is left as originally defined needs to be updated\r\n" + + " security_group sg {\r\n" + + " egress icmp {\r\n" + + " protocol \"ICMP\"\r\n" + + " from_port -1\r\n" + + " to_port -1\r\n" + + " cidr [\"0.0.0.0/0\"]\r\n" + + " }\r\n" + + " ingress http {\r\n" + + " protocol \"TCP\"\r\n" + + " from_port 80\r\n" + + " to_port 80\r\n" + + " cidr [\"0.0.0.0/0\"]\r\n" + + " }\r\n" + + " ingress https {\r\n" + + " protocol \"TCP\"\r\n" + + " from_port 443\r\n" + + " to_port 443\r\n" + + " cidr [\"0.0.0.0/0\"]\r\n" + + " }\r\n" + + " ingress ssh {\r\n" + + " protocol \"TCP\"\r\n" + + " from_port 22\r\n" + + " to_port 22\r\n" + + " cidr [\"0.0.0.0/0\"]\r\n" + + " }\r\n" + + "\r\n" + + " ifaces igw_vm_oam, igw_vm_net1, igw_vm_net2, osint_vm_oam, osint_vm_net1, osint_vm_net3, ewcf_vm_oam, ewcf_vm_net1, ewcf_vm_net3\r\n" + + " }\r\n" + + "}\r\n" + + "\r\n" + + "deployment config1 {\r\n" + + " osint -> osint_vm,\r\n" + + " iwg -> igw_vm,\r\n" + + " ewcf -> ewcf_vm\r\n" + + "}\r\n" + + "\r\n" + + "active deployment config1\r\n" + + "\r\n" + + "concretizations {\r\n" + + " concrete_infrastructure con_infra {\r\n" + + "\r\n" + + " provider openstack {\r\n" + + "\r\n" + + " // Concrete computing nodes region\r\n" + + "\r\n" + + " vm concrete_osint_vm {\r\n" + + " properties {\r\n" + + " // Actually, this is not recognized by ICG, so it's useless\r\n" + + " vm_name = \"osint\";\r\n" + + " // vm_flavor property moved to \"size\" attribute\r\n" + + " vm_key_name = \"user1\";\r\n" + + " }\r\n" + + " maps osint_vm\r\n" + + " }\r\n" + + "\r\n" + + " vm concrete_igw_vm {\r\n" + + " properties {\r\n" + + " vm_name = \"igw\";\r\n" + + " vm_key_name = \"user1\";\r\n" + + " }\r\n" + + " maps igw_vm\r\n" + + " }\r\n" + + "\r\n" + + " vm concrete_ewcf_vm {\r\n" + + " properties {\r\n" + + " vm_name = \"ewcf\";\r\n" + + " vm_key_name = \"user1\";\r\n" + + " }\r\n" + + " maps ewcf_vm\r\n" + + " }\r\n" + + "\r\n" + + " // Concrete Network region\r\n" + + " net concrete_oam {\r\n" + + " properties {\r\n" + + " name = \"uc3_oam\";\r\n" + + " }\r\n" + + " maps oam\r\n" + + " }\r\n" + + " \r\n" + + " net concrete_net1 {\r\n" + + " properties {\r\n" + + " name = \"uc3_net1\";\r\n" + + " }\r\n" + + " maps net1\r\n" + + " }\r\n" + + " \r\n" + + " net concrete_net2 {\r\n" + + " properties {\r\n" + + " name = \"uc3_net2\";\r\n" + + " }\r\n" + + " maps net2\r\n" + + " }\r\n" + + " \r\n" + + " net concrete_net3 {\r\n" + + " properties {\r\n" + + " name = \"uc3_net3\";\r\n" + + " }\r\n" + + " maps net3\r\n" + + " }\r\n" + + " \r\n" + + " }\r\n" + + " }\r\n" + + " active con_infra\r\n" + + "}\r\n" + + "optimization opt {\r\n" + + " objectives {\r\n" + + " \"cost\" => min\r\n" + + " \"performance\" => max\r\n" + + " \"availability\" => max\r\n" + + " }\r\n" + + " nonfunctional_requirements {\r\n" + + " req1 \"Cost <= 700\" max 700.0 => \"cost\"\r\n" + + " req2 \"Performance >= 5%\" min 5.0 => \"performance\"\r\n" + + " Req3 \"Provider\" values \"aws\" => \"provider\"\r\n" + + " req4 \"elements\" => \"VM, storage\"\r\n" + + " }\r\n" + + "}"; - /*String call = "{\r\n" - + " \"Call\":[\r\n" - + " {\r\n" - + " \"Objectives\":[\r\n" - + " \"cost\",\r\n" - + " \"availability\",\r\n" - + " \"performance\"\r\n" - + " ],\r\n" - + " \"Requirements\":{\r\n" - + " \"cost\":200.0,\r\n" - + " \"availability\":98.0,\r\n" - + " \"region\":\"00EU\"\r\n" - + " }\r\n" - + " }\r\n" - + " ]\r\n" - + "}";*/ + System.out.println(optimizerService.checkOptimization(call)); + System.out.println(optimizerService.checkEmptyObjectives(call)); + System.out.println(optimizerService.checkBadObjectives(call)); + System.out.println(optimizerService.checkRequirements(call)); + System.out.println(optimizerService.checkElements(call)); - /*String call = "{\r\n" - + " \"Call\":[\r\n" - + " {\r\n" - + " \"Objectives\"[\r\n" - + " \"cost\",\r\n" - + " \"availability\",\r\n" - + " \"performance\"\r\n" - + " ],\r\n" - + " \"Requirements\":{\r\n" - + " }\r\n" - + " }\r\n" - + " ]\r\n" - + "}";*/ - /*String call = "doml nginx_openstack\n" - + "\n" - + "application app {\n" - + "\n" - + " software_component nginx {\n" - + " properties {\n" - + " // site\n" - + " source_code=\"/usr/share/nginx/html/index.html\";\n" - + " }\n" - + " }\n" - + "}\n" - + "\n" - + "infrastructure infra {\n" - + " vm vm1 {\n" - + " ifaces {\n" - + " iface i1 {\n" - + " address \"16.0.0.1\"\n" - + " }\n" - + " }\n" - + " }\n" - + "\n" - + " vm_image v_img {\n" - + " generates vm1\n" - + " }\n" - + "\n" - + " net net1 {\n" - + " address \"16.0.0.0/24\"\n" - + " protocol \"tcp/ip\"\n" - + " }\n" - + "\n" - + " autoscale_group ag { vm1 }\n" - + "}\n" - + "\n" - + "deployment config {\n" - + " nginx -> vm1\n" - + "}\n" - + "\n" - + "active deployment config\n" - + "\n" - + "concretizations {\n" - + " concrete_infrastructure con_infra {\n" - + " provider openstack {\n" - + " vm concrete_vm {\n" - + " properties {\n" - + " vm_name = \"nginx-host\";\n" - + " vm_flavor = \"small\";\n" - + " vm_security_groups = \"default\";\n" - + " vm_key_name = \"user1\";\n" - + " ssh_user = \"ubuntu\";\n" - + " ssh_key_file = \"/home/user1/.ssh/openstack.key\";\n" - + " }\n" - + " maps vm1\n" - + " }\n" - + "\n" - + " vm_image concrete_vm_image {\n" - + " properties {\n" - + " name = \"ubuntu-20.04.3\";\n" - + " }\n" - + " maps v_img\n" - + " }\n" - + "\n" - + " net concrete_net {\n" - + " properties {\n" - + " name = \"ostack2\";\n" - + " }\n" - + " maps net1\n" - + " }\n" - + " }\n" - + " }\n" - + " active con_infra\n" - + "}\n" - + "\n" - + "optimization opt {\n" - + " objectives {\n" - + " \"cost\" => min\n" - //+ " \"availability\" => max\n" - //+ " \"performance\" => max\n" - + " }\n" - + " nonfunctional_requirements {\n" - + " req1 \"Cost <= 200\" max 200 => \"cost\";\n" - + " req2 \"Availability >= 98%\" min 98 => \"availability\";\n" - + " req3 \"Region\" values \"00EU\" => \"region\";\n" - + " }\n" - + "}\n" - + "";*/ - String call = "doml nginx_openstack application app { software_component nginx { properties { // site source_code=\"/usr/share/nginx/html/index.html\"; } }}infrastructure infra { vm vm1 { ifaces { iface i1 { address \"16.0.0.1\" } } } vm_image v_img { generates vm1 } net net1 { address \"16.0.0.0/24\" protocol \"tcp/ip\" } autoscale_group ag { vm1 }} deployment config { nginx -> vm1} active deployment config concretizations { concrete_infrastructure con_infra { provider openstack { vm concrete_vm { properties { vm_name = \"nginx-host\"; vm_flavor = \"small\"; vm_security_groups = \"default\"; vm_key_name = \"user1\"; ssh_user = \"ubuntu\"; ssh_key_file = \"/home/user1/.ssh/openstack.key\"; } maps vm1 } vm_image concrete_vm_image { properties { name = \"ubuntu-20.04.3\"; } maps v_img } net concrete_net { properties { name = \"ostack2\"; } maps net1 } } } active con_infra}optimization opt { objectives { \"cost\" => min } nonfunctional_requirements { req1 \"Cost <= 200\" max 200 => \"cost\"; req2 \"Availability >= 98%\" min 98 => \"availability\"; req3 \"Region\" values \"00EU\" => \"region\"; }}"; - //This is for test purposes + String result=""; - String result = optimizerService.run(call); + for(int i=0;i<1;i++) { + result = optimizerService.run(call); + } + System.out.println(result); assertThat("ok").isEqualTo("ok"); + } } diff --git a/git/iop-optimizer/src/test/resources/config/bootstrap.yml b/git/iop-optimizer/src/test/resources/config/bootstrap.yml index 24f637e540cf694384d39ff504f254d66fecd0b2..a0bd3475323dddc45cec224163bceb73fe3b210e 100644 --- a/git/iop-optimizer/src/test/resources/config/bootstrap.yml +++ b/git/iop-optimizer/src/test/resources/config/bootstrap.yml @@ -7,7 +7,7 @@ backend: registry: host: optimizer-registry:8761 catalog: - url: https://iec-frontend.piacere.esilab.org:8444/services/iecbackend/api/root-services/catalogue + url: https://iec.ci.piacere.digital.tecnalia.dev/services/iecbackend/api/root-services/catalogue base64-secret: MjFhOTY5YjFiYjZjZGM0YTlhZjM1OGYwZmU2MjE1ZTJiNTNmM2Q0OTdiMDhmNDQzNjRjZWQyZDM0YmI0YjkwMGI4ZDc0ZGE0MGM3Yzg0M2U2Y2Q0ZDE4MDcwNzc4ODQyMjczOWYyODNlY2RmOTQzNGQzOTc3NDc0MDdkNjlkN2I= spring: diff --git a/keycloak-setup-config/192.168.56.1.nip.io/realm.json b/keycloak-setup-config/192.168.56.1.nip.io/realm.json deleted file mode 100644 index 2e64e699dddbd1ae22006addea0b568d6f4d7c93..0000000000000000000000000000000000000000 --- a/keycloak-setup-config/192.168.56.1.nip.io/realm.json +++ /dev/null @@ -1,2215 +0,0 @@ -{ - "id": "jhipster", - "realm": "jhipster", - "notBefore": 0, - "revokeRefreshToken": false, - "refreshTokenMaxReuse": 0, - "accessTokenLifespan": 300, - "accessTokenLifespanForImplicitFlow": 900, - "ssoSessionIdleTimeout": 1800, - "ssoSessionMaxLifespan": 36000, - "ssoSessionIdleTimeoutRememberMe": 0, - "ssoSessionMaxLifespanRememberMe": 0, - "offlineSessionIdleTimeout": 2592000, - "offlineSessionMaxLifespanEnabled": false, - "offlineSessionMaxLifespan": 5184000, - "clientSessionIdleTimeout": 0, - "clientSessionMaxLifespan": 0, - "clientOfflineSessionIdleTimeout": 0, - "clientOfflineSessionMaxLifespan": 0, - "accessCodeLifespan": 60, - "accessCodeLifespanUserAction": 300, - "accessCodeLifespanLogin": 1800, - "actionTokenGeneratedByAdminLifespan": 43200, - "actionTokenGeneratedByUserLifespan": 300, - "enabled": true, - "sslRequired": "external", - "registrationAllowed": false, - "registrationEmailAsUsername": false, - "rememberMe": false, - "verifyEmail": false, - "loginWithEmailAllowed": true, - "duplicateEmailsAllowed": false, - "resetPasswordAllowed": false, - "editUsernameAllowed": false, - "bruteForceProtected": false, - "permanentLockout": false, - "maxFailureWaitSeconds": 900, - "minimumQuickLoginWaitSeconds": 60, - "waitIncrementSeconds": 60, - "quickLoginCheckMilliSeconds": 1000, - "maxDeltaTimeSeconds": 43200, - "failureFactor": 30, - "roles": { - "realm": [ - { - "id": "8e986fb5-dafb-43bf-a7c2-7e57572d3d80", - "name": "ROLE_ADMIN", - "description": "Jhipster administrator role", - "composite": false, - "clientRole": false, - "containerId": "jhipster", - "attributes": {} - }, - { - "id": "e1b19afd-f612-4a79-bdf8-26a99b89b10b", - "name": "offline_access", - "description": "${role_offline-access}", - "composite": false, - "clientRole": false, - "containerId": "jhipster", - "attributes": {} - }, - { - "id": "ec5705e1-fc1d-4d21-8364-abd3bd4efcd0", - "name": "ROLE_USER", - "description": "Jhipster user role", - "composite": false, - "clientRole": false, - "containerId": "jhipster", - "attributes": {} - }, - { - "id": "2eec61d0-9581-4dbf-8c7b-f32dc5fac3ce", - "name": "uma_authorization", - "description": "${role_uma_authorization}", - "composite": false, - "clientRole": false, - "containerId": "jhipster", - "attributes": {} - } - ], - "client": { - "internal": [], - "realm-management": [ - { - "id": "a6249a12-d76c-4514-b137-e3018b243e25", - "name": "manage-authorization", - "description": "${role_manage-authorization}", - "composite": false, - "clientRole": true, - "containerId": "898488c8-e260-41c5-a463-7ceea14d587a", - "attributes": {} - }, - { - "id": "a28bc401-c5ad-4fab-aef4-42629988c10b", - "name": "view-realm", - "description": "${role_view-realm}", - "composite": false, - "clientRole": true, - "containerId": "898488c8-e260-41c5-a463-7ceea14d587a", - "attributes": {} - }, - { - "id": "464bca1f-136f-45de-a7fc-b976a185ce7e", - "name": "view-users", - "description": "${role_view-users}", - "composite": true, - "composites": { - "client": { - "realm-management": ["query-users", "query-groups"] - } - }, - "clientRole": true, - "containerId": "898488c8-e260-41c5-a463-7ceea14d587a", - "attributes": {} - }, - { - "id": "98c2fa77-d3c8-4f68-b9f4-b79f87efd4a9", - "name": "query-users", - "description": "${role_query-users}", - "composite": false, - "clientRole": true, - "containerId": "898488c8-e260-41c5-a463-7ceea14d587a", - "attributes": {} - }, - { - "id": "6b82bfdb-c8de-4274-95b4-a683eb4ead50", - "name": "view-identity-providers", - "description": "${role_view-identity-providers}", - "composite": false, - "clientRole": true, - "containerId": "898488c8-e260-41c5-a463-7ceea14d587a", - "attributes": {} - }, - { - "id": "3c6b9cfe-80c4-41d5-a5ac-0cadebacfc8d", - "name": "manage-identity-providers", - "description": "${role_manage-identity-providers}", - "composite": false, - "clientRole": true, - "containerId": "898488c8-e260-41c5-a463-7ceea14d587a", - "attributes": {} - }, - { - "id": "23676fb8-235a-4e54-a0d0-9bed1ccbe2f8", - "name": "query-groups", - "description": "${role_query-groups}", - "composite": false, - "clientRole": true, - "containerId": "898488c8-e260-41c5-a463-7ceea14d587a", - "attributes": {} - }, - { - "id": "b71fe952-bb06-4e4a-91ef-2d2714f770e1", - "name": "impersonation", - "description": "${role_impersonation}", - "composite": false, - "clientRole": true, - "containerId": "898488c8-e260-41c5-a463-7ceea14d587a", - "attributes": {} - }, - { - "id": "0813cbd0-c73d-469d-a54d-84a865c302af", - "name": "manage-events", - "description": "${role_manage-events}", - "composite": false, - "clientRole": true, - "containerId": "898488c8-e260-41c5-a463-7ceea14d587a", - "attributes": {} - }, - { - "id": "c7a4f4c1-9089-458c-a765-f6d22ea94690", - "name": "view-authorization", - "description": "${role_view-authorization}", - "composite": false, - "clientRole": true, - "containerId": "898488c8-e260-41c5-a463-7ceea14d587a", - "attributes": {} - }, - { - "id": "2e1bc884-e9d3-45d2-909c-2777a78ca8ae", - "name": "manage-realm", - "description": "${role_manage-realm}", - "composite": false, - "clientRole": true, - "containerId": "898488c8-e260-41c5-a463-7ceea14d587a", - "attributes": {} - }, - { - "id": "0a05451e-7d64-4e87-b585-f1143ce5752e", - "name": "query-clients", - "description": "${role_query-clients}", - "composite": false, - "clientRole": true, - "containerId": "898488c8-e260-41c5-a463-7ceea14d587a", - "attributes": {} - }, - { - "id": "dfad4d08-6d75-42b6-8699-4886e47bc464", - "name": "view-events", - "description": "${role_view-events}", - "composite": false, - "clientRole": true, - "containerId": "898488c8-e260-41c5-a463-7ceea14d587a", - "attributes": {} - }, - { - "id": "392ed0a3-f6ad-48a1-b201-648037d2b4bd", - "name": "realm-admin", - "description": "${role_realm-admin}", - "composite": true, - "composites": { - "client": { - "realm-management": [ - "manage-authorization", - "view-realm", - "view-users", - "query-users", - "manage-identity-providers", - "view-identity-providers", - "query-groups", - "impersonation", - "manage-events", - "query-clients", - "manage-realm", - "view-authorization", - "view-events", - "view-clients", - "create-client", - "manage-clients", - "manage-users", - "query-realms" - ] - } - }, - "clientRole": true, - "containerId": "898488c8-e260-41c5-a463-7ceea14d587a", - "attributes": {} - }, - { - "id": "d7efdf61-affb-42a1-bcb0-b2c30d87a39e", - "name": "view-clients", - "description": "${role_view-clients}", - "composite": true, - "composites": { - "client": { - "realm-management": ["query-clients"] - } - }, - "clientRole": true, - "containerId": "898488c8-e260-41c5-a463-7ceea14d587a", - "attributes": {} - }, - { - "id": "14da8e56-5c8b-4764-96da-250449a32fd4", - "name": "create-client", - "description": "${role_create-client}", - "composite": false, - "clientRole": true, - "containerId": "898488c8-e260-41c5-a463-7ceea14d587a", - "attributes": {} - }, - { - "id": "88e6a9f5-259c-487d-af35-2a98da066816", - "name": "manage-clients", - "description": "${role_manage-clients}", - "composite": false, - "clientRole": true, - "containerId": "898488c8-e260-41c5-a463-7ceea14d587a", - "attributes": {} - }, - { - "id": "932273a7-c02b-43db-81c5-96a0dc45e454", - "name": "manage-users", - "description": "${role_manage-users}", - "composite": false, - "clientRole": true, - "containerId": "898488c8-e260-41c5-a463-7ceea14d587a", - "attributes": {} - }, - { - "id": "e3edf335-cec5-4012-a00d-fcac045052e1", - "name": "query-realms", - "description": "${role_query-realms}", - "composite": false, - "clientRole": true, - "containerId": "898488c8-e260-41c5-a463-7ceea14d587a", - "attributes": {} - } - ], - "jhipster-control-center": [], - "security-admin-console": [], - "web_app": [], - "admin-cli": [], - "account-console": [], - "jhipster-registry": [], - "broker": [ - { - "id": "5b08a930-9f1d-4030-ae75-92c1e4c9352c", - "name": "read-token", - "description": "${role_read-token}", - "composite": false, - "clientRole": true, - "containerId": "88e1225b-f0b9-46ba-8efd-f2c10ce23058", - "attributes": {} - } - ], - "account": [ - { - "id": "a88c56b8-6bc9-418a-92bc-7a17e7707f60", - "name": "view-profile", - "description": "${role_view-profile}", - "composite": false, - "clientRole": true, - "containerId": "6cc5a716-0880-47dc-b714-9a4967246b2f", - "attributes": {} - }, - { - "id": "0cb954ab-987f-482a-b2d7-0d481ba1d532", - "name": "view-applications", - "description": "${role_view-applications}", - "composite": false, - "clientRole": true, - "containerId": "6cc5a716-0880-47dc-b714-9a4967246b2f", - "attributes": {} - }, - { - "id": "6450156d-7526-48f2-8ea0-bb1e51f9eefa", - "name": "manage-account", - "description": "${role_manage-account}", - "composite": true, - "composites": { - "client": { - "account": ["manage-account-links"] - } - }, - "clientRole": true, - "containerId": "6cc5a716-0880-47dc-b714-9a4967246b2f", - "attributes": {} - }, - { - "id": "e5b2ba76-4c36-4ba1-b210-89a1ac3c6bbe", - "name": "view-consent", - "description": "${role_view-consent}", - "composite": false, - "clientRole": true, - "containerId": "6cc5a716-0880-47dc-b714-9a4967246b2f", - "attributes": {} - }, - { - "id": "35537940-67a6-4217-881b-1ff98109b374", - "name": "manage-consent", - "description": "${role_manage-consent}", - "composite": true, - "composites": { - "client": { - "account": ["view-consent"] - } - }, - "clientRole": true, - "containerId": "6cc5a716-0880-47dc-b714-9a4967246b2f", - "attributes": {} - }, - { - "id": "5ebf404b-7805-4da2-abb4-9db7d3b36120", - "name": "delete-account", - "description": "${role_delete-account}", - "composite": false, - "clientRole": true, - "containerId": "6cc5a716-0880-47dc-b714-9a4967246b2f", - "attributes": {} - }, - { - "id": "a7f45fab-19c3-4c48-aca3-85f828ca0fed", - "name": "manage-account-links", - "description": "${role_manage-account-links}", - "composite": false, - "clientRole": true, - "containerId": "6cc5a716-0880-47dc-b714-9a4967246b2f", - "attributes": {} - } - ] - } - }, - "groups": [ - { - "id": "afb0c768-ab0f-454c-a8ea-bc9e70b50248", - "name": "Admins", - "path": "/Admins", - "attributes": {}, - "realmRoles": ["ROLE_ADMIN"], - "clientRoles": {}, - "subGroups": [] - }, - { - "id": "672767bb-4ab0-4d37-93a1-9b6c2416b6b2", - "name": "Users", - "path": "/Users", - "attributes": {}, - "realmRoles": ["ROLE_USER"], - "clientRoles": {}, - "subGroups": [] - } - ], - "defaultRoles": ["uma_authorization", "offline_access"], - "requiredCredentials": ["password"], - "otpPolicyType": "totp", - "otpPolicyAlgorithm": "HmacSHA1", - "otpPolicyInitialCounter": 0, - "otpPolicyDigits": 6, - "otpPolicyLookAheadWindow": 1, - "otpPolicyPeriod": 30, - "otpSupportedApplications": ["FreeOTP", "Google Authenticator"], - "webAuthnPolicyRpEntityName": "keycloak", - "webAuthnPolicySignatureAlgorithms": ["ES256"], - "webAuthnPolicyRpId": "", - "webAuthnPolicyAttestationConveyancePreference": "not specified", - "webAuthnPolicyAuthenticatorAttachment": "not specified", - "webAuthnPolicyRequireResidentKey": "not specified", - "webAuthnPolicyUserVerificationRequirement": "not specified", - "webAuthnPolicyCreateTimeout": 0, - "webAuthnPolicyAvoidSameAuthenticatorRegister": false, - "webAuthnPolicyAcceptableAaguids": [], - "webAuthnPolicyPasswordlessRpEntityName": "keycloak", - "webAuthnPolicyPasswordlessSignatureAlgorithms": ["ES256"], - "webAuthnPolicyPasswordlessRpId": "", - "webAuthnPolicyPasswordlessAttestationConveyancePreference": "not specified", - "webAuthnPolicyPasswordlessAuthenticatorAttachment": "not specified", - "webAuthnPolicyPasswordlessRequireResidentKey": "not specified", - "webAuthnPolicyPasswordlessUserVerificationRequirement": "not specified", - "webAuthnPolicyPasswordlessCreateTimeout": 0, - "webAuthnPolicyPasswordlessAvoidSameAuthenticatorRegister": false, - "webAuthnPolicyPasswordlessAcceptableAaguids": [], - "users": [ - { - "id": "f742ba6f-1d8a-4dec-bf15-e02dab508283", - "createdTimestamp": 1598681172054, - "username": "service-account-internal", - "enabled": true, - "totp": false, - "emailVerified": false, - "serviceAccountClientId": "internal", - "disableableCredentialTypes": [], - "requiredActions": [], - "realmRoles": ["offline_access", "uma_authorization"], - "clientRoles": { - "account": ["view-profile", "manage-account"] - }, - "notBefore": 0, - "groups": [] - } - ], - "scopeMappings": [ - { - "clientScope": "offline_access", - "roles": ["offline_access"] - } - ], - "clientScopeMappings": { - "account": [ - { - "client": "account-console", - "roles": ["manage-account"] - } - ] - }, - "clients": [ - { - "id": "6cc5a716-0880-47dc-b714-9a4967246b2f", - "clientId": "account", - "name": "${client_account}", - "rootUrl": "${authBaseUrl}", - "baseUrl": "/realms/jhipster/account/", - "surrogateAuthRequired": false, - "enabled": true, - "alwaysDisplayInConsole": false, - "clientAuthenticatorType": "client-secret", - "secret": "**********", - "defaultRoles": ["manage-account", "view-profile"], - "redirectUris": ["/realms/jhipster/account/*"], - "webOrigins": [], - "notBefore": 0, - "bearerOnly": false, - "consentRequired": false, - "standardFlowEnabled": true, - "implicitFlowEnabled": false, - "directAccessGrantsEnabled": false, - "serviceAccountsEnabled": false, - "publicClient": false, - "frontchannelLogout": false, - "protocol": "openid-connect", - "attributes": {}, - "authenticationFlowBindingOverrides": {}, - "fullScopeAllowed": false, - "nodeReRegistrationTimeout": 0, - "defaultClientScopes": ["web-origins", "role_list", "profile", "roles", "email"], - "optionalClientScopes": ["address", "phone", "offline_access", "microprofile-jwt"] - }, - { - "id": "fb0a4870-06db-4f9d-9d44-baf51a00cc34", - "clientId": "account-console", - "name": "${client_account-console}", - "rootUrl": "${authBaseUrl}", - "baseUrl": "/realms/jhipster/account/", - "surrogateAuthRequired": false, - "enabled": true, - "alwaysDisplayInConsole": false, - "clientAuthenticatorType": "client-secret", - "secret": "**********", - "redirectUris": ["/realms/jhipster/account/*"], - "webOrigins": [], - "notBefore": 0, - "bearerOnly": false, - "consentRequired": false, - "standardFlowEnabled": true, - "implicitFlowEnabled": false, - "directAccessGrantsEnabled": false, - "serviceAccountsEnabled": false, - "publicClient": true, - "frontchannelLogout": false, - "protocol": "openid-connect", - "attributes": { - "pkce.code.challenge.method": "S256" - }, - "authenticationFlowBindingOverrides": {}, - "fullScopeAllowed": false, - "nodeReRegistrationTimeout": 0, - "protocolMappers": [ - { - "id": "c5c4ebe5-d009-4f96-b143-1b36d770eafb", - "name": "audience resolve", - "protocol": "openid-connect", - "protocolMapper": "oidc-audience-resolve-mapper", - "consentRequired": false, - "config": {} - } - ], - "defaultClientScopes": ["web-origins", "role_list", "profile", "roles", "email"], - "optionalClientScopes": ["address", "phone", "offline_access", "microprofile-jwt"] - }, - { - "id": "bb166356-838d-445e-94e3-9330ad7ab51b", - "clientId": "admin-cli", - "name": "${client_admin-cli}", - "surrogateAuthRequired": false, - "enabled": true, - "alwaysDisplayInConsole": false, - "clientAuthenticatorType": "client-secret", - "secret": "**********", - "redirectUris": [], - "webOrigins": [], - "notBefore": 0, - "bearerOnly": false, - "consentRequired": false, - "standardFlowEnabled": false, - "implicitFlowEnabled": false, - "directAccessGrantsEnabled": true, - "serviceAccountsEnabled": false, - "publicClient": true, - "frontchannelLogout": false, - "protocol": "openid-connect", - "attributes": {}, - "authenticationFlowBindingOverrides": {}, - "fullScopeAllowed": false, - "nodeReRegistrationTimeout": 0, - "defaultClientScopes": ["web-origins", "role_list", "profile", "roles", "email"], - "optionalClientScopes": ["address", "phone", "offline_access", "microprofile-jwt"] - }, - { - "id": "88e1225b-f0b9-46ba-8efd-f2c10ce23058", - "clientId": "broker", - "name": "${client_broker}", - "surrogateAuthRequired": false, - "enabled": true, - "alwaysDisplayInConsole": false, - "clientAuthenticatorType": "client-secret", - "secret": "**********", - "redirectUris": [], - "webOrigins": [], - "notBefore": 0, - "bearerOnly": false, - "consentRequired": false, - "standardFlowEnabled": true, - "implicitFlowEnabled": false, - "directAccessGrantsEnabled": false, - "serviceAccountsEnabled": false, - "publicClient": false, - "frontchannelLogout": false, - "protocol": "openid-connect", - "attributes": {}, - "authenticationFlowBindingOverrides": {}, - "fullScopeAllowed": false, - "nodeReRegistrationTimeout": 0, - "defaultClientScopes": ["web-origins", "role_list", "profile", "roles", "email"], - "optionalClientScopes": ["address", "phone", "offline_access", "microprofile-jwt"] - }, - { - "id": "10e6ea34-9f1e-49ef-8e28-7eb851459694", - "clientId": "internal", - "surrogateAuthRequired": false, - "enabled": true, - "alwaysDisplayInConsole": false, - "clientAuthenticatorType": "client-secret", - "secret": "internal", - "redirectUris": [], - "webOrigins": [], - "notBefore": 0, - "bearerOnly": false, - "consentRequired": false, - "standardFlowEnabled": false, - "implicitFlowEnabled": false, - "directAccessGrantsEnabled": false, - "serviceAccountsEnabled": true, - "publicClient": false, - "frontchannelLogout": false, - "protocol": "openid-connect", - "attributes": { - "saml.assertion.signature": "false", - "saml.force.post.binding": "false", - "saml.multivalued.roles": "false", - "saml.encrypt": "false", - "saml.server.signature": "false", - "saml.server.signature.keyinfo.ext": "false", - "exclude.session.state.from.auth.response": "false", - "saml_force_name_id_format": "false", - "saml.client.signature": "false", - "tls.client.certificate.bound.access.tokens": "false", - "saml.authnstatement": "false", - "display.on.consent.screen": "false", - "saml.onetimeuse.condition": "false" - }, - "authenticationFlowBindingOverrides": {}, - "fullScopeAllowed": true, - "nodeReRegistrationTimeout": -1, - "protocolMappers": [ - { - "id": "ff2f50b4-5409-4789-bdda-fe731f14fbff", - "name": "Client IP Address", - "protocol": "openid-connect", - "protocolMapper": "oidc-usersessionmodel-note-mapper", - "consentRequired": false, - "config": { - "user.session.note": "clientAddress", - "userinfo.token.claim": "true", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "clientAddress", - "jsonType.label": "String" - } - }, - { - "id": "72f9ae74-9e95-4b7b-a709-5086137410bb", - "name": "Client ID", - "protocol": "openid-connect", - "protocolMapper": "oidc-usersessionmodel-note-mapper", - "consentRequired": false, - "config": { - "user.session.note": "clientId", - "userinfo.token.claim": "true", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "clientId", - "jsonType.label": "String" - } - }, - { - "id": "029bf6c8-5a19-4798-984c-bdb205d752d5", - "name": "Client Host", - "protocol": "openid-connect", - "protocolMapper": "oidc-usersessionmodel-note-mapper", - "consentRequired": false, - "config": { - "user.session.note": "clientHost", - "userinfo.token.claim": "true", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "clientHost", - "jsonType.label": "String" - } - } - ], - "defaultClientScopes": ["web-origins", "role_list", "profile", "roles", "email"], - "optionalClientScopes": ["address", "phone", "offline_access", "microprofile-jwt"] - }, - { - "id": "1acf7ad0-68cb-46a6-a3e4-8b2f2abecb85", - "clientId": "jhipster-control-center", - "rootUrl": "http://localhost:7419", - "adminUrl": "http://localhost:7419", - "surrogateAuthRequired": false, - "enabled": true, - "alwaysDisplayInConsole": false, - "clientAuthenticatorType": "client-secret", - "secret": "jhipster-control-center", - "redirectUris": ["*"], - "webOrigins": ["*"], - "notBefore": 0, - "bearerOnly": false, - "consentRequired": false, - "standardFlowEnabled": true, - "implicitFlowEnabled": true, - "directAccessGrantsEnabled": false, - "serviceAccountsEnabled": false, - "publicClient": true, - "frontchannelLogout": false, - "protocol": "openid-connect", - "attributes": { - "saml.assertion.signature": "false", - "saml.force.post.binding": "false", - "saml.multivalued.roles": "false", - "saml.encrypt": "false", - "saml.server.signature": "false", - "saml.server.signature.keyinfo.ext": "false", - "exclude.session.state.from.auth.response": "false", - "saml_force_name_id_format": "false", - "saml.client.signature": "false", - "tls.client.certificate.bound.access.tokens": "false", - "saml.authnstatement": "false", - "display.on.consent.screen": "false", - "saml.onetimeuse.condition": "false" - }, - "authenticationFlowBindingOverrides": {}, - "fullScopeAllowed": true, - "nodeReRegistrationTimeout": -1, - "defaultClientScopes": ["web-origins", "jhipster", "role_list", "profile", "roles", "email"], - "optionalClientScopes": ["address", "phone", "offline_access", "microprofile-jwt"] - }, - { - "id": "9057870f-8775-448d-a194-1d4e122f44d5", - "clientId": "jhipster-registry", - "rootUrl": "https://jhipster-registry.192.168.56.1.nip.io:8443", - "adminUrl": "https://jhipster-registry.192.168.56.1.nip.io:8443", - "surrogateAuthRequired": false, - "enabled": true, - "alwaysDisplayInConsole": false, - "clientAuthenticatorType": "client-secret", - "secret": "jhipster-registry", - "redirectUris": ["*"], - "webOrigins": ["*"], - "notBefore": 0, - "bearerOnly": false, - "consentRequired": false, - "standardFlowEnabled": true, - "implicitFlowEnabled": false, - "directAccessGrantsEnabled": true, - "serviceAccountsEnabled": false, - "publicClient": true, - "frontchannelLogout": false, - "protocol": "openid-connect", - "attributes": { - "saml.assertion.signature": "false", - "saml.force.post.binding": "false", - "saml.multivalued.roles": "false", - "saml.encrypt": "false", - "saml.server.signature": "false", - "saml.server.signature.keyinfo.ext": "false", - "exclude.session.state.from.auth.response": "false", - "saml_force_name_id_format": "false", - "saml.client.signature": "false", - "tls.client.certificate.bound.access.tokens": "false", - "saml.authnstatement": "false", - "display.on.consent.screen": "false", - "saml.onetimeuse.condition": "false" - }, - "authenticationFlowBindingOverrides": {}, - "fullScopeAllowed": true, - "nodeReRegistrationTimeout": -1, - "defaultClientScopes": ["web-origins", "jhipster", "role_list", "roles", "profile", "email"], - "optionalClientScopes": ["address", "phone", "offline_access", "microprofile-jwt"] - }, - { - "id": "898488c8-e260-41c5-a463-7ceea14d587a", - "clientId": "realm-management", - "name": "${client_realm-management}", - "surrogateAuthRequired": false, - "enabled": true, - "alwaysDisplayInConsole": false, - "clientAuthenticatorType": "client-secret", - "secret": "**********", - "redirectUris": [], - "webOrigins": [], - "notBefore": 0, - "bearerOnly": true, - "consentRequired": false, - "standardFlowEnabled": true, - "implicitFlowEnabled": false, - "directAccessGrantsEnabled": false, - "serviceAccountsEnabled": false, - "publicClient": false, - "frontchannelLogout": false, - "protocol": "openid-connect", - "attributes": {}, - "authenticationFlowBindingOverrides": {}, - "fullScopeAllowed": false, - "nodeReRegistrationTimeout": 0, - "defaultClientScopes": ["web-origins", "role_list", "profile", "roles", "email"], - "optionalClientScopes": ["address", "phone", "offline_access", "microprofile-jwt"] - }, - { - "id": "989d2b96-b820-4f9b-aa17-55e6488b08c8", - "clientId": "security-admin-console", - "name": "${client_security-admin-console}", - "rootUrl": "${authAdminUrl}", - "baseUrl": "/admin/jhipster/console/", - "surrogateAuthRequired": false, - "enabled": true, - "alwaysDisplayInConsole": false, - "clientAuthenticatorType": "client-secret", - "secret": "**********", - "redirectUris": ["/admin/jhipster/console/*"], - "webOrigins": ["+"], - "notBefore": 0, - "bearerOnly": false, - "consentRequired": false, - "standardFlowEnabled": true, - "implicitFlowEnabled": false, - "directAccessGrantsEnabled": false, - "serviceAccountsEnabled": false, - "publicClient": true, - "frontchannelLogout": false, - "protocol": "openid-connect", - "attributes": { - "pkce.code.challenge.method": "S256" - }, - "authenticationFlowBindingOverrides": {}, - "fullScopeAllowed": false, - "nodeReRegistrationTimeout": 0, - "protocolMappers": [ - { - "id": "5fd34289-c644-411a-874c-849475d9d102", - "name": "locale", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-attribute-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "locale", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "locale", - "jsonType.label": "String" - } - } - ], - "defaultClientScopes": ["web-origins", "role_list", "profile", "roles", "email"], - "optionalClientScopes": ["address", "phone", "offline_access", "microprofile-jwt"] - }, - { - "id": "6e8deddb-b4d6-4e2e-b389-b397d3f74fcd", - "clientId": "web_app", - "rootUrl": "https://192.168.56.1.nip.io:8443", - "adminUrl": "https://192.168.56.1.nip.io:8443", - "surrogateAuthRequired": false, - "enabled": true, - "alwaysDisplayInConsole": false, - "clientAuthenticatorType": "client-secret", - "secret": "web_app", - "redirectUris": [ - "*"], - "webOrigins": ["*"], - "notBefore": 0, - "bearerOnly": false, - "consentRequired": false, - "standardFlowEnabled": true, - "implicitFlowEnabled": true, - "directAccessGrantsEnabled": false, - "serviceAccountsEnabled": false, - "publicClient": true, - "frontchannelLogout": false, - "protocol": "openid-connect", - "attributes": { - "saml.assertion.signature": "false", - "saml.force.post.binding": "false", - "saml.multivalued.roles": "false", - "saml.encrypt": "false", - "saml.server.signature": "false", - "saml.server.signature.keyinfo.ext": "false", - "exclude.session.state.from.auth.response": "false", - "saml_force_name_id_format": "false", - "saml.client.signature": "false", - "tls.client.certificate.bound.access.tokens": "false", - "saml.authnstatement": "false", - "display.on.consent.screen": "false", - "saml.onetimeuse.condition": "false" - }, - "authenticationFlowBindingOverrides": {}, - "fullScopeAllowed": true, - "nodeReRegistrationTimeout": -1, - "defaultClientScopes": ["web-origins", "jhipster", "role_list", "profile", "roles", "email"], - "optionalClientScopes": ["address", "phone", "offline_access", "microprofile-jwt"] - } - ], - "clientScopes": [ - { - "id": "52d73c82-423c-44a8-b2ec-1e13f4cd6065", - "name": "address", - "description": "OpenID Connect built-in scope: address", - "protocol": "openid-connect", - "attributes": { - "include.in.token.scope": "true", - "display.on.consent.screen": "true", - "consent.screen.text": "${addressScopeConsentText}" - }, - "protocolMappers": [ - { - "id": "98230752-36b9-4755-8661-a7de1926d0d4", - "name": "address", - "protocol": "openid-connect", - "protocolMapper": "oidc-address-mapper", - "consentRequired": false, - "config": { - "user.attribute.formatted": "formatted", - "user.attribute.country": "country", - "user.attribute.postal_code": "postal_code", - "userinfo.token.claim": "true", - "user.attribute.street": "street", - "id.token.claim": "true", - "user.attribute.region": "region", - "access.token.claim": "true", - "user.attribute.locality": "locality" - } - } - ] - }, - { - "id": "44d24405-87bf-4b37-a627-e3fdabb93f50", - "name": "email", - "description": "OpenID Connect built-in scope: email", - "protocol": "openid-connect", - "attributes": { - "include.in.token.scope": "true", - "display.on.consent.screen": "true", - "consent.screen.text": "${emailScopeConsentText}" - }, - "protocolMappers": [ - { - "id": "36800088-6d17-4c18-93e8-2bc93901d8b7", - "name": "email", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-property-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "email", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "email", - "jsonType.label": "String" - } - }, - { - "id": "3ea34afd-30b5-4e5d-a836-dbda439dce6f", - "name": "email verified", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-property-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "emailVerified", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "email_verified", - "jsonType.label": "boolean" - } - } - ] - }, - { - "id": "9816de82-24b7-42fe-a85a-1264868ec293", - "name": "jhipster", - "description": "Jhipster specific claims", - "protocol": "openid-connect", - "attributes": { - "include.in.token.scope": "false", - "display.on.consent.screen": "false" - }, - "protocolMappers": [ - { - "id": "0f9c9347-aad6-4bff-94f4-e11937f2ad33", - "name": "langKey", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-attribute-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "langKey", - "id.token.claim": "false", - "access.token.claim": "false", - "claim.name": "langKey", - "jsonType.label": "String" - } - }, - { - "id": "69729907-8d1c-4961-81c0-91766f548cc9", - "name": "roles", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-realm-role-mapper", - "consentRequired": false, - "config": { - "multivalued": "true", - "userinfo.token.claim": "true", - "id.token.claim": "false", - "access.token.claim": "true", - "claim.name": "roles", - "jsonType.label": "String" - } - }, - { - "id": "336acfe2-a717-492a-9055-5b70e808f42f", - "name": "login", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-attribute-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "preferred_username", - "id.token.claim": "false", - "access.token.claim": "false", - "claim.name": "login", - "jsonType.label": "String" - } - } - ] - }, - { - "id": "87d299f2-434f-4abd-8cb0-a16231acd713", - "name": "microprofile-jwt", - "description": "Microprofile - JWT built-in scope", - "protocol": "openid-connect", - "attributes": { - "include.in.token.scope": "true", - "display.on.consent.screen": "false" - }, - "protocolMappers": [ - { - "id": "fce09d51-cb85-4ccd-b83d-865a4d4bf650", - "name": "groups", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-realm-role-mapper", - "consentRequired": false, - "config": { - "multivalued": "true", - "userinfo.token.claim": "true", - "user.attribute": "foo", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "groups", - "jsonType.label": "String" - } - }, - { - "id": "3d1ee7e2-b7e1-4504-bd52-b47a2cb10eec", - "name": "upn", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-property-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "username", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "upn", - "jsonType.label": "String" - } - } - ] - }, - { - "id": "0399b625-22d7-4d68-b4db-fd1dc2effacc", - "name": "offline_access", - "description": "OpenID Connect built-in scope: offline_access", - "protocol": "openid-connect", - "attributes": { - "consent.screen.text": "${offlineAccessScopeConsentText}", - "display.on.consent.screen": "true" - } - }, - { - "id": "2b867b2d-3373-43ff-b50f-ea37a5e1c390", - "name": "phone", - "description": "OpenID Connect built-in scope: phone", - "protocol": "openid-connect", - "attributes": { - "include.in.token.scope": "true", - "display.on.consent.screen": "true", - "consent.screen.text": "${phoneScopeConsentText}" - }, - "protocolMappers": [ - { - "id": "daa0191b-20d1-4f71-b191-6c48a37e3677", - "name": "phone number", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-attribute-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "phoneNumber", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "phone_number", - "jsonType.label": "String" - } - }, - { - "id": "32213de7-12f7-4864-b696-c8e6c5e0c26e", - "name": "phone number verified", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-attribute-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "phoneNumberVerified", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "phone_number_verified", - "jsonType.label": "boolean" - } - } - ] - }, - { - "id": "60a44832-9776-449f-94cd-fa8c24a75f35", - "name": "profile", - "description": "OpenID Connect built-in scope: profile", - "protocol": "openid-connect", - "attributes": { - "include.in.token.scope": "true", - "display.on.consent.screen": "true", - "consent.screen.text": "${profileScopeConsentText}" - }, - "protocolMappers": [ - { - "id": "a59584ab-7a7c-4b23-95b5-be8dbbfadc6f", - "name": "family name", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-property-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "lastName", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "family_name", - "jsonType.label": "String" - } - }, - { - "id": "d382c1dc-d5d8-479e-8809-f0a618113a07", - "name": "website", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-attribute-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "website", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "website", - "jsonType.label": "String" - } - }, - { - "id": "559f86c1-1187-498d-8354-723f4ea5721c", - "name": "full name", - "protocol": "openid-connect", - "protocolMapper": "oidc-full-name-mapper", - "consentRequired": false, - "config": { - "id.token.claim": "true", - "access.token.claim": "true", - "userinfo.token.claim": "true" - } - }, - { - "id": "0925e106-a8e2-4ad1-b75e-4147d185894a", - "name": "updated at", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-attribute-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "updatedAt", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "updated_at", - "jsonType.label": "String" - } - }, - { - "id": "eb8e2c73-5c65-4b53-8d55-46edef61315b", - "name": "locale", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-attribute-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "locale", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "locale", - "jsonType.label": "String" - } - }, - { - "id": "4c109376-01bc-4b69-a3c0-4b830ecad674", - "name": "middle name", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-attribute-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "middleName", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "middle_name", - "jsonType.label": "String" - } - }, - { - "id": "b3813956-e556-4b57-a06b-f71b0d6f3d47", - "name": "nickname", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-attribute-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "nickname", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "nickname", - "jsonType.label": "String" - } - }, - { - "id": "28beb4c0-029b-4aa5-ad5f-6d824ca67e15", - "name": "username", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-property-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "username", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "preferred_username", - "jsonType.label": "String" - } - }, - { - "id": "53d681bc-ec29-4f57-924b-ff5bd22d4093", - "name": "profile", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-attribute-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "profile", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "profile", - "jsonType.label": "String" - } - }, - { - "id": "12ba8e12-157d-4729-918b-0d74fa444fba", - "name": "picture", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-attribute-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "picture", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "picture", - "jsonType.label": "String" - } - }, - { - "id": "ddb818fe-8e4a-4b26-9c5d-2467a26af6dc", - "name": "gender", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-attribute-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "gender", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "gender", - "jsonType.label": "String" - } - }, - { - "id": "f78b1746-2be1-45f4-9c1e-1f6141ccdb65", - "name": "birthdate", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-attribute-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "birthdate", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "birthdate", - "jsonType.label": "String" - } - }, - { - "id": "7723245c-4952-4822-86ae-084048b1f2f2", - "name": "given name", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-property-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "firstName", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "given_name", - "jsonType.label": "String" - } - }, - { - "id": "b192fe9f-aa82-4d7d-b8c7-eb7d1ba888d4", - "name": "zoneinfo", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-attribute-mapper", - "consentRequired": false, - "config": { - "userinfo.token.claim": "true", - "user.attribute": "zoneinfo", - "id.token.claim": "true", - "access.token.claim": "true", - "claim.name": "zoneinfo", - "jsonType.label": "String" - } - } - ] - }, - { - "id": "d181691e-b4a6-4063-9eba-6b984402a9a7", - "name": "role_list", - "description": "SAML role list", - "protocol": "saml", - "attributes": { - "consent.screen.text": "${samlRoleListScopeConsentText}", - "display.on.consent.screen": "true" - }, - "protocolMappers": [ - { - "id": "724b16d4-8a9b-42d8-850f-99ca1ab3c958", - "name": "role list", - "protocol": "saml", - "protocolMapper": "saml-role-list-mapper", - "consentRequired": false, - "config": { - "single": "false", - "attribute.nameformat": "Basic", - "attribute.name": "Role" - } - } - ] - }, - { - "id": "915fcb95-81da-4e4c-86ee-73f3b52c83e9", - "name": "roles", - "description": "OpenID Connect scope for add user roles to the access token", - "protocol": "openid-connect", - "attributes": { - "include.in.token.scope": "false", - "display.on.consent.screen": "true", - "consent.screen.text": "${rolesScopeConsentText}" - }, - "protocolMappers": [ - { - "id": "12f0b32d-8911-4028-809b-fc1c0e5e9207", - "name": "audience resolve", - "protocol": "openid-connect", - "protocolMapper": "oidc-audience-resolve-mapper", - "consentRequired": false, - "config": {} - }, - { - "id": "5b997b66-937f-46d3-9e8b-70dca949f682", - "name": "realm roles", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-realm-role-mapper", - "consentRequired": false, - "config": { - "user.attribute": "foo", - "access.token.claim": "true", - "claim.name": "realm_access.roles", - "jsonType.label": "String", - "multivalued": "true" - } - }, - { - "id": "cdcd6969-a9aa-4de5-adbe-dc83da4184c5", - "name": "client roles", - "protocol": "openid-connect", - "protocolMapper": "oidc-usermodel-client-role-mapper", - "consentRequired": false, - "config": { - "user.attribute": "foo", - "access.token.claim": "true", - "claim.name": "resource_access.${client_id}.roles", - "jsonType.label": "String", - "multivalued": "true" - } - } - ] - }, - { - "id": "2daaac74-636f-4074-87a9-d1aba9dffb96", - "name": "web-origins", - "description": "OpenID Connect scope for add allowed web origins to the access token", - "protocol": "openid-connect", - "attributes": { - "include.in.token.scope": "false", - "display.on.consent.screen": "false", - "consent.screen.text": "" - }, - "protocolMappers": [ - { - "id": "752e035f-038d-46ac-b65d-91f863fdd986", - "name": "allowed web origins", - "protocol": "openid-connect", - "protocolMapper": "oidc-allowed-origins-mapper", - "consentRequired": false, - "config": {} - } - ] - } - ], - "defaultDefaultClientScopes": ["web-origins", "email", "profile", "roles", "role_list"], - "defaultOptionalClientScopes": ["offline_access", "phone", "address", "microprofile-jwt"], - "browserSecurityHeaders": { - "contentSecurityPolicyReportOnly": "", - "xContentTypeOptions": "nosniff", - "xRobotsTag": "none", - "xFrameOptions": "SAMEORIGIN", - "contentSecurityPolicy": "frame-src 'self'; frame-ancestors 'self'; object-src 'none';", - "xXSSProtection": "1; mode=block", - "strictTransportSecurity": "max-age=31536000; includeSubDomains" - }, - "smtpServer": {}, - "eventsEnabled": false, - "eventsListeners": ["jboss-logging"], - "enabledEventTypes": [], - "adminEventsEnabled": false, - "adminEventsDetailsEnabled": false, - "identityProviders": [], - "identityProviderMappers": [], - "components": { - "org.keycloak.services.clientregistration.policy.ClientRegistrationPolicy": [ - { - "id": "827fde01-dc1b-4c1f-a529-9ef833ca3432", - "name": "Allowed Protocol Mapper Types", - "providerId": "allowed-protocol-mappers", - "subType": "authenticated", - "subComponents": {}, - "config": { - "allowed-protocol-mapper-types": [ - "oidc-full-name-mapper", - "saml-user-property-mapper", - "saml-role-list-mapper", - "oidc-address-mapper", - "oidc-usermodel-property-mapper", - "oidc-sha256-pairwise-sub-mapper", - "saml-user-attribute-mapper", - "oidc-usermodel-attribute-mapper" - ] - } - }, - { - "id": "0a429e7e-be7a-46b4-b42a-d1f8b265ff16", - "name": "Allowed Client Scopes", - "providerId": "allowed-client-templates", - "subType": "authenticated", - "subComponents": {}, - "config": { - "allow-default-scopes": ["true"] - } - }, - { - "id": "5a1ff0b4-250f-48ee-8169-abff30cf7534", - "name": "Allowed Client Scopes", - "providerId": "allowed-client-templates", - "subType": "anonymous", - "subComponents": {}, - "config": { - "allow-default-scopes": ["true"] - } - }, - { - "id": "c79f6629-84a9-467c-81d0-63e20b19f916", - "name": "Full Scope Disabled", - "providerId": "scope", - "subType": "anonymous", - "subComponents": {}, - "config": {} - }, - { - "id": "b6b23ef8-96e8-4e2e-8efe-8003057a8d42", - "name": "Max Clients Limit", - "providerId": "max-clients", - "subType": "anonymous", - "subComponents": {}, - "config": { - "max-clients": ["200"] - } - }, - { - "id": "36dfaa02-0252-4448-9cdf-a17abf239f78", - "name": "Trusted Hosts", - "providerId": "trusted-hosts", - "subType": "anonymous", - "subComponents": {}, - "config": { - "host-sending-registration-request-must-match": ["true"], - "client-uris-must-match": ["true"] - } - }, - { - "id": "8216421d-34fb-4726-8331-137217657bdb", - "name": "Allowed Protocol Mapper Types", - "providerId": "allowed-protocol-mappers", - "subType": "anonymous", - "subComponents": {}, - "config": { - "allowed-protocol-mapper-types": [ - "saml-user-attribute-mapper", - "oidc-address-mapper", - "oidc-sha256-pairwise-sub-mapper", - "oidc-usermodel-property-mapper", - "oidc-full-name-mapper", - "oidc-usermodel-attribute-mapper", - "saml-user-property-mapper", - "saml-role-list-mapper" - ] - } - }, - { - "id": "d045f3f9-15e6-4e69-a419-0e7ff8a635ef", - "name": "Consent Required", - "providerId": "consent-required", - "subType": "anonymous", - "subComponents": {}, - "config": {} - } - ], - "org.keycloak.keys.KeyProvider": [ - { - "id": "62707fae-58f9-4fc2-89fb-0c5d212dc3dc", - "name": "rsa-generated", - "providerId": "rsa-generated", - "subComponents": {}, - "config": { - "priority": ["100"] - } - }, - { - "id": "4a8480bc-96fd-4906-a907-f948a73bab38", - "name": "hmac-generated", - "providerId": "hmac-generated", - "subComponents": {}, - "config": { - "priority": ["100"], - "algorithm": ["HS256"] - } - }, - { - "id": "40c01a32-0c0b-4dbb-9595-e5a5c8d26bc4", - "name": "aes-generated", - "providerId": "aes-generated", - "subComponents": {}, - "config": { - "priority": ["100"] - } - } - ] - }, - "internationalizationEnabled": false, - "supportedLocales": [], - "authenticationFlows": [ - { - "id": "491fbbc9-b70b-45bd-8243-2039ae3f115d", - "alias": "Account verification options", - "description": "Method with which to verity the existing account", - "providerId": "basic-flow", - "topLevel": false, - "builtIn": true, - "authenticationExecutions": [ - { - "authenticator": "idp-email-verification", - "requirement": "ALTERNATIVE", - "priority": 10, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "requirement": "ALTERNATIVE", - "priority": 20, - "flowAlias": "Verify Existing Account by Re-authentication", - "userSetupAllowed": false, - "autheticatorFlow": true - } - ] - }, - { - "id": "2c63ad60-76ab-4350-9def-74328bab70d0", - "alias": "Authentication Options", - "description": "Authentication options.", - "providerId": "basic-flow", - "topLevel": false, - "builtIn": true, - "authenticationExecutions": [ - { - "authenticator": "basic-auth", - "requirement": "REQUIRED", - "priority": 10, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "authenticator": "basic-auth-otp", - "requirement": "DISABLED", - "priority": 20, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "authenticator": "auth-spnego", - "requirement": "DISABLED", - "priority": 30, - "userSetupAllowed": false, - "autheticatorFlow": false - } - ] - }, - { - "id": "82b9b584-2243-4893-b58c-4567f34434a6", - "alias": "Browser - Conditional OTP", - "description": "Flow to determine if the OTP is required for the authentication", - "providerId": "basic-flow", - "topLevel": false, - "builtIn": true, - "authenticationExecutions": [ - { - "authenticator": "conditional-user-configured", - "requirement": "REQUIRED", - "priority": 10, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "authenticator": "auth-otp-form", - "requirement": "REQUIRED", - "priority": 20, - "userSetupAllowed": false, - "autheticatorFlow": false - } - ] - }, - { - "id": "e70e7c74-8ab5-411c-b06c-d478a452bee3", - "alias": "Direct Grant - Conditional OTP", - "description": "Flow to determine if the OTP is required for the authentication", - "providerId": "basic-flow", - "topLevel": false, - "builtIn": true, - "authenticationExecutions": [ - { - "authenticator": "conditional-user-configured", - "requirement": "REQUIRED", - "priority": 10, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "authenticator": "direct-grant-validate-otp", - "requirement": "REQUIRED", - "priority": 20, - "userSetupAllowed": false, - "autheticatorFlow": false - } - ] - }, - { - "id": "4f3e6fdd-9b4d-4dc0-946a-1e1ccae7af71", - "alias": "First broker login - Conditional OTP", - "description": "Flow to determine if the OTP is required for the authentication", - "providerId": "basic-flow", - "topLevel": false, - "builtIn": true, - "authenticationExecutions": [ - { - "authenticator": "conditional-user-configured", - "requirement": "REQUIRED", - "priority": 10, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "authenticator": "auth-otp-form", - "requirement": "REQUIRED", - "priority": 20, - "userSetupAllowed": false, - "autheticatorFlow": false - } - ] - }, - { - "id": "aa66c794-f21b-4663-9de1-9e27a7e425ab", - "alias": "Handle Existing Account", - "description": "Handle what to do if there is existing account with same email/username like authenticated identity provider", - "providerId": "basic-flow", - "topLevel": false, - "builtIn": true, - "authenticationExecutions": [ - { - "authenticator": "idp-confirm-link", - "requirement": "REQUIRED", - "priority": 10, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "requirement": "REQUIRED", - "priority": 20, - "flowAlias": "Account verification options", - "userSetupAllowed": false, - "autheticatorFlow": true - } - ] - }, - { - "id": "2d4499a0-399c-4b6c-970c-7b441498f7b9", - "alias": "Reset - Conditional OTP", - "description": "Flow to determine if the OTP should be reset or not. Set to REQUIRED to force.", - "providerId": "basic-flow", - "topLevel": false, - "builtIn": true, - "authenticationExecutions": [ - { - "authenticator": "conditional-user-configured", - "requirement": "REQUIRED", - "priority": 10, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "authenticator": "reset-otp", - "requirement": "REQUIRED", - "priority": 20, - "userSetupAllowed": false, - "autheticatorFlow": false - } - ] - }, - { - "id": "710f4172-56a5-466e-bc75-ad7405ff62b5", - "alias": "User creation or linking", - "description": "Flow for the existing/non-existing user alternatives", - "providerId": "basic-flow", - "topLevel": false, - "builtIn": true, - "authenticationExecutions": [ - { - "authenticatorConfig": "create unique user config", - "authenticator": "idp-create-user-if-unique", - "requirement": "ALTERNATIVE", - "priority": 10, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "requirement": "ALTERNATIVE", - "priority": 20, - "flowAlias": "Handle Existing Account", - "userSetupAllowed": false, - "autheticatorFlow": true - } - ] - }, - { - "id": "da7d3a39-7077-4354-9ffc-5b9f79fbaf0d", - "alias": "Verify Existing Account by Re-authentication", - "description": "Reauthentication of existing account", - "providerId": "basic-flow", - "topLevel": false, - "builtIn": true, - "authenticationExecutions": [ - { - "authenticator": "idp-username-password-form", - "requirement": "REQUIRED", - "priority": 10, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "requirement": "CONDITIONAL", - "priority": 20, - "flowAlias": "First broker login - Conditional OTP", - "userSetupAllowed": false, - "autheticatorFlow": true - } - ] - }, - { - "id": "6285968e-6200-463a-a329-8c60bc8fe9fc", - "alias": "browser", - "description": "browser based authentication", - "providerId": "basic-flow", - "topLevel": true, - "builtIn": true, - "authenticationExecutions": [ - { - "authenticator": "auth-cookie", - "requirement": "ALTERNATIVE", - "priority": 10, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "authenticator": "auth-spnego", - "requirement": "DISABLED", - "priority": 20, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "authenticator": "identity-provider-redirector", - "requirement": "ALTERNATIVE", - "priority": 25, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "requirement": "ALTERNATIVE", - "priority": 30, - "flowAlias": "forms", - "userSetupAllowed": false, - "autheticatorFlow": true - } - ] - }, - { - "id": "10393f04-3922-40db-a622-2655dfcae45d", - "alias": "clients", - "description": "Base authentication for clients", - "providerId": "client-flow", - "topLevel": true, - "builtIn": true, - "authenticationExecutions": [ - { - "authenticator": "client-secret", - "requirement": "ALTERNATIVE", - "priority": 10, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "authenticator": "client-jwt", - "requirement": "ALTERNATIVE", - "priority": 20, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "authenticator": "client-secret-jwt", - "requirement": "ALTERNATIVE", - "priority": 30, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "authenticator": "client-x509", - "requirement": "ALTERNATIVE", - "priority": 40, - "userSetupAllowed": false, - "autheticatorFlow": false - } - ] - }, - { - "id": "4e5e164e-3c7e-4ca5-a10c-d7b817a7d468", - "alias": "direct grant", - "description": "OpenID Connect Resource Owner Grant", - "providerId": "basic-flow", - "topLevel": true, - "builtIn": true, - "authenticationExecutions": [ - { - "authenticator": "direct-grant-validate-username", - "requirement": "REQUIRED", - "priority": 10, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "authenticator": "direct-grant-validate-password", - "requirement": "REQUIRED", - "priority": 20, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "requirement": "CONDITIONAL", - "priority": 30, - "flowAlias": "Direct Grant - Conditional OTP", - "userSetupAllowed": false, - "autheticatorFlow": true - } - ] - }, - { - "id": "80f88b0b-70de-4e4c-ae56-0293558301c5", - "alias": "docker auth", - "description": "Used by Docker clients to authenticate against the IDP", - "providerId": "basic-flow", - "topLevel": true, - "builtIn": true, - "authenticationExecutions": [ - { - "authenticator": "docker-http-basic-authenticator", - "requirement": "REQUIRED", - "priority": 10, - "userSetupAllowed": false, - "autheticatorFlow": false - } - ] - }, - { - "id": "821af41a-6e77-4e8c-85a6-0280d5268909", - "alias": "first broker login", - "description": "Actions taken after first broker login with identity provider account, which is not yet linked to any Keycloak account", - "providerId": "basic-flow", - "topLevel": true, - "builtIn": true, - "authenticationExecutions": [ - { - "authenticatorConfig": "review profile config", - "authenticator": "idp-review-profile", - "requirement": "REQUIRED", - "priority": 10, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "requirement": "REQUIRED", - "priority": 20, - "flowAlias": "User creation or linking", - "userSetupAllowed": false, - "autheticatorFlow": true - } - ] - }, - { - "id": "c4058fb0-ad93-4595-96ef-7d4bc5cbef4d", - "alias": "forms", - "description": "Username, password, otp and other auth forms.", - "providerId": "basic-flow", - "topLevel": false, - "builtIn": true, - "authenticationExecutions": [ - { - "authenticator": "auth-username-password-form", - "requirement": "REQUIRED", - "priority": 10, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "requirement": "CONDITIONAL", - "priority": 20, - "flowAlias": "Browser - Conditional OTP", - "userSetupAllowed": false, - "autheticatorFlow": true - } - ] - }, - { - "id": "a2a1d056-2521-498f-b345-b7db56f9342c", - "alias": "http challenge", - "description": "An authentication flow based on challenge-response HTTP Authentication Schemes", - "providerId": "basic-flow", - "topLevel": true, - "builtIn": true, - "authenticationExecutions": [ - { - "authenticator": "no-cookie-redirect", - "requirement": "REQUIRED", - "priority": 10, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "requirement": "REQUIRED", - "priority": 20, - "flowAlias": "Authentication Options", - "userSetupAllowed": false, - "autheticatorFlow": true - } - ] - }, - { - "id": "13e68e1b-4b44-4f21-a253-5b2dea24404b", - "alias": "registration", - "description": "registration flow", - "providerId": "basic-flow", - "topLevel": true, - "builtIn": true, - "authenticationExecutions": [ - { - "authenticator": "registration-page-form", - "requirement": "REQUIRED", - "priority": 10, - "flowAlias": "registration form", - "userSetupAllowed": false, - "autheticatorFlow": true - } - ] - }, - { - "id": "e7588789-22d4-459b-96d6-1b480520f487", - "alias": "registration form", - "description": "registration form", - "providerId": "form-flow", - "topLevel": false, - "builtIn": true, - "authenticationExecutions": [ - { - "authenticator": "registration-user-creation", - "requirement": "REQUIRED", - "priority": 20, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "authenticator": "registration-profile-action", - "requirement": "REQUIRED", - "priority": 40, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "authenticator": "registration-password-action", - "requirement": "REQUIRED", - "priority": 50, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "authenticator": "registration-recaptcha-action", - "requirement": "DISABLED", - "priority": 60, - "userSetupAllowed": false, - "autheticatorFlow": false - } - ] - }, - { - "id": "8dc399ef-cf7d-46d5-9688-678c146ea8c4", - "alias": "reset credentials", - "description": "Reset credentials for a user if they forgot their password or something", - "providerId": "basic-flow", - "topLevel": true, - "builtIn": true, - "authenticationExecutions": [ - { - "authenticator": "reset-credentials-choose-user", - "requirement": "REQUIRED", - "priority": 10, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "authenticator": "reset-credential-email", - "requirement": "REQUIRED", - "priority": 20, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "authenticator": "reset-password", - "requirement": "REQUIRED", - "priority": 30, - "userSetupAllowed": false, - "autheticatorFlow": false - }, - { - "requirement": "CONDITIONAL", - "priority": 40, - "flowAlias": "Reset - Conditional OTP", - "userSetupAllowed": false, - "autheticatorFlow": true - } - ] - }, - { - "id": "47ab5a7a-f67a-4a66-bdac-932ee230000d", - "alias": "saml ecp", - "description": "SAML ECP Profile Authentication Flow", - "providerId": "basic-flow", - "topLevel": true, - "builtIn": true, - "authenticationExecutions": [ - { - "authenticator": "http-basic-authenticator", - "requirement": "REQUIRED", - "priority": 10, - "userSetupAllowed": false, - "autheticatorFlow": false - } - ] - } - ], - "authenticatorConfig": [ - { - "id": "b12be521-4e2b-42f0-a1a2-f1ba47ab4854", - "alias": "create unique user config", - "config": { - "require.password.update.after.registration": "false" - } - }, - { - "id": "58bf2d56-1c45-4acc-9005-23b978d961d7", - "alias": "review profile config", - "config": { - "update.profile.on.first.login": "missing" - } - } - ], - "requiredActions": [ - { - "alias": "CONFIGURE_TOTP", - "name": "Configure OTP", - "providerId": "CONFIGURE_TOTP", - "enabled": true, - "defaultAction": false, - "priority": 10, - "config": {} - }, - { - "alias": "terms_and_conditions", - "name": "Terms and Conditions", - "providerId": "terms_and_conditions", - "enabled": false, - "defaultAction": false, - "priority": 20, - "config": {} - }, - { - "alias": "UPDATE_PASSWORD", - "name": "Update Password", - "providerId": "UPDATE_PASSWORD", - "enabled": true, - "defaultAction": false, - "priority": 30, - "config": {} - }, - { - "alias": "UPDATE_PROFILE", - "name": "Update Profile", - "providerId": "UPDATE_PROFILE", - "enabled": true, - "defaultAction": false, - "priority": 40, - "config": {} - }, - { - "alias": "VERIFY_EMAIL", - "name": "Verify Email", - "providerId": "VERIFY_EMAIL", - "enabled": true, - "defaultAction": false, - "priority": 50, - "config": {} - }, - { - "alias": "delete_account", - "name": "Delete Account", - "providerId": "delete_account", - "enabled": false, - "defaultAction": false, - "priority": 60, - "config": {} - }, - { - "alias": "update_user_locale", - "name": "Update User Locale", - "providerId": "update_user_locale", - "enabled": true, - "defaultAction": false, - "priority": 1000, - "config": {} - } - ], - "browserFlow": "browser", - "registrationFlow": "registration", - "directGrantFlow": "direct grant", - "resetCredentialsFlow": "reset credentials", - "clientAuthenticationFlow": "clients", - "dockerAuthenticationFlow": "docker auth", - "attributes": { - "clientOfflineSessionMaxLifespan": "0", - "clientSessionIdleTimeout": "0", - "clientSessionMaxLifespan": "0", - "clientOfflineSessionIdleTimeout": "0" - }, - "keycloakVersion": "12.0.4", - "userManagedAccessAllowed": false - } \ No newline at end of file diff --git a/keycloak-setup-config/192.168.56.1.nip.io/users.json b/keycloak-setup-config/192.168.56.1.nip.io/users.json deleted file mode 100644 index 8d199a34b36c007c425e7c617c17cd3502419ec6..0000000000000000000000000000000000000000 --- a/keycloak-setup-config/192.168.56.1.nip.io/users.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "realm": "jhipster", - "users": [ - { - "id": "4c973896-5761-41fc-8217-07c5d13a004b", - "createdTimestamp": 1505479415590, - "username": "admin", - "enabled": true, - "totp": false, - "emailVerified": true, - "firstName": "Admin", - "lastName": "Administrator", - "email": "admin@localhost", - "credentials": [ - { - "id": "b860462b-9b02-48ba-9523-d3a8926a917b", - "type": "password", - "createdDate": 1505479429154, - "secretData": "{\"value\":\"4pf9K2jWSCcHC+CwsZP/qidN5pSmDUe6AX6wBerSGdBVKkExay8MWKx+EKmaaObZW6FVsD8vdW/ZsyUFD9gJ1Q==\",\"salt\":\"1/qNkZ5kr77jOMOBPBogGw==\"}", - "credentialData": "{\"hashIterations\":27500,\"algorithm\":\"pbkdf2-sha256\"}" - } - ], - "disableableCredentialTypes": [], - "requiredActions": [], - "realmRoles": ["offline_access", "uma_authorization"], - "clientRoles": { - "account": ["view-profile", "manage-account"] - }, - "notBefore": 0, - "groups": ["/Admins", "/Users"] - }, - { - "id": "c4af4e2f-b432-4c3b-8405-cca86cd5b97b", - "createdTimestamp": 1505479373742, - "username": "user", - "enabled": true, - "totp": false, - "emailVerified": true, - "firstName": "", - "lastName": "User", - "email": "user@localhost", - "credentials": [ - { - "id": "7821832b-1e82-45a2-b8d3-f1a6ad909e64", - "type": "password", - "createdDate": 1505479392766, - "secretData": "{\"value\":\"MbKsMgWPnZyImih8s4SaoCSCq+XIY/c6S9F93sXEidHF1TjPWxCqMkec0+o3860CMLXHt3az61cIJOWI0FW9aw==\",\"salt\":\"fmpBI1r8R1u75hDLMUlwBw==\"}", - "credentialData": "{\"hashIterations\":27500,\"algorithm\":\"pbkdf2-sha256\"}" - } - ], - "disableableCredentialTypes": [], - "requiredActions": [], - "realmRoles": ["offline_access", "uma_authorization"], - "clientRoles": { - "account": ["view-profile", "manage-account"] - }, - "notBefore": 0, - "groups": ["/Users"] - } - ] -} \ No newline at end of file diff --git a/piacere-build/docker-compose.yaml b/piacere-build/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..df545dc162d861f022eaff2fe22feabd097e6619 --- /dev/null +++ b/piacere-build/docker-compose.yaml @@ -0,0 +1,9 @@ +services: + iop-optimizer: + build: + context: ${IOP_BASE_PATH}git/iop-optimizer + dockerfile: Dockerfile + cache_from: + - ${IMAGE_IOP_OPTIMIZER_CACHE:?err} + args: + BUILDKIT_INLINE_CACHE: 1 # For multistage docker diff --git a/release/docker-compose-gateway.yaml b/release/docker-compose-gateway.yaml new file mode 100644 index 0000000000000000000000000000000000000000..bf7566ed1786f1a2da3045b1de9afd93d0af76a5 --- /dev/null +++ b/release/docker-compose-gateway.yaml @@ -0,0 +1,3 @@ +services: + iop-gateway: + image: optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iop-gateway:y2 diff --git a/release/docker-compose.yaml b/release/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d3326a030abfe52a075f44bec3bf4e656337e340 --- /dev/null +++ b/release/docker-compose.yaml @@ -0,0 +1,3 @@ +services: + iop-optimizer: + image: ${IMAGE_IOP_OPTIMIZER:?err}