diff --git a/.env b/.env index a1ab798461bb0044c7a03dada696539ce140ef19..e0d8e543a5abc487924e7fc507bda9be95f37cd9 100644 --- a/.env +++ b/.env @@ -1,9 +1,10 @@ -ADMIN_USER=piacere -ADMIN_PASSWORD=piacerePassword +ADMIN_USER=admin +ADMIN_PASSWORD=projectPassword HTTPS_PORT=443 SERVER_HOST=ci.piacere.digital.tecnalia.dev -COMPOSE_PROJECT_NAME=piacere-iec-production +COMPOSE_PROJECT_NAME=iec IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3 IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3 IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3 -COMPOSE_FILE=docker-compose.yaml:docker-compose-jhipster-network-external.yaml:docker-compose-traefik-network-external.yaml:release/docker-compose.yaml +IMAGE_IEC_INFLUXDBCLIENT=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3 +COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-jhipster-network-external.yaml:release/docker-compose.yaml diff --git a/.env.gen b/.env.gen index 8fd0ecdf7216e42d9125adca83e6bfa59d493850..d1ea828e447de3aea0303d40a5b8e1c0de5896ea 100644 --- a/.env.gen +++ b/.env.gen @@ -2,23 +2,41 @@ # 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 +#### 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 () +# - development: 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 (local:run-build-cache) +# - release: purpouse is to generate images (that do not use BUILDKIT_INLINE_CACHE 1) tagged for the clients/pilots usage (release:run-build-release) +# - prod: purpose is to generate non building docker-compose that uses the release to deploy on generic client (prod:run-release) +# - test: the purpouse is to test from the cache images the correct behaviour without exposing ports (test:run-cache) # types of building +# - run-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. +# - run-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. # - 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 +# - build-release: it focuses in the generation of images for distribution it avoid using BUILDKIT_INLINE_CACHE 1 to reduce the size, it will not use cache from. +# - run-cache: it runs using cache images +# - run-release: it runs using release images # default enviroment -# _ENVIRONMENTS=_ENV_LOCAL_:build-cache:.env.local +# __ENVIRONMENTS=development:run-build-cache # to add more enviroments use split with ";" -_ENVIRONMENTS=_ENV_LOCAL_:build-cache:.env.local;_ENV_RELEASE_:build-release:.env.release;_ENV_DEPLOY_:release:.env;_ENV_PIACERE_:release:.env.piacere +__ENVIRONMENTS=development:run-build-cache;prod:run-release;release:build-release + +#### Modules managed #### +# this will create individual docker composes that enables the individual usage of the modules through the docker-compose command and specific env files i.e. +# __MODULES=traefik;step-ca +# will enable the following docker-compose commands +# docker-compose --env-file .env/modules/traefik/prod ----project-directory . up -d +# __MODULES=traefik;step-ca +__MODULES=iec + +#### default environment #### +# __DEFAULT_ENVIRONMENT=.envs/global/prod + +#### default environment #### +# __DEFAULT_DEVELOPMENT_ENVIRONMENT=.envs/global/development + +#### default release environment #### +# __DEFAULT_RELEASE_ENVIRONMENT=.envs/global/release #### Common image related #### DOCKER_REGISTRY_CACHE_PREFIX=cache.euve.digital.tecnalia.dev:5000 @@ -32,56 +50,65 @@ DOCKER_REGISTRY_CACHE_VERSION=latest ### Common Traefik related ### TRAEFIK_NETWORK_NAME=traefik_network TRAEFIK_HTTPS_ENTRYPOINT_NAME=websecure -TRAEFIK_HTTP_ENTRYPOINT_NAME=web +# TRAEFIK_HTTP_ENTRYPOINT_NAME=web #### Common Production related #### -ADMIN_USER=piacere -ADMIN_PASSWORD=piacerePassword +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=project.org SERVER_HOST=ci.piacere.digital.tecnalia.dev #### Platform Specific #### -TZ=Madrid - -#### Platform Specific path #### +# TZ=Madrid 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-iec-production +COMPOSE_PROJECT_NAME=iec # _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_JHIPSTER_NETWORK=docker-compose-jhipster-network-external.yaml +COMPOSE_FILE_BASE= COMPOSE_FILE= # COMPOSE_FILE Is generated automatically -COMPOSE_FILE_BASE_NETWORK=docker-compose-traefik-network-external.yaml - -IEC_CONFIG_PATH= -IEC_BASE_PATH= - -IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3 -IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3 -IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3 -IMAGE_IEC_MYSQL_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3 -IMAGE_IEC_BACKEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3 -IMAGE_IEC_FRONTEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3 - -_ENV_LOCAL_SERVER_HOST=192.168.56.1.nip.io -_ENV_LOCAL_COMPOSE_FILE_BASE_EXPOSE_DEV=docker-compose-dev-expose.yaml -_ENV_LOCAL_COMPOSE_FILE_BASE_LOCAL_JHIPSTER_REGISTRY_VOLUMES=docker-compose-jhipster-registry-volumes.yaml -_ENV_LOCAL_COMPOSE_FILE_BASE_LOCAL_JHIPSTER_REGISTRY=git/jhipster-registry/docker-compose.yaml -_ENV_LOCAL_COMPOSE_FILE_BASE_LOCAL_JHIPSTER_REGISTRY_DEV=git/jhipster-registry/docker-compose-dev.yaml -_ENV_LOCAL_JHIPSTER_REGISTRY_CONFIG_PATH=git/jhipster-registry/ - -_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 +__iec__COMPOSE_FILE_BASE=docker-compose.yaml +__iec__COMPOSE_FILE_BASE_NETWORK=docker-compose-traefik-network-external.yaml + +__iec__IEC_CONFIG_PATH= +__iec__IEC_BASE_PATH= + +__iec_development__SERVER_HOST=192.168.56.1.nip.io +__iec_development__COMPOSE_FILE_BASE_EXPOSE_DEV=docker-compose-dev-expose.yaml +__iec_development__COMPOSE_FILE_BASE_LOCAL_JHIPSTER_REGISTRY_VOLUMES=docker-compose-jhipster-registry-volumes.yaml +__iec_development__COMPOSE_FILE_BASE_LOCAL_JHIPSTER_REGISTRY=git/jhipster-registry/docker-compose.yaml +__iec_development__COMPOSE_FILE_BASE_LOCAL_JHIPSTER_REGISTRY_DEV=git/jhipster-registry/docker-compose-dev.yaml +__iec_development__JHIPSTER_REGISTRY_CONFIG_PATH=git/jhipster-registry/ + +__iec__IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3 +__iec__IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3 +__iec__IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3 +__iec__IMAGE_IEC_INFLUXDBCLIENT=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3 +__iec__IMAGE_IEC_MYSQL_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3 +__iec__IMAGE_IEC_BACKEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3 +__iec__IMAGE_IEC_FRONTEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3 +__iec__IMAGE_IEC_INFLUXDBCLIENT_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3 + +__iec__COMPOSE_FILE_BASE_JHIPSTER_NETWORK=docker-compose-jhipster-network-external.yaml + +__iec_release__COMPOSE_FILE_BASE_PIACERE_BUILD=piacere-build/docker-compose.yaml +__iec_release__COMPOSE_FILE_BASE_PIACERE_RELEASE=release/docker-compose.yaml +__iec_release__COMPOSE_FILE_BASE_ARTIFACTORY=docker-compose-artifactory.yaml +__iec_release__COMPOSE_FILE_BASE_TRAEFIK_NETWORK=docker-compose-traefik-network-internal.yaml diff --git a/.envs/global/development b/.envs/global/development new file mode 100644 index 0000000000000000000000000000000000000000..b0891b9d003dd58b4d686fd8633dee0fcd3c77df --- /dev/null +++ b/.envs/global/development @@ -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=192.168.56.1.nip.io +EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem +COMPOSE_PROJECT_NAME=iec +IEC_CONFIG_PATH= +IEC_BASE_PATH= +JHIPSTER_REGISTRY_CONFIG_PATH=git/jhipster-registry/ +COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-dev-expose.yaml:docker-compose-jhipster-registry-volumes.yaml:git/jhipster-registry/docker-compose.yaml:git/jhipster-registry/docker-compose-dev.yaml:docker-compose-jhipster-network-external.yaml:build/docker-compose.yaml:build/inline-cache/docker-compose.yaml:build/image/docker-compose.yaml diff --git a/.envs/global/prod b/.envs/global/prod new file mode 100644 index 0000000000000000000000000000000000000000..e0d8e543a5abc487924e7fc507bda9be95f37cd9 --- /dev/null +++ b/.envs/global/prod @@ -0,0 +1,10 @@ +ADMIN_USER=admin +ADMIN_PASSWORD=projectPassword +HTTPS_PORT=443 +SERVER_HOST=ci.piacere.digital.tecnalia.dev +COMPOSE_PROJECT_NAME=iec +IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3 +IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3 +IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3 +IMAGE_IEC_INFLUXDBCLIENT=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3 +COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-jhipster-network-external.yaml:release/docker-compose.yaml diff --git a/.envs/global/release b/.envs/global/release new file mode 100644 index 0000000000000000000000000000000000000000..94a817160f00ebcc04c5aad6cedb63448be64367 --- /dev/null +++ b/.envs/global/release @@ -0,0 +1,18 @@ +DOCKER_REGISTRY_CACHE_PREFIX=cache.euve.digital.tecnalia.dev:5000 +DOCKER_REGISTRY_CACHE_VERSION=latest +TRAEFIK_NETWORK_NAME=traefik_network +ADMIN_USER=admin +ADMIN_PASSWORD=projectPassword +HTTPS_PORT=443 +SERVER_HOST=ci.piacere.digital.tecnalia.dev +EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem +COMPOSE_PROJECT_NAME=iec +IEC_BASE_PATH= +IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3 +IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3 +IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3 +IMAGE_IEC_INFLUXDBCLIENT=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3 +IMAGE_IEC_MYSQL_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3 +IMAGE_IEC_BACKEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3 +IMAGE_IEC_FRONTEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3 +COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-jhipster-network-external.yaml:piacere-build/docker-compose.yaml:release/docker-compose.yaml:docker-compose-artifactory.yaml:docker-compose-traefik-network-internal.yaml:build/docker-compose.yaml diff --git a/.envs/modules/iec/development b/.envs/modules/iec/development new file mode 100644 index 0000000000000000000000000000000000000000..b0891b9d003dd58b4d686fd8633dee0fcd3c77df --- /dev/null +++ b/.envs/modules/iec/development @@ -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=192.168.56.1.nip.io +EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem +COMPOSE_PROJECT_NAME=iec +IEC_CONFIG_PATH= +IEC_BASE_PATH= +JHIPSTER_REGISTRY_CONFIG_PATH=git/jhipster-registry/ +COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-dev-expose.yaml:docker-compose-jhipster-registry-volumes.yaml:git/jhipster-registry/docker-compose.yaml:git/jhipster-registry/docker-compose-dev.yaml:docker-compose-jhipster-network-external.yaml:build/docker-compose.yaml:build/inline-cache/docker-compose.yaml:build/image/docker-compose.yaml diff --git a/.envs/modules/iec/prod b/.envs/modules/iec/prod new file mode 100644 index 0000000000000000000000000000000000000000..e0d8e543a5abc487924e7fc507bda9be95f37cd9 --- /dev/null +++ b/.envs/modules/iec/prod @@ -0,0 +1,10 @@ +ADMIN_USER=admin +ADMIN_PASSWORD=projectPassword +HTTPS_PORT=443 +SERVER_HOST=ci.piacere.digital.tecnalia.dev +COMPOSE_PROJECT_NAME=iec +IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3 +IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3 +IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3 +IMAGE_IEC_INFLUXDBCLIENT=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3 +COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-jhipster-network-external.yaml:release/docker-compose.yaml diff --git a/.envs/modules/iec/release b/.envs/modules/iec/release new file mode 100644 index 0000000000000000000000000000000000000000..94a817160f00ebcc04c5aad6cedb63448be64367 --- /dev/null +++ b/.envs/modules/iec/release @@ -0,0 +1,18 @@ +DOCKER_REGISTRY_CACHE_PREFIX=cache.euve.digital.tecnalia.dev:5000 +DOCKER_REGISTRY_CACHE_VERSION=latest +TRAEFIK_NETWORK_NAME=traefik_network +ADMIN_USER=admin +ADMIN_PASSWORD=projectPassword +HTTPS_PORT=443 +SERVER_HOST=ci.piacere.digital.tecnalia.dev +EXTRA_CA_URL=https://git.code.tecnalia.com/smartdatalab/ca/-/raw/master/ca.crt.pem +COMPOSE_PROJECT_NAME=iec +IEC_BASE_PATH= +IMAGE_IEC_MYSQL=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3 +IMAGE_IEC_BACKEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3 +IMAGE_IEC_FRONTEND=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3 +IMAGE_IEC_INFLUXDBCLIENT=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-influxdbclient:y3 +IMAGE_IEC_MYSQL_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-mysql:y3 +IMAGE_IEC_BACKEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-backend:y3 +IMAGE_IEC_FRONTEND_CACHE=optima-piacere-docker-dev.artifact.tecnalia.com/wp5/iec-frontend:y3 +COMPOSE_FILE=docker-compose.yaml:docker-compose-traefik-network-external.yaml:docker-compose-jhipster-network-external.yaml:piacere-build/docker-compose.yaml:release/docker-compose.yaml:docker-compose-artifactory.yaml:docker-compose-traefik-network-internal.yaml:build/docker-compose.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9937bc2e2293e4995924209cf2b1418c326c51e4..d62f06bf81b15db64dbd8f9632e514fb1c713d1a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -57,8 +57,8 @@ stages: DOCKER_BUILDKIT: 1 COMPOSE_DOCKER_CLI_BUILD: 1 DOCKER_COMPOSE_PATH: "." - DOCKER_COMPOSE_ENV_FILE_CACHE: ".env.piacere" - DOCKER_COMPOSE_ENV_FILE: ".env.piacere" + DOCKER_COMPOSE_ENV_FILE_CACHE: ".envs/global/release" + DOCKER_COMPOSE_ENV_FILE: ".envs/global/release" before_script: - !reference [.artifactory-login] script: diff --git a/build/docker-compose.yaml b/build/docker-compose.yaml index 39c9b162beb1b9b2bd1d2565f791e7e8b76829d8..5d1828d739ed515cb1efd1928b72ddada85222db 100644 --- a/build/docker-compose.yaml +++ b/build/docker-compose.yaml @@ -23,3 +23,16 @@ services: EXTRA_CA_URL: ${EXTRA_CA_URL:?err} cache_from: - ${DOCKER_REGISTRY_CACHE_PREFIX}/piacere/iec-frontend:${DOCKER_REGISTRY_CACHE_VERSION:?err} + + iec-influxdbclient: + build: + args: + - ENABLED=1 + - LISTEN_INTERVAL=60 + - RANGE_START=-30m + - TELEGRAF_INTERVAL=10s + - AGGREGATE_SAMPLING=60s + context: ${IEC_BASE_PATH}git/iec-influxdbclient + dockerfile: Dockerfile + cache_from: + - ${DOCKER_REGISTRY_CACHE_PREFIX}/piacere/iec-frontend:${DOCKER_REGISTRY_CACHE_VERSION:?err} diff --git a/build/image/docker-compose.yaml b/build/image/docker-compose.yaml index 206ed7976253901fceb9cf22b74c3a585e36af81..da3e12db0339f62e0bacd5e704e04034f8367a67 100644 --- a/build/image/docker-compose.yaml +++ b/build/image/docker-compose.yaml @@ -7,3 +7,6 @@ services: iec-frontend: image: ${DOCKER_REGISTRY_CACHE_PREFIX}/piacere/iec-frontend:${DOCKER_REGISTRY_CACHE_VERSION:?err} + + iec-influxdbclient: + image: ${DOCKER_REGISTRY_CACHE_PREFIX}/piacere/iec-influxdbclient:${DOCKER_REGISTRY_CACHE_VERSION:?err} diff --git a/build/inline-cache/docker-compose.yaml b/build/inline-cache/docker-compose.yaml index 956fffde0d4c37ada3813fd864647538f068ea33..607e912f8bf7958a46690c66bfd6474d502c317a 100644 --- a/build/inline-cache/docker-compose.yaml +++ b/build/inline-cache/docker-compose.yaml @@ -13,3 +13,8 @@ services: build: args: BUILDKIT_INLINE_CACHE: 1 # For multistage docker + + iec-influxdbclient: + build: + args: + BUILDKIT_INLINE_CACHE: 1 # For multistage docker diff --git a/docker-compose-artifactory.yaml b/docker-compose-artifactory.yaml index 6786dc9adde4e61d182c29cd940a80087e7e8fa8..1142f08b9e70563ca6d8c30e68a7f04dc37c3ff4 100644 --- a/docker-compose-artifactory.yaml +++ b/docker-compose-artifactory.yaml @@ -11,4 +11,8 @@ services: build: labels: com.jfrog.artifactory.retention.maxCount: 6 + iec-influxdbclient: + build: + labels: + com.jfrog.artifactory.retention.maxCount: 6 diff --git a/docker-compose.yaml b/docker-compose.yaml index 41dbaa8c01d147775d01acf108774a4dfae0d00b..558d2d3bcd5df4feaf5469a0a08984d0fd317375 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -5,7 +5,7 @@ services: volumes: - iec-mysql_data:/var/lib/mysql networks: - default: + traefik_network: iec-backend: restart: always @@ -17,8 +17,7 @@ services: # SPRING_R2DBC_URL: r2dbc:mysql://iec-mysql:3306/iecBackend?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true # SPRING_LIQUIBASE_URL: jdbc:mysql://iec-mysql:3306/iecBackend?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true networks: - default: - jhipster_network: + traefik_network: iec-frontend: restart: always @@ -26,8 +25,6 @@ services: GLOBAL_PASSWORD: ${ADMIN_PASSWORD} JHIPSTER_CORS_ALLOWEDORIGINS: "https://iec.${SERVER_HOST:?err}:${HTTPS_PORT}" networks: - default: - jhipster_network: traefik_network: labels: - "traefik.enable=true" @@ -35,8 +32,22 @@ services: - "traefik.http.routers.iec-frontend.entrypoints=websecure" - "traefik.http.routers.iec-frontend.rule=Host(`iec.${SERVER_HOST:?err}`)" + # PIACERE InfluxDB Client + iec-influxdbclient: + restart: always + environment: + - INFLUXDB_URL=https://influxdb.pm.ci.piacere.digital.tecnalia.dev + - INFLUXDB_TOKEN=Fu7iwOeqhYOd6A_1Fg9GKSUNKBwl-FEAWn8cUTXuMUwAXXge4WETVAxg4iRh_l9vdYZN9klkf3aY250h6wyNKg== + - INFLUXDB_ORGANIZATION=piacere + - INFLUXDB_BUCKET=bucket + - INFLUXDB_MEASUREMENT=psl + - INFLUXDB_FIELD=input_system_availability_percent + - MYSQL_HOST=iec-mysql + - MYSQL_USER=root + - MYSQL_PASSWORD= + - MYSQL_DB=iecbackend + networks: + traefik_network: + volumes: iec-mysql_data: - -networks: - default: diff --git a/git/iec-Influxdbclient/Dockerfile b/git/iec-Influxdbclient/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..16e3e1ecba2e7d5d1b6f3a1a6ad1cdce7369fb9e --- /dev/null +++ b/git/iec-Influxdbclient/Dockerfile @@ -0,0 +1,24 @@ +FROM python:3.9-slim-bullseye + +ARG ENABLED +ARG LISTEN_INTERVAL +ARG RANGE_START +ARG TELEGRAF_INTERVAL +ARG AGGREGATE_SAMPLING + +RUN mkdir -p /piacere_influxdb_client +WORKDIR /piacere_influxdb_client + +COPY . /piacere_influxdb_client + +RUN apt-get update && \ + pip3 install --no-cache-dir -r requirements.txt && \ + sed -i "s|\"ENABLED\"|$ENABLED|g" /piacere_influxdb_client/config/config.ini && \ + sed -i "s|\"LISTEN_INTERVAL\"|$LISTEN_INTERVAL|g" /piacere_influxdb_client/config/config.ini && \ + sed -i "s|\"RANGE_START\"|$RANGE_START|g" /piacere_influxdb_client/config/config.ini && \ + sed -i "s|\"TELEGRAF_INTERVAL\"|$TELEGRAF_INTERVAL|g" /piacere_influxdb_client/config/config.ini && \ + sed -i "s|\"AGGREGATE_SAMPLING\"|$AGGREGATE_SAMPLING|g" /piacere_influxdb_client/config/config.ini + +ENV PATH /piacere_influxdb_client:$PATH + +ENTRYPOINT ["sh", "./init.sh"] \ No newline at end of file diff --git a/git/iec-Influxdbclient/config/config.ini b/git/iec-Influxdbclient/config/config.ini new file mode 100644 index 0000000000000000000000000000000000000000..ce5923fb44db7633097709bae1b864a42c3515bb --- /dev/null +++ b/git/iec-Influxdbclient/config/config.ini @@ -0,0 +1,6 @@ +[PIACERE-INFLUXDB-CLIENT] +piacere.influxdb.enabled = "ENABLED" +piacere.influxdb.sleep = "LISTEN_INTERVAL" +piacere.influxdb.range.start = "RANGE_START" +piacere.influxdb.telegraf.interval = "TELEGRAF_INTERVAL" +piacere.influxdb.aggregate.sampling = "AGGREGATE_SAMPLING" \ No newline at end of file diff --git a/git/iec-Influxdbclient/init.sh b/git/iec-Influxdbclient/init.sh new file mode 100644 index 0000000000000000000000000000000000000000..cd1682637434407738d74055355e07794c3e79b7 --- /dev/null +++ b/git/iec-Influxdbclient/init.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +python piacere_influxdb_client.py \ No newline at end of file diff --git a/git/iec-Influxdbclient/piacere_influxdb_client.py b/git/iec-Influxdbclient/piacere_influxdb_client.py new file mode 100644 index 0000000000000000000000000000000000000000..7dd6aa5e5b1e53bf4994b7194f1e00f1aafa4f1a --- /dev/null +++ b/git/iec-Influxdbclient/piacere_influxdb_client.py @@ -0,0 +1,182 @@ +import configparser +import influxdb_client +import json +import logging +import os +import pymysql +import time + +from datetime import datetime + +from influxdb_client import InfluxDBClient, Point, WritePrecision +from influxdb_client.client.write_api import SYNCHRONOUS + +import templates.influxdb_query_templates as influxdb_query_templates +import templates.mysql_query_templates as mysql_query_templates + + +# Configure the logging level +logging.basicConfig(level = logging.INFO) + +# Create the config object and read config.ini file +config = configparser.ConfigParser() +config.read('config/config.ini') + + +# Function: commitToDatabase +def commitToDatabase(query_result): + # logging.info(json.dumps(query_result, indent = 4)) + conn = None + try: + # Connect to the database + conn = pymysql.connect( + host = os.environ.get("MYSQL_HOST"), + user = os.environ.get("MYSQL_USER"), + password = os.environ.get("MYSQL_PASSWORD"), + db = os.environ.get("MYSQL_DB")) + + # Declare the custom cursor and update the database + cursor = conn.cursor() + if query_result: + # Transform the influxdb query result, replacing the service name by the service id + # and discarding the entries whose service id is null + data_to_process = {} + cursor.execute(mysql_query_templates.mysql_select_services_query) + services = cursor.fetchall() + if services and len(services) > 0: + for key in query_result: + service_id = None + for service in services: + if query_result[key]['service'] == service[1]: + service_id = service[0] + break + if service_id: + query_result[key]['service'] = service_id + data_to_process[key] = query_result[key] + + # Fetch the instances, and separate them into active and inactive + logging.info("") + logging.info(" > Data to be processed:") + logging.info(json.dumps(data_to_process, indent = 4)) + cursor.execute(mysql_query_templates.mysql_select_instances_query) + instances = cursor.fetchall() + active_instances = [] + inactive_instances = [] + if instances and len(instances) > 0: + for instance in instances: + if instance[4]: + inactive_instances.append(instance) + else: + active_instances.append(instance) + logging.info("") + logging.info(" > Checking instances...") + logging.info(" > Active instances: " + str(len(active_instances))) + logging.info(" > Inactive instances: " + str(len(inactive_instances))) + + # Set all the active instances to inactive + if active_instances and len(active_instances) > 0: + logging.info(" > Setting the active instances to inactive...") + cursor.execute(mysql_query_templates.mysql_update_instances_to_inactive_query % (datetime.now().strftime('%Y-%m-%d %H:%M:%S'))) + conn.commit() + + # Search the result of the influxdb query in active and inactive instance lists + foundInActiveInstances = False + foundInInactiveInstances = False + for key in data_to_process: + for instance in active_instances: + if key == instance[1] and data_to_process[key]['instance'] == instance[2] and data_to_process[key]['service'] == instance[5] and data_to_process[key]['host'] == instance[3]: + foundInActiveInstances = True + break + for instance in inactive_instances: + if key == instance[1] and data_to_process[key]['instance'] == instance[2] and data_to_process[key]['service'] == instance[5] and data_to_process[key]['host'] == instance[3]: + foundInInactiveInstances = True + break + + # If the instance is not found, insert into database. If the instances is found as active, update database + if foundInActiveInstances is False and foundInInactiveInstances is False: + logging.info(" > Inserting '" + data_to_process[key]['instance'] + "' instance...") + cursor.execute(mysql_query_templates.mysql_insert_instance_query % (key, data_to_process[key]['instance'], data_to_process[key]['host'], data_to_process[key]['availability'], datetime.now().strftime('%Y-%m-%d %H:%M:%S'), datetime.now().strftime('%Y-%m-%d %H:%M:%S'), data_to_process[key]['service'])) + conn.commit() + logging.info(" > The instance was inserted successfully!") + logging.info("") + elif foundInActiveInstances is True: + logging.info(" > Updating '" + data_to_process[key]['instance'] + "' instance...") + cursor.execute(mysql_query_templates.mysql_update_instance_query % (data_to_process[key]['availability'], datetime.now().strftime('%Y-%m-%d %H:%M:%S'), key, data_to_process[key]['instance'], data_to_process[key]['host'], data_to_process[key]['service'])) + conn.commit() + logging.info(" > The instance was updated successfully!") + logging.info("") + except Exception as error: + logging.error(str(error)) + finally: + # Close the connection + if conn: + conn.close() + + +# Welcome message +logging.info('') +logging.info('******************************************************************************************') +logging.info('*************************** PIACERE InfluxDB Client started! ***************************') +logging.info('******************************************************************************************') + + +# Start the process +if int(config['PIACERE-INFLUXDB-CLIENT']['piacere.influxdb.enabled']) != 1: + logging.info('') + logging.info('******************************************************************************************') + logging.info('************************* PIACERE InfluxDB Client not enabled! *************************') + logging.info('************************* PIACERE InfluxDB Client exited! *************************') + logging.info('******************************************************************************************') +else: + try: + # Create the query result object + query_result = {} + + # Create the InfluxDB client and the query API + client = influxdb_client.InfluxDBClient( + url = os.environ.get("INFLUXDB_URL"), + token = os.environ.get("INFLUXDB_TOKEN"), + org = os.environ.get("INFLUXDB_ORGANIZATION")) + query_api = client.query_api() + + # Start listening + while True: + logging.info(' > Listening...') + + # Execute the query and extract the data as a JSON object + tables = query_api.query(influxdb_query_templates.influxdb_query, org = os.environ.get("INFLUXDB_ORGANIZATION")) + tables_to_json = json.loads(tables.to_json(indent = 4)) + + # Loop through the query result (if needed) + if tables_to_json and len(tables_to_json) > 0: + # logging.info(json.dumps(tables_to_json, indent = 4)) + deployments = [] + for table in tables_to_json: + if table['deployment_id'] not in deployments: + deployments.append(table['deployment_id']) + if table['deployment_id'] not in query_result: + query_result[table['deployment_id']] = { 'service': None, 'instance': None, 'host': None, 'availability': None, 'time': 0 } + if deployments and len(deployments) > 0: + for deployment in deployments: + for table in tables_to_json: + if table['deployment_id'] == deployment: + result_time = datetime.strptime(table['_time'][:19], '%Y-%m-%dT%H:%M:%S').timestamp() * 1000 + if result_time > query_result[deployment]['time']: + if 'doml_element_type' in table: + query_result[deployment]['service'] = table['doml_element_type'] + query_result[deployment]['instance'] = table['doml_element_name'] + if 'host' in table: + query_result[deployment]['host'] = table['host'] + query_result[deployment]['availability'] = table['_value'] + query_result[deployment]['time'] = result_time + + # Commit to database + commitToDatabase(query_result) + + # Wait the configured interval + time.sleep(int(config['PIACERE-INFLUXDB-CLIENT']['piacere.influxdb.sleep'])) + except Exception as error: + logging.info('') + logging.info('******************************************************************************************') + logging.error(str(error)) + logging.info('******************************************************************************************') \ No newline at end of file diff --git a/git/iec-Influxdbclient/requirements.txt b/git/iec-Influxdbclient/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..a3af078607712e02cf2664287d892e8e8aea855a --- /dev/null +++ b/git/iec-Influxdbclient/requirements.txt @@ -0,0 +1,4 @@ +cryptography == 41.0.5 +influxdb-client == 1.38.0 +pymysql == 1.1.0 +Werkzeug == 2.2.2 \ No newline at end of file diff --git a/git/iec-Influxdbclient/templates/influxdb_query_templates.py b/git/iec-Influxdbclient/templates/influxdb_query_templates.py new file mode 100644 index 0000000000000000000000000000000000000000..ce1c8aab051e7674ace48dd7f2becad89981e753 --- /dev/null +++ b/git/iec-Influxdbclient/templates/influxdb_query_templates.py @@ -0,0 +1,39 @@ +import configparser +import os + +# Create the config object and read config.ini file +config = configparser.ConfigParser() +config.read('config/config.ini') + +# Replacing variables +influxdb_query_data = { + "bucket": os.environ.get("INFLUXDB_BUCKET"), + "start": config['PIACERE-INFLUXDB-CLIENT']['piacere.influxdb.range.start'], + "telegraf_interval": config['PIACERE-INFLUXDB-CLIENT']['piacere.influxdb.telegraf.interval'], + "aggregate_sampling": config['PIACERE-INFLUXDB-CLIENT']['piacere.influxdb.aggregate.sampling'], + "measurement": os.environ.get("INFLUXDB_MEASUREMENT"), + "field": os.environ.get("INFLUXDB_FIELD") +} + +# The query template +INFLUXDB_QUERY_TEMPLATE = """ + bucket = "{bucket}" + start = {start} + telegraf_interval = {telegraf_interval} + discard_level = int(v: duration(v: uint(v: telegraf_interval) + uint(v: 5s)))/1000000000 + aggregate_sampling = {aggregate_sampling} + measurement = "{measurement}" + field = "{field}" + + from(bucket: bucket) + |> range(start: start) + |> filter(fn: (r) => r._measurement == measurement) + |> filter(fn: (r) => r._field == field) + |> keep(columns: ["deployment_id", "host", "doml_element_name", "doml_element_type", "_time", "_field", "_value"]) + |> aggregateWindow(every: 1m, fn: mean, createEmpty: true) + |> fill(column: "_value", value: 0.0) + |> yield(name: "mean") +""" + +# The final query +influxdb_query = INFLUXDB_QUERY_TEMPLATE.format(**influxdb_query_data) \ No newline at end of file diff --git a/git/iec-Influxdbclient/templates/mysql_query_templates.py b/git/iec-Influxdbclient/templates/mysql_query_templates.py new file mode 100644 index 0000000000000000000000000000000000000000..a5fead85a9c5c99f0b7e229c8f69d52cdbb23c7f --- /dev/null +++ b/git/iec-Influxdbclient/templates/mysql_query_templates.py @@ -0,0 +1,85 @@ +import configparser +import os + +# Create the config object and read config.ini file +config = configparser.ConfigParser() +config.read('config/config.ini') + +# Replacing variables +mysql_connection_data = { + "mysql_host": os.environ.get("MYSQL_HOST"), + "mysql_db": os.environ.get("MYSQL_DB"), + "mysql_user": os.environ.get("MYSQL_USER"), + "mysql_password": os.environ.get("MYSQL_PASSWORD") +} + +# The select instances query +MYSQL_SELECT_INSTANCES_QUERY_TEMPLATE = """ + SELECT + id, + deployment_id, + instance_name, + instance_ip_url, + deleted_date, + service_id + FROM + instance +""" + +# The select services query +MYSQL_SELECT_SERVICES_QUERY_TEMPLATE = """ + SELECT + id, + service_name + FROM + root_service +""" + +# The update instances to inactive query +MYSQL_UPDATE_INSTANCES_TO_INACTIVE_QUERY_TEMPLATE = """ + UPDATE instance + SET + deleted_date = '%s' + WHERE + deleted_date is null +""" + +# The delete instances query +MYSQL_DELETE_INSTANCES_QUERY_TEMPLATE = """ + DELETE FROM instance +""" + +# The insert instance query template +MYSQL_INSERT_INSTANCE_QUERY_TEMPLATE = """ + INSERT INTO instance ( + deployment_id, + instance_name, + instance_ip_url, + average_availability, + created_date, + last_modified_date, + service_id + ) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', %s) +""" + +# The update instance query template +MYSQL_UPDATE_INSTANCE_QUERY_TEMPLATE = """ + UPDATE instance + SET + average_availability = '%s', + last_modified_date = '%s', + deleted_date = NULL + WHERE + deployment_id = '%s' AND + instance_name = '%s' AND + instance_ip_url = '%s' AND + service_id = %s +""" + +# The final queries +mysql_select_instances_query = MYSQL_SELECT_INSTANCES_QUERY_TEMPLATE +mysql_select_services_query = MYSQL_SELECT_SERVICES_QUERY_TEMPLATE +mysql_update_instances_to_inactive_query = MYSQL_UPDATE_INSTANCES_TO_INACTIVE_QUERY_TEMPLATE +mysql_delete_instances_query = MYSQL_DELETE_INSTANCES_QUERY_TEMPLATE +mysql_insert_instance_query = MYSQL_INSERT_INSTANCE_QUERY_TEMPLATE +mysql_update_instance_query = MYSQL_UPDATE_INSTANCE_QUERY_TEMPLATE \ No newline at end of file diff --git a/git/iec-backend/src/main/java/com/piacere/iec/backend/domain/Instance.java b/git/iec-backend/src/main/java/com/piacere/iec/backend/domain/Instance.java index 0d9df80d80434da657b8246b3983d0788566513b..d8fb43f41aa9dea07ac8f5b53f3227cf1697ccb4 100644 --- a/git/iec-backend/src/main/java/com/piacere/iec/backend/domain/Instance.java +++ b/git/iec-backend/src/main/java/com/piacere/iec/backend/domain/Instance.java @@ -38,11 +38,10 @@ public class Instance implements Serializable { @Size(max = 70) @Column(name = "instance_ip_url", length = 70, nullable = false) private String instanceIpUrl; - - @NotNull - @Size(max = 70) - @Column(name = "email", length = 70, nullable = false) - private String email; + + @Size(max = 8) + @Column(name = "average_availability", length = 8, nullable = true) + private String averageAvailability; @NotNull @Column(name = "created_date", nullable = false) @@ -115,19 +114,19 @@ public class Instance implements Serializable { public void setInstanceIpUrl(String instanceIpUrl) { this.instanceIpUrl = instanceIpUrl; } + + public String getAverageAvailability() { + return averageAvailability; + } - public String getEmail() { - return this.email; - } - - public Instance email(String email) { - this.email = email; + public Instance averageAvailability(String averageAvailability) { + this.averageAvailability = averageAvailability; return this; } - - public void setEmail(String email) { - this.email = email; - } + + public void setAverageAvailability(String averageAvailability) { + this.averageAvailability = averageAvailability; + } public Instant getCreatedDate() { return this.createdDate; @@ -239,7 +238,7 @@ public class Instance implements Serializable { ", deploymentId='" + getDeploymentId() + "'" + ", instanceName='" + getInstanceName() + "'" + ", instanceIpUrl='" + getInstanceIpUrl() + "'" + - ", email='" + getEmail() + "'" + + ", averageAvailability='" + getAverageAvailability() + "'" + ", createdDate='" + getCreatedDate() + "'" + ", lastModifiedDate='" + getLastModifiedDate() + "'" + ", deletedDate='" + getDeletedDate() + "'" + diff --git a/git/iec-backend/src/main/java/com/piacere/iec/backend/service/InstanceQueryService.java b/git/iec-backend/src/main/java/com/piacere/iec/backend/service/InstanceQueryService.java index 30aeba232f14b76dea44c7018c9fde5fc97de8d2..5d44e9f99057f05442be64c63ddba78e7c39f3c2 100644 --- a/git/iec-backend/src/main/java/com/piacere/iec/backend/service/InstanceQueryService.java +++ b/git/iec-backend/src/main/java/com/piacere/iec/backend/service/InstanceQueryService.java @@ -92,8 +92,8 @@ public class InstanceQueryService extends QueryService<Instance> { if (criteria.getInstanceIpUrl() != null) { specification = specification.and(buildStringSpecification(criteria.getInstanceIpUrl(), Instance_.instanceIpUrl)); } - if (criteria.getEmail() != null) { - specification = specification.and(buildStringSpecification(criteria.getEmail(), Instance_.email)); + if (criteria.getAverageAvailability() != null) { + specification = specification.and(buildStringSpecification(criteria.getAverageAvailability(), Instance_.averageAvailability)); } if (criteria.getCreatedDate() != null) { specification = specification.and(buildRangeSpecification(criteria.getCreatedDate(), Instance_.createdDate)); diff --git a/git/iec-backend/src/main/java/com/piacere/iec/backend/service/criteria/InstanceCriteria.java b/git/iec-backend/src/main/java/com/piacere/iec/backend/service/criteria/InstanceCriteria.java index 0c751b18def89ab50c3966d9dad36d3ee59e1ccc..2e7a2076e11204404e418a232086f7a41e718ac5 100644 --- a/git/iec-backend/src/main/java/com/piacere/iec/backend/service/criteria/InstanceCriteria.java +++ b/git/iec-backend/src/main/java/com/piacere/iec/backend/service/criteria/InstanceCriteria.java @@ -2,13 +2,10 @@ package com.piacere.iec.backend.service.criteria; import java.io.Serializable; import java.util.Objects; + import tech.jhipster.service.Criteria; -import tech.jhipster.service.filter.BooleanFilter; -import tech.jhipster.service.filter.DoubleFilter; import tech.jhipster.service.filter.Filter; -import tech.jhipster.service.filter.FloatFilter; import tech.jhipster.service.filter.InstantFilter; -import tech.jhipster.service.filter.IntegerFilter; import tech.jhipster.service.filter.LongFilter; import tech.jhipster.service.filter.StringFilter; @@ -30,8 +27,8 @@ public class InstanceCriteria implements Serializable, Criteria { private StringFilter instanceName; private StringFilter instanceIpUrl; - - private StringFilter email; + + private StringFilter averageAvailability; private InstantFilter createdDate; @@ -49,7 +46,7 @@ public class InstanceCriteria implements Serializable, Criteria { this.id = other.id == null ? null : other.id.copy(); this.instanceName = other.instanceName == null ? null : other.instanceName.copy(); this.instanceIpUrl = other.instanceIpUrl == null ? null : other.instanceIpUrl.copy(); - this.email = other.email == null ? null : other.email.copy(); + this.averageAvailability = other.averageAvailability == null ? null : other.averageAvailability.copy(); this.createdDate = other.createdDate == null ? null : other.createdDate.copy(); this.lastModifiedDate = other.lastModifiedDate == null ? null : other.lastModifiedDate.copy(); this.deletedDate = other.deletedDate == null ? null : other.deletedDate.copy(); @@ -106,20 +103,20 @@ public class InstanceCriteria implements Serializable, Criteria { public void setInstanceIpUrl(StringFilter instanceIpUrl) { this.instanceIpUrl = instanceIpUrl; } - - public StringFilter getEmail() { - return email; + + public StringFilter getAverageAvailability() { + return averageAvailability; } - public StringFilter email() { - if (email == null) { - email = new StringFilter(); + public StringFilter averageAvailability() { + if (averageAvailability == null) { + averageAvailability = new StringFilter(); } - return email; + return averageAvailability; } - public void setEmail(StringFilter email) { - this.email = email; + public void setAverageAvailability(StringFilter averageAvailability) { + this.averageAvailability = averageAvailability; } public InstantFilter getCreatedDate() { @@ -210,7 +207,7 @@ public class InstanceCriteria implements Serializable, Criteria { Objects.equals(id, that.id) && Objects.equals(instanceName, that.instanceName) && Objects.equals(instanceIpUrl, that.instanceIpUrl) && - Objects.equals(email, that.email) && + Objects.equals(averageAvailability, that.averageAvailability) && Objects.equals(createdDate, that.createdDate) && Objects.equals(lastModifiedDate, that.lastModifiedDate) && Objects.equals(deletedDate, that.deletedDate) && @@ -221,7 +218,7 @@ public class InstanceCriteria implements Serializable, Criteria { @Override public int hashCode() { - return Objects.hash(id, instanceName, instanceIpUrl, email, createdDate, lastModifiedDate, deletedDate, incidenceId, serviceId); + return Objects.hash(id, instanceName, instanceIpUrl, averageAvailability, createdDate, lastModifiedDate, deletedDate, incidenceId, serviceId); } // prettier-ignore @@ -231,7 +228,7 @@ public class InstanceCriteria implements Serializable, Criteria { (id != null ? "id=" + id + ", " : "") + (instanceName != null ? "instanceName=" + instanceName + ", " : "") + (instanceIpUrl != null ? "instanceIpUrl=" + instanceIpUrl + ", " : "") + - (email != null ? "email=" + email + ", " : "") + + (averageAvailability != null ? "averageAvailability=" + averageAvailability + ", " : "") + (createdDate != null ? "createdDate=" + createdDate + ", " : "") + (lastModifiedDate != null ? "lastModifiedDate=" + lastModifiedDate + ", " : "") + (deletedDate != null ? "deletedDate=" + deletedDate + ", " : "") + diff --git a/git/iec-backend/src/main/java/com/piacere/iec/backend/service/dto/InstanceDTO.java b/git/iec-backend/src/main/java/com/piacere/iec/backend/service/dto/InstanceDTO.java index dd4e8156a5fe84535c829662e485f6df41c8aec0..1b9215291a4f63087ea98b45f1beb34a945fa726 100644 --- a/git/iec-backend/src/main/java/com/piacere/iec/backend/service/dto/InstanceDTO.java +++ b/git/iec-backend/src/main/java/com/piacere/iec/backend/service/dto/InstanceDTO.java @@ -6,7 +6,8 @@ import java.util.HashSet; import java.util.Objects; import java.util.Set; -import javax.validation.constraints.*; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; import com.piacere.iec.backend.domain.InstanceIncidence; @@ -27,10 +28,9 @@ public class InstanceDTO implements Serializable { @NotNull @Size(max = 70) private String instanceIpUrl; - - @NotNull - @Size(max = 70) - private String email; + + @Size(max = 8) + private String averageAvailability; @NotNull private Instant createdDate; @@ -52,7 +52,7 @@ public class InstanceDTO implements Serializable { this.deploymentId=instanceSaveInfoDTO.getDeploymentId(); this.instanceName = instanceSaveInfoDTO.getInstanceName(); this.instanceIpUrl = instanceSaveInfoDTO.getInstanceIpUrl(); - this.email = instanceSaveInfoDTO.getEmail(); + this.averageAvailability = instanceSaveInfoDTO.getAverageAvailability(); this.service= new RootServiceDTO(); this.service.setServiceName(instanceSaveInfoDTO.getServiceName()); } @@ -88,13 +88,13 @@ public class InstanceDTO implements Serializable { public void setInstanceIpUrl(String instanceIpUrl) { this.instanceIpUrl = instanceIpUrl; } - - public String getEmail() { - return email; + + public String getAverageAvailability() { + return averageAvailability; } - public void setEmail(String email) { - this.email = email; + public void setAverageAvailability(String averageAvailability) { + this.averageAvailability = averageAvailability; } public Instant getCreatedDate() { @@ -166,7 +166,7 @@ public class InstanceDTO implements Serializable { ", deploymentId='" + getDeploymentId() + "'" + ", instanceName='" + getInstanceName() + "'" + ", instanceIpUrl='" + getInstanceIpUrl() + "'" + - ", email='" + getEmail() + "'" + + ", averageAvailability='" + getAverageAvailability() + "'" + ", createdDate='" + getCreatedDate() + "'" + ", lastModifiedDate='" + getLastModifiedDate() + "'" + ", deletedDate='" + getDeletedDate() + "'" + diff --git a/git/iec-backend/src/main/java/com/piacere/iec/backend/service/dto/InstanceSaveInfoDTO.java b/git/iec-backend/src/main/java/com/piacere/iec/backend/service/dto/InstanceSaveInfoDTO.java index e63560d90d1900cc4d41375c7078a33080475231..6922b76c3d40048b0c2c2b6a937d19265750e56e 100644 --- a/git/iec-backend/src/main/java/com/piacere/iec/backend/service/dto/InstanceSaveInfoDTO.java +++ b/git/iec-backend/src/main/java/com/piacere/iec/backend/service/dto/InstanceSaveInfoDTO.java @@ -1,14 +1,10 @@ package com.piacere.iec.backend.service.dto; import java.io.Serializable; -import java.time.Instant; -import java.util.HashSet; import java.util.Objects; -import java.util.Set; -import javax.validation.constraints.*; - -import com.piacere.iec.backend.domain.InstanceIncidence; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; /** * A DTO for the {@link com.piacere.iec.backend.domain.Instance} entity. @@ -29,6 +25,9 @@ public class InstanceSaveInfoDTO implements Serializable { @NotNull @Size(max = 70) private String email; + + @Size(max = 8) + private String averageAvailability; private String serviceName; @@ -56,7 +55,7 @@ public class InstanceSaveInfoDTO implements Serializable { public void setInstanceIpUrl(String instanceIpUrl) { this.instanceIpUrl = instanceIpUrl; } - + public String getEmail() { return email; } @@ -64,6 +63,14 @@ public class InstanceSaveInfoDTO implements Serializable { public void setEmail(String email) { this.email = email; } + + public String getAverageAvailability() { + return averageAvailability; + } + + public void setAverageAvailability(String averageAvailability) { + this.averageAvailability = averageAvailability; + } public String getServiceName() { return serviceName; @@ -102,6 +109,7 @@ public class InstanceSaveInfoDTO implements Serializable { ", instanceName='" + getInstanceName() + "'" + ", instanceIpUrl='" + getInstanceIpUrl() + "'" + ", email='" + getEmail() + "'" + + ", averageAvailability='" + getAverageAvailability() + "'" + ", serviceName='" + getServiceName() + "}"; } diff --git a/git/iec-backend/src/main/java/com/piacere/iec/backend/web/rest/InstanceResource.java b/git/iec-backend/src/main/java/com/piacere/iec/backend/web/rest/InstanceResource.java index bb5d4d83f39024314184436297100843e37580c9..f7763c7c7f29e9c978e1f8e3dd08f5d0ab497f60 100644 --- a/git/iec-backend/src/main/java/com/piacere/iec/backend/web/rest/InstanceResource.java +++ b/git/iec-backend/src/main/java/com/piacere/iec/backend/web/rest/InstanceResource.java @@ -2,6 +2,7 @@ package com.piacere.iec.backend.web.rest; import java.net.URI; import java.net.URISyntaxException; +import java.time.Instant; import java.util.List; import java.util.Objects; import java.util.Optional; @@ -84,6 +85,7 @@ public class InstanceResource { if (instanceDTO.getId() != null) { throw new BadRequestAlertException("A new instance cannot already have an ID", ENTITY_NAME, "idexists"); } + instanceDTO.setDeletedDate(Instant.now()); InstanceDTO result = instanceService.save(instanceDTO); return ResponseEntity .created(new URI("/api/instances/" + result.getId())) diff --git a/git/iec-backend/src/test/java/com/piacere/iec/backend/web/rest/InstanceResourceIT.java b/git/iec-backend/src/test/java/com/piacere/iec/backend/web/rest/InstanceResourceIT.java index 612fc60cadeb948a550d20894b51ee8dd763f102..8dedb9d8ad9163a51986c876d0e9508b2e6ff027 100644 --- a/git/iec-backend/src/test/java/com/piacere/iec/backend/web/rest/InstanceResourceIT.java +++ b/git/iec-backend/src/test/java/com/piacere/iec/backend/web/rest/InstanceResourceIT.java @@ -42,9 +42,6 @@ class InstanceResourceIT { private static final String DEFAULT_INSTANCE_IP_URL = "AAAAAAAAAA"; private static final String UPDATED_INSTANCE_IP_URL = "BBBBBBBBBB"; - private static final String DEFAULT_EMAIL = "AAAAAAAAAA"; - private static final String UPDATED_EMAIL = "BBBBBBBBBB"; - private static final Instant DEFAULT_CREATED_DATE = Instant.ofEpochMilli(0L); private static final Instant UPDATED_CREATED_DATE = Instant.now().truncatedTo(ChronoUnit.MILLIS); @@ -84,7 +81,6 @@ class InstanceResourceIT { Instance instance = new Instance() .instanceName(DEFAULT_INSTANCE_NAME) .instanceIpUrl(DEFAULT_INSTANCE_IP_URL) - .email(DEFAULT_EMAIL) .createdDate(DEFAULT_CREATED_DATE) .lastModifiedDate(DEFAULT_LAST_MODIFIED_DATE) .deletedDate(DEFAULT_DELETED_DATE); @@ -101,7 +97,6 @@ class InstanceResourceIT { Instance instance = new Instance() .instanceName(UPDATED_INSTANCE_NAME) .instanceIpUrl(UPDATED_INSTANCE_IP_URL) - .email(UPDATED_EMAIL) .createdDate(UPDATED_CREATED_DATE) .lastModifiedDate(UPDATED_LAST_MODIFIED_DATE) .deletedDate(UPDATED_DELETED_DATE); @@ -129,7 +124,6 @@ class InstanceResourceIT { Instance testInstance = instanceList.get(instanceList.size() - 1); assertThat(testInstance.getInstanceName()).isEqualTo(DEFAULT_INSTANCE_NAME); assertThat(testInstance.getInstanceIpUrl()).isEqualTo(DEFAULT_INSTANCE_IP_URL); - assertThat(testInstance.getEmail()).isEqualTo(DEFAULT_EMAIL); assertThat(testInstance.getCreatedDate()).isEqualTo(DEFAULT_CREATED_DATE); assertThat(testInstance.getLastModifiedDate()).isEqualTo(DEFAULT_LAST_MODIFIED_DATE); assertThat(testInstance.getDeletedDate()).isEqualTo(DEFAULT_DELETED_DATE); @@ -194,9 +188,6 @@ class InstanceResourceIT { @Transactional void checkEmailIsRequired() throws Exception { int databaseSizeBeforeTest = instanceRepository.findAll().size(); - // set the field null - instance.setEmail(null); - // Create the Instance, which fails. InstanceDTO instanceDTO = instanceMapper.toDto(instance); @@ -240,7 +231,6 @@ class InstanceResourceIT { .andExpect(jsonPath("$.[*].id").value(hasItem(instance.getId().intValue()))) .andExpect(jsonPath("$.[*].instanceName").value(hasItem(DEFAULT_INSTANCE_NAME))) .andExpect(jsonPath("$.[*].instanceIpUrl").value(hasItem(DEFAULT_INSTANCE_IP_URL))) - .andExpect(jsonPath("$.[*].email").value(hasItem(DEFAULT_EMAIL))) .andExpect(jsonPath("$.[*].createdDate").value(hasItem(DEFAULT_CREATED_DATE.toString()))) .andExpect(jsonPath("$.[*].lastModifiedDate").value(hasItem(DEFAULT_LAST_MODIFIED_DATE.toString()))) .andExpect(jsonPath("$.[*].deletedDate").value(hasItem(DEFAULT_DELETED_DATE.toString()))); @@ -260,7 +250,6 @@ class InstanceResourceIT { .andExpect(jsonPath("$.id").value(instance.getId().intValue())) .andExpect(jsonPath("$.instanceName").value(DEFAULT_INSTANCE_NAME)) .andExpect(jsonPath("$.instanceIpUrl").value(DEFAULT_INSTANCE_IP_URL)) - .andExpect(jsonPath("$.email").value(DEFAULT_EMAIL)) .andExpect(jsonPath("$.createdDate").value(DEFAULT_CREATED_DATE.toString())) .andExpect(jsonPath("$.lastModifiedDate").value(DEFAULT_LAST_MODIFIED_DATE.toString())) .andExpect(jsonPath("$.deletedDate").value(DEFAULT_DELETED_DATE.toString())); @@ -440,84 +429,6 @@ class InstanceResourceIT { defaultInstanceShouldBeFound("instanceIpUrl.doesNotContain=" + UPDATED_INSTANCE_IP_URL); } - @Test - @Transactional - void getAllInstancesByEmailIsEqualToSomething() throws Exception { - // Initialize the database - instanceRepository.saveAndFlush(instance); - - // Get all the instanceList where email equals to DEFAULT_EMAIL - defaultInstanceShouldBeFound("email.equals=" + DEFAULT_EMAIL); - - // Get all the instanceList where email equals to UPDATED_EMAIL - defaultInstanceShouldNotBeFound("email.equals=" + UPDATED_EMAIL); - } - - @Test - @Transactional - void getAllInstancesByEmailIsNotEqualToSomething() throws Exception { - // Initialize the database - instanceRepository.saveAndFlush(instance); - - // Get all the instanceList where email not equals to DEFAULT_EMAIL - defaultInstanceShouldNotBeFound("email.notEquals=" + DEFAULT_EMAIL); - - // Get all the instanceList where email not equals to UPDATED_EMAIL - defaultInstanceShouldBeFound("email.notEquals=" + UPDATED_EMAIL); - } - - @Test - @Transactional - void getAllInstancesByEmailIsInShouldWork() throws Exception { - // Initialize the database - instanceRepository.saveAndFlush(instance); - - // Get all the instanceList where email in DEFAULT_EMAIL or UPDATED_EMAIL - defaultInstanceShouldBeFound("email.in=" + DEFAULT_EMAIL + "," + UPDATED_EMAIL); - - // Get all the instanceList where email equals to UPDATED_EMAIL - defaultInstanceShouldNotBeFound("email.in=" + UPDATED_EMAIL); - } - - @Test - @Transactional - void getAllInstancesByEmailIsNullOrNotNull() throws Exception { - // Initialize the database - instanceRepository.saveAndFlush(instance); - - // Get all the instanceList where email is not null - defaultInstanceShouldBeFound("email.specified=true"); - - // Get all the instanceList where email is null - defaultInstanceShouldNotBeFound("email.specified=false"); - } - - @Test - @Transactional - void getAllInstancesByEmailContainsSomething() throws Exception { - // Initialize the database - instanceRepository.saveAndFlush(instance); - - // Get all the instanceList where email contains DEFAULT_EMAIL - defaultInstanceShouldBeFound("email.contains=" + DEFAULT_EMAIL); - - // Get all the instanceList where email contains UPDATED_EMAIL - defaultInstanceShouldNotBeFound("email.contains=" + UPDATED_EMAIL); - } - - @Test - @Transactional - void getAllInstancesByEmailNotContainsSomething() throws Exception { - // Initialize the database - instanceRepository.saveAndFlush(instance); - - // Get all the instanceList where email does not contain DEFAULT_EMAIL - defaultInstanceShouldNotBeFound("email.doesNotContain=" + DEFAULT_EMAIL); - - // Get all the instanceList where email does not contain UPDATED_EMAIL - defaultInstanceShouldBeFound("email.doesNotContain=" + UPDATED_EMAIL); - } - @Test @Transactional void getAllInstancesByCreatedDateIsEqualToSomething() throws Exception { @@ -723,7 +634,6 @@ class InstanceResourceIT { .andExpect(jsonPath("$.[*].id").value(hasItem(instance.getId().intValue()))) .andExpect(jsonPath("$.[*].instanceName").value(hasItem(DEFAULT_INSTANCE_NAME))) .andExpect(jsonPath("$.[*].instanceIpUrl").value(hasItem(DEFAULT_INSTANCE_IP_URL))) - .andExpect(jsonPath("$.[*].email").value(hasItem(DEFAULT_EMAIL))) .andExpect(jsonPath("$.[*].createdDate").value(hasItem(DEFAULT_CREATED_DATE.toString()))) .andExpect(jsonPath("$.[*].lastModifiedDate").value(hasItem(DEFAULT_LAST_MODIFIED_DATE.toString()))) .andExpect(jsonPath("$.[*].deletedDate").value(hasItem(DEFAULT_DELETED_DATE.toString()))); @@ -777,7 +687,6 @@ class InstanceResourceIT { updatedInstance .instanceName(UPDATED_INSTANCE_NAME) .instanceIpUrl(UPDATED_INSTANCE_IP_URL) - .email(UPDATED_EMAIL) .createdDate(UPDATED_CREATED_DATE) .lastModifiedDate(UPDATED_LAST_MODIFIED_DATE) .deletedDate(UPDATED_DELETED_DATE); @@ -797,7 +706,6 @@ class InstanceResourceIT { Instance testInstance = instanceList.get(instanceList.size() - 1); assertThat(testInstance.getInstanceName()).isEqualTo(UPDATED_INSTANCE_NAME); assertThat(testInstance.getInstanceIpUrl()).isEqualTo(UPDATED_INSTANCE_IP_URL); - assertThat(testInstance.getEmail()).isEqualTo(UPDATED_EMAIL); assertThat(testInstance.getCreatedDate()).isEqualTo(UPDATED_CREATED_DATE); assertThat(testInstance.getLastModifiedDate()).isEqualTo(UPDATED_LAST_MODIFIED_DATE); assertThat(testInstance.getDeletedDate()).isEqualTo(UPDATED_DELETED_DATE); @@ -880,7 +788,7 @@ class InstanceResourceIT { Instance partialUpdatedInstance = new Instance(); partialUpdatedInstance.setId(instance.getId()); - partialUpdatedInstance.instanceName(UPDATED_INSTANCE_NAME).email(UPDATED_EMAIL).lastModifiedDate(UPDATED_LAST_MODIFIED_DATE); + partialUpdatedInstance.instanceName(UPDATED_INSTANCE_NAME).lastModifiedDate(UPDATED_LAST_MODIFIED_DATE); restInstanceMockMvc .perform( @@ -896,7 +804,6 @@ class InstanceResourceIT { Instance testInstance = instanceList.get(instanceList.size() - 1); assertThat(testInstance.getInstanceName()).isEqualTo(UPDATED_INSTANCE_NAME); assertThat(testInstance.getInstanceIpUrl()).isEqualTo(DEFAULT_INSTANCE_IP_URL); - assertThat(testInstance.getEmail()).isEqualTo(UPDATED_EMAIL); assertThat(testInstance.getCreatedDate()).isEqualTo(DEFAULT_CREATED_DATE); assertThat(testInstance.getLastModifiedDate()).isEqualTo(UPDATED_LAST_MODIFIED_DATE); assertThat(testInstance.getDeletedDate()).isEqualTo(DEFAULT_DELETED_DATE); @@ -917,7 +824,6 @@ class InstanceResourceIT { partialUpdatedInstance .instanceName(UPDATED_INSTANCE_NAME) .instanceIpUrl(UPDATED_INSTANCE_IP_URL) - .email(UPDATED_EMAIL) .createdDate(UPDATED_CREATED_DATE) .lastModifiedDate(UPDATED_LAST_MODIFIED_DATE) .deletedDate(UPDATED_DELETED_DATE); @@ -936,7 +842,6 @@ class InstanceResourceIT { Instance testInstance = instanceList.get(instanceList.size() - 1); assertThat(testInstance.getInstanceName()).isEqualTo(UPDATED_INSTANCE_NAME); assertThat(testInstance.getInstanceIpUrl()).isEqualTo(UPDATED_INSTANCE_IP_URL); - assertThat(testInstance.getEmail()).isEqualTo(UPDATED_EMAIL); assertThat(testInstance.getCreatedDate()).isEqualTo(UPDATED_CREATED_DATE); assertThat(testInstance.getLastModifiedDate()).isEqualTo(UPDATED_LAST_MODIFIED_DATE); assertThat(testInstance.getDeletedDate()).isEqualTo(UPDATED_DELETED_DATE); diff --git a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/detail/instance-detail.component.html b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/detail/instance-detail.component.html index 3f24893d9729c6f79f11a402b7678c45678ec05e..69c529118c572af0f4ea106c16d28682baffb274 100644 --- a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/detail/instance-detail.component.html +++ b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/detail/instance-detail.component.html @@ -18,13 +18,13 @@ <span class="text-primary font-weight-bold" jhiTranslate="iecFrontendApp.iecBackendInstance.instanceIpUrl">Instance Ip Url</span> <span> </span> <span>{{ instance?.instanceIpUrl }}</span><br> - <span class="text-primary font-weight-bold" jhiTranslate="iecFrontendApp.iecBackendInstance.email">Email</span> + <span class="text-primary font-weight-bold" jhiTranslate="iecFrontendApp.iecBackendInstance.averageAvailability">Average availability</span> <span> </span> - <span>{{ instance?.email }}</span><br> + <span>{{ instance?.averageAvailability }} %</span><br> <span class="text-primary font-weight-bold" jhiTranslate="iecFrontendApp.iecBackendInstance.service">Service</span> <span> </span> <span>{{ instance?.service?.serviceName }}</span><br><br> - <span class="text-warning" jhiTranslate="iecFrontendApp.iecBackendInstance.alertsdetail">Alerts</span>:<br> + <span *ngIf="getAlertsCount()>0" class="text-warning" jhiTranslate="iecFrontendApp.iecBackendInstance.alertsdetail">Alerts</span><br *ngIf="getAlertsCount()>0"> <ng-container *ngIf="getAlertsCount()>0"> <span *ngFor="let incidence of instance?.incidences; let i = index;"> <strong>{{incidence?.detail}}</strong> ({{ incidence.createdDate }})<br> diff --git a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/instance.model.ts b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/instance.model.ts index 3b931d1a92eed67cb1e67ebde908b23e219dfe5c..61fb8920322bd2e83c4baa03c0cbcd3f702123b2 100644 --- a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/instance.model.ts +++ b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/instance.model.ts @@ -8,6 +8,7 @@ export interface IInstance { instanceName?: string; instanceIpUrl?: string; email?: string; + averageAvailability?: string; createdDate?: dayjs.Dayjs; lastModifiedDate?: dayjs.Dayjs | null; deletedDate?: dayjs.Dayjs | null; @@ -22,6 +23,7 @@ export class Instance implements IInstance { public instanceName?: string, public instanceIpUrl?: string, public email?: string, + public averageAvailability?: string, public createdDate?: dayjs.Dayjs, public lastModifiedDate?: dayjs.Dayjs | null, public deletedDate?: dayjs.Dayjs | null, diff --git a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/list/instance.component.html b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/list/instance.component.html index 85350c583cb1bf44ab71d64367103161f64bda70..a9a4059fb5aae9a71c1aa486a8366568e9f9e040 100644 --- a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/list/instance.component.html +++ b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/list/instance.component.html @@ -2,7 +2,7 @@ <nav class="navbar navbar-dark bg-primary"> <span class="navbar-brand mb-0 h1" jhiTranslate="iecFrontendApp.iecBackendInstance.home.title">Instances</span> <div class="form-inline"> - <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search" [(ngModel)]="searchText"> + <input class="form-control mr-sm-2" type="search" placeholder="Search by Service" aria-label="Search" [(ngModel)]="searchText"> </div> <!-- <form class="form-inline"> <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search"> @@ -49,14 +49,11 @@ <th scope="col" jhiSortBy="instanceName"> <span jhiTranslate="iecFrontendApp.iecBackendInstance.instanceName">Instance Name</span> <fa-icon icon="sort"></fa-icon> </th> - <th scope="col"> - <span jhiTranslate="iecFrontendApp.iecBackendInstance.status">Status</span> - </th> <th scope="col" jhiSortBy="instanceIpUrl"> <span jhiTranslate="iecFrontendApp.iecBackendInstance.instanceIpUrl">Instance Ip Url</span> <fa-icon icon="sort"></fa-icon> </th> - <th scope="col" jhiSortBy="email"> - <span jhiTranslate="iecFrontendApp.iecBackendInstance.email">Email</span> <fa-icon icon="sort"></fa-icon> + <th scope="col" jhiSortBy="averageAvailability"> + <span jhiTranslate="iecFrontendApp.iecBackendInstance.averageAvailability">Average availability</span> <fa-icon icon="sort"></fa-icon> </th> <!-- <th scope="col" jhiSortBy="createdDate"> <span jhiTranslate="iecFrontendApp.iecBackendInstance.createdDate">Created Date</span> <fa-icon icon="sort"></fa-icon> @@ -68,12 +65,12 @@ <th scope="col" jhiSortBy="deletedDate"> <span jhiTranslate="iecFrontendApp.iecBackendInstance.deletedDate">Deleted Date</span> <fa-icon icon="sort"></fa-icon> </th> --> - <th scope="col" jhiSortBy="instanceRootService.serviceName"> + <th scope="col" jhiSortBy="service.serviceName"> <span jhiTranslate="iecFrontendApp.iecBackendInstance.service">Service</span> <fa-icon icon="sort"></fa-icon> </th> <th scope="col"> - <span jhiTranslate="iecFrontendApp.iecBackendInstance.alerts">N.Alerts</span> + <span jhiTranslate="iecFrontendApp.iecBackendInstance.status">Status</span> </th> <th scope="col"></th> </tr> @@ -85,12 +82,8 @@ </td> --> <td>{{ instance.deploymentId }}</td> <td>{{ instance.instanceName }}</td> - <td> - <span class="badge badge-success" jhiTranslate="iecFrontendApp.iecBackendInstance.active" *ngIf="instance.deletedDate == null">Active</span> - <span class="badge badge-danger" jhiTranslate="iecFrontendApp.iecBackendInstance.inactive" *ngIf="instance.deletedDate != null">Inactive</span> - </td> <td>{{ instance.instanceIpUrl }}</td> - <td>{{ instance.email }}</td> + <td>{{ instance.averageAvailability }} %</td> <!-- <td>{{ instance.createdDate | formatMediumDatetime }}</td> <td>{{ instance.lastModifiedDate | formatMediumDatetime }}</td> <td>{{ instance.deletedDate | formatMediumDatetime }}</td> --> @@ -100,12 +93,8 @@ </div> </td> <td> - <div *ngIf="instance.incidences?.length"> - <a *ngIf="instance.incidences?.length" [routerLink]="['/instance', instance?.id, 'view']">{{ instance.incidences?.length }}</a> - </div> - <div *ngIf="!instance.incidences?.length"> - 0 - </div> + <span class="badge badge-success" jhiTranslate="iecFrontendApp.iecBackendInstance.active" *ngIf="instance.deletedDate == null">Active</span> + <span class="badge badge-danger" jhiTranslate="iecFrontendApp.iecBackendInstance.inactive" *ngIf="instance.deletedDate != null">Inactive</span> </td> <td class="text-right"> <div class="btn-group"> @@ -118,7 +107,7 @@ <fa-icon icon="eye"></fa-icon> <span class="d-none d-md-inline" jhiTranslate="entity.action.view">View</span> </button> - + <!-- <button type="submit" [routerLink]="['/instance', instance.id, 'edit']" @@ -128,7 +117,7 @@ <fa-icon icon="pencil-alt"></fa-icon> <span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span> </button> - + --> <button type="submit" (click)="delete(instance)" class="btn btn-danger btn-sm" data-cy="entityDeleteButton"> <fa-icon icon="times"></fa-icon> <span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Delete</span> diff --git a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/pipes/filter.instance.pipe.ts b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/pipes/filter.instance.pipe.ts index 54e367f8ec6c3f9dd13bb06241a551cab3787368..dc850fcf220edd31819388625ceb44d896a00edf 100644 --- a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/pipes/filter.instance.pipe.ts +++ b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/pipes/filter.instance.pipe.ts @@ -12,7 +12,7 @@ export class FilterInstancePipe implements PipeTransform { } searchText = searchText.toLocaleLowerCase(); - return items.filter( it => it.instanceName?.toLocaleLowerCase().includes(searchText)); + return items.filter( it => it.service?.serviceName?.toLocaleLowerCase().includes(searchText)); } } diff --git a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/update/instance-update.component.html b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/update/instance-update.component.html index d20db884f83e5609976cc5223cc172538fb89d21..c774ec64e4cbeaad2a35a92871e985a22c6f7fea 100644 --- a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/update/instance-update.component.html +++ b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/update/instance-update.component.html @@ -117,24 +117,6 @@ </small> </div> </div> - - <div class="form-group"> - <label class="form-control-label" jhiTranslate="iecFrontendApp.iecBackendInstance.email" for="field_email">Email</label> - <input type="text" class="form-control" name="email" id="field_email" data-cy="email" formControlName="email" /> - <div *ngIf="editForm.get('email')!.invalid && (editForm.get('email')!.dirty || editForm.get('email')!.touched)"> - <small class="form-text text-danger" *ngIf="editForm.get('email')?.errors?.required" jhiTranslate="entity.validation.required"> - This field is required. - </small> - <small - class="form-text text-danger" - *ngIf="editForm.get('email')?.errors?.maxlength" - jhiTranslate="entity.validation.maxlength" - [translateValues]="{ max: 70 }" - > - This field cannot be longer than 70 characters. - </small> - </div> - </div> <input type="hidden" id="field_createdDate" data-cy="createdDate" name="createdDate" formControlName="createdDate"/> <input type="hidden" id="field_lastModifiedDate" data-cy="lastModifiedDate" name="lastModifiedDate" formControlName="lastModifiedDate"/> <input type="hidden" id="field_deletedDate" data-cy="deletedDate" name="deletedDate" formControlName="deletedDate"/> diff --git a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/update/instance-update.component.ts b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/update/instance-update.component.ts index e8c6f5fc47501525468f438c0a0861042ed6c92d..cc1aa931e99d09f22877bd58d90f7b60e421e3eb 100644 --- a/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/update/instance-update.component.ts +++ b/git/iec-frontend/src/main/webapp/app/entities/iecBackend/instance/update/instance-update.component.ts @@ -27,7 +27,6 @@ export class InstanceUpdateComponent implements OnInit { deploymentId: [null, [Validators.required, Validators.maxLength(70)]], instanceName: [null, [Validators.required, Validators.maxLength(70)]], instanceIpUrl: [null, [Validators.required, Validators.maxLength(70)]], - email: [null, [Validators.required, Validators.maxLength(70)]], createdDate: [null, [Validators.required]], lastModifiedDate: [], deletedDate: [], @@ -97,7 +96,7 @@ export class InstanceUpdateComponent implements OnInit { deploymentId: instance.deploymentId, instanceName: instance.instanceName, instanceIpUrl: instance.instanceIpUrl, - email: instance.email, + averageAvailability: '0.0', createdDate: instance.createdDate ? instance.createdDate.format(DATE_TIME_FORMAT) : null, lastModifiedDate: instance.lastModifiedDate ? instance.lastModifiedDate.format(DATE_TIME_FORMAT) : null, deletedDate: instance.deletedDate ? instance.deletedDate.format(DATE_TIME_FORMAT) : null, @@ -129,7 +128,7 @@ export class InstanceUpdateComponent implements OnInit { instanceName: this.editForm.get(['instanceName'])!.value, deploymentId: this.editForm.get(['deploymentId'])!.value, instanceIpUrl: this.editForm.get(['instanceIpUrl'])!.value, - email: this.editForm.get(['email'])!.value, + averageAvailability: '0.0', createdDate: this.editForm.get(['createdDate'])!.value ? dayjs(this.editForm.get(['createdDate'])!.value, DATE_TIME_FORMAT) : undefined, diff --git a/git/iec-frontend/src/main/webapp/i18n/en/iecBackendInstance.json b/git/iec-frontend/src/main/webapp/i18n/en/iecBackendInstance.json index 4ed3759d89502e7734b96e2807e9c47e98317b59..c8162e8dcc1956af352bbc82ece383997fc28c88 100644 --- a/git/iec-frontend/src/main/webapp/i18n/en/iecBackendInstance.json +++ b/git/iec-frontend/src/main/webapp/i18n/en/iecBackendInstance.json @@ -19,6 +19,7 @@ "instanceName": "Name", "instanceIpUrl": "Instance Ip Url", "email": "Email", + "averageAvailability": "Avg. availability", "createdDate": "Created Date", "lastModifiedDate": "Last Modified Date", "deletedDate": "Deleted Date", diff --git a/git/iec-frontend/src/main/webapp/i18n/es/iecBackendInstance.json b/git/iec-frontend/src/main/webapp/i18n/es/iecBackendInstance.json index f61b4d07040cae7f90d422283d7050b01a0f91f0..9ebe5f75acd164df9d9dfd886d723a90167aa902 100644 --- a/git/iec-frontend/src/main/webapp/i18n/es/iecBackendInstance.json +++ b/git/iec-frontend/src/main/webapp/i18n/es/iecBackendInstance.json @@ -19,6 +19,7 @@ "instanceName": "Nombre", "instanceIpUrl": "Ip Url", "email": "Email", + "averageAvailability": "Disponiblidad media", "createdDate": "Fecha de creación", "lastModifiedDate": "Fecha última modificación", "deletedDate": "Fecha eliminación", diff --git a/git/iec-mysql/startupscripts/02_createTables.sql b/git/iec-mysql/startupscripts/02_createTables.sql index defbd80a5d28516d3f6ee1b736171a0223265cb7..601d4a2fe90a0f143891759823c89a608ce187fe 100644 --- a/git/iec-mysql/startupscripts/02_createTables.sql +++ b/git/iec-mysql/startupscripts/02_createTables.sql @@ -29,7 +29,7 @@ CREATE TABLE `instance` ( `deployment_id` varchar(70) NOT NULL, `instance_name` varchar(70) NOT NULL, `instance_ip_url` varchar(70) NOT NULL, - `email` varchar(70) NOT NULL, + `average_availability` varchar(8) DEFAULT '0.0', `created_date` datetime(6) NOT NULL, `last_modified_date` datetime(6), `deleted_date` datetime(6), diff --git a/git/iec-mysql/startupscripts/03_initialData.sql b/git/iec-mysql/startupscripts/03_initialData.sql index f69df04416d7440cdebd28912b4160ba055456ca..03b1ff79bc55e76f568497e15a3a9abb8e0c8764 100644 --- a/git/iec-mysql/startupscripts/03_initialData.sql +++ b/git/iec-mysql/startupscripts/03_initialData.sql @@ -1263,14 +1263,13 @@ INSERT INTO iecbackend.definition (code,value,ismainattribute,ischeckoption,serv -- 25: Cost -INSERT INTO instance (`id`,`created_date`,`deleted_date`,`email`,`instance_ip_url`,`deployment_id`,`instance_name`,`last_modified_date`,`service_id`) VALUES - (1, '2021-07-05 00:00:00',NULL,'testmail@tecnalia.com','168.0.1.10','deployment01','instanceTest',NULL,1); +INSERT INTO `instance` (`id`,`created_date`,`deleted_date`,`instance_ip_url`,`deployment_id`,`instance_name`,`average_availability`,`last_modified_date`,`service_id`) VALUES + (1, '2021-07-05 00:00:00','2021-07-05 00:00:00','168.0.1.10','123e4567-e89b-12d3-a456-426614174000','instanceTest','100.0',NULL,1); -INSERT INTO `instance_incidence` (`id`, `detail`, `real_metric_value`, `instance_id`, `created_date`, `last_modified_date`, `deleted_date`) VALUES +/*INSERT INTO `instance_incidence` (`id`, `detail`, `real_metric_value`, `instance_id`, `created_date`, `last_modified_date`, `deleted_date`) VALUES (1, 'NFR Violation', NULL, 1, '2020-04-01 19:46:19', '2020-04-01 19:46:19', NULL), (2, 'NFR Violation', NULL, 1, '2020-04-01 19:46:19', '2020-04-01 19:46:19', NULL), (3, 'Error in Region', NULL, 1, '2020-04-01 19:46:19', '2020-04-01 19:46:19', NULL); - /*, (8, 'NFR Violation', NULL, 6, '2020-04-01 19:46:19', '2020-04-01 19:46:19', NULL), (18, 'Error in Region', NULL, 3, '2020-04-01 19:46:19', '2020-04-01 19:46:19', NULL);*/ diff --git a/release/docker-compose.yaml b/release/docker-compose.yaml index 3af1f85eb7b10c95a383814acbba1f3fee6c7081..28105058a6e2f02330e62bcc4258d7e6f28c2e82 100644 --- a/release/docker-compose.yaml +++ b/release/docker-compose.yaml @@ -7,3 +7,6 @@ services: iec-frontend: image: ${IMAGE_IEC_FRONTEND:?err} + + iec-influxdbclient: + image: ${IMAGE_IEC_INFLUXDBCLIENT:?err} \ No newline at end of file