diff --git a/.gitignore b/.gitignore index d1a9d74..eae167d 100644 --- a/.gitignore +++ b/.gitignore @@ -58,13 +58,6 @@ old/ out.* -OLD/* -*_OLD* -*_ORIG* -*.ORIG -TMP/* - -client.log docker/*.env @@ -102,5 +95,18 @@ TOKEN *.modif.* *.moi *.moi.* +*.me.* +*.me +*.me? +*.old +*.OLD +OLD/* +*_OLD* +*_ORIG* +*.ORIG +*.ORIG? +TMP/* +___* +client.log #privatedev/plugin/agent/triton/triton/CATALOGUES diff --git a/Dockerfile b/Dockerfile index 360a9a0..7f2f9a9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -68,7 +68,7 @@ RUN cd /usr/bin && ln -s python3 python #RUN apt-get install -y python3-pip RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10 #RUN pip3 install --upgrade pip -RUN python3.10 -m pip install --upgrade pip +RUN python3 -m pip install --upgrade pip @@ -155,11 +155,11 @@ CMD ["x11vnc", "-create", "-forever"] - - # Get IRAP self signed certificate RUN echo | openssl s_client -connect gitlab.irap.omp.eu:443 -servername gitlab.irap.omp.eu 2>/dev/null | openssl x509 > /etc/ssl/certs/gitlab.irap.omp.eu.crt + + ################################# # PyROS user (better than root) # ################################# @@ -178,8 +178,6 @@ USER pyros_user # TODO: pourquoi numpy ??? A virer ? #RUN pip install --user numpy - - # Copy local host machine files to image COPY --chown=pyros_user:pyros_user . . # Copy some aliases @@ -190,9 +188,12 @@ RUN cp .bash_aliases .. # Adding local/bin to path to avoid pip warning ENV PATH "$PATH:/home/pyros_user/.local/bin" + # Installing click on the image to prevent error on the first execution of the installation script -RUN python3.10 -m pip install --user click -RUN python3.10 -m pip install --user setuptools==58 +RUN python3 -m pip install --user click + +RUN python3 -m pip install --user setuptools==58 + # (EP 23/3/2022) Installing pip-tools for the management of all the requirements*.txt files (python dependencies packages) # NB : # - pip-tools generates a smarter and smaller requirements.txt file than the traditional "pip freeze" @@ -200,14 +201,14 @@ RUN python3.10 -m pip install --user setuptools==58 # - Unfortunatly, it is difficult to use with several requirements*.txt files as it is the case for this software : pyros + sphinx + guitastro... # - So we cannot yet use it completely and still have to use the traditional "pip install -r" anyway ... # - But we can at least use it to generate all the requirements*.txt files in a far better format -RUN python3.10 -m pip install --user pip-tools +RUN python3 -m pip install --user pip-tools # Installing packages required for Guitastro RUN pip-compile ./vendor/guitastro/install/requirements.in -RUN python3.10 -m pip install --user -r ./vendor/guitastro/install/requirements.txt +RUN python3 -m pip install --user -r ./vendor/guitastro/install/requirements.txt # Maybe unnecessary because same requirements as for pyros requirements_dev (?) #RUN pip install --user -r ./vendor/guitastro/install/requirements_dev.txt # Installing packages required for PyROS -RUN python3.10 -m pip install --user -r ./install/requirements.txt -RUN python3.10 -m pip install --user -r ./install/requirements_dev.txt +RUN python3 -m pip install --user -r ./install/requirements.txt +RUN python3 -m pip install --user -r ./install/requirements_dev.txt diff --git a/docker/PYROS_DOCKER_INSTALL b/docker/PYROS_DOCKER_INSTALL index af693df..266626f 100755 --- a/docker/PYROS_DOCKER_INSTALL +++ b/docker/PYROS_DOCKER_INSTALL @@ -1,24 +1,22 @@ #!/usr/bin/env bash # if no container is running -if ! [ $(docker ps | grep 'pyros' | wc -l) -eq 4 ] -then +if ! [ $(docker ps | grep 'pyros' | wc -l) -eq 4 ] ; then echo "pyros-db or pyros weren't running, starting them..." ./PYROS_DOCKER_START.bat fi # while db container isn't ready to execute queries, wait 5 seconds -if ! docker inspect pyros-db --format='{{.State.Health.Status}}' | grep -q 'healthy' -then +#if ! docker inspect pyros-db --format='{{.State.Health.Status}}' | grep -q 'healthy' ; then +#fi +while ! docker inspect pyros-db --format='{{.State.Health.Status}}' | grep -q 'healthy' ; do echo "db service isn't ready yet, waiting until it's ready..." -fi -while ! docker inspect pyros-db --format='{{.State.Health.Status}}' | grep -q 'healthy' -do sleep 5 heal_status=$(docker inspect pyros-db --format='{{.State.Health.Status}}') echo "Current status : $heal_status" done -# db container is ready to execture queries, we can start the installation +# db container is ready to execture queries +# We can now start the installation docker-compose exec pyros python3 pyros.py install diff --git a/docker/PYROS_DOCKER_RUN_WEBSERVER_ONLY b/docker/PYROS_DOCKER_RUN_WEBSERVER_ONLY index da1bad7..a8bcefb 100755 --- a/docker/PYROS_DOCKER_RUN_WEBSERVER_ONLY +++ b/docker/PYROS_DOCKER_RUN_WEBSERVER_ONLY @@ -1,11 +1,13 @@ #!/usr/bin/env bash #if no container is running -if ! [ $(docker ps | grep 'pyros' | wc -l) -eq 4 ] -then +if ! [ $(docker ps | grep 'pyros' | wc -l) -eq 4 ] ; then echo "pyros-db or pyros weren't running, starting them..." ./PYROS_DOCKER_START.bat fi -docker-compose exec pyros python3 pyros.py -d start webserver $@ + +docker compose exec pyros python3 pyros.py -d start webserver $@ +#docker-compose exec pyros python3 pyros.py -d start webserver $@ +#docker compose exec pyros python3 pyros.py -d start -o tnc -fg webserver $@ #docker exec -it pyros python3 pyros.py start webserver $@ #docker exec -it pyros python3 pyros.py -d start -o tnc webserver $@ diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index b61de04..64baff7 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,12 +1,23 @@ version: "3.9" services: + + ####################### + # MYSQL - DBMS + ####################### db: # if we're using mysql >= 8, some of sql queries aren't valid anymore, like for creating and grant an user at the same time # This is fixed in pyros.py + container_name: pyros-db image: mysql:8.0.28 - command: --default-authentication-plugin=mysql_native_password restart: always + command: --default-authentication-plugin=mysql_native_password + environment: + # note : as db is an image of mysql, this root password will be set on the first installation on the image, if the value is changed, it will not be updated in the database + - "MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-root}" + - VNC_NO_PASSWORD=1 + volumes: + - db:/var/lib/mysql/ deploy: restart_policy: condition: on-failure @@ -15,29 +26,26 @@ services: limits: cpus: '0.5' memory: 1GB - #pids: 1 - container_name: pyros-db - environment: - # note : as db is an image of mysql, this root password will be set on the first installation on the image, if the value is changed, it will not be updated in the database - - "MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-root}" - - VNC_NO_PASSWORD=1 - volumes: - - db:/var/lib/mysql/ + #pids: 1 # create network to allow images to communicate with other images within the same network # networks: # pyros-network: # ipv4_address: 172.19.0.2 - healthcheck: test: ["CMD", 'mysqladmin', 'ping', '-h', 'db', '-u', 'root', '-p$$MYSQL_ROOT_PASSWORD' ] timeout: 10s interval: 5s retries: 20 + ###################################################### + # REDIS - in memory communication bus (for websockets) + ###################################################### redis: container_name: pyros-redis image: redis:latest restart: always + ports: + - "6379:6379" deploy: restart_policy: condition: on-failure @@ -46,9 +54,7 @@ services: limits: cpus: '1' memory: 1GB - #pids: 1 - ports: - - "6379:6379" + #pids: 1 healthcheck: test: ["CMD", "redis-cli","ping"] timeout: 10s @@ -58,22 +64,19 @@ services: # pyros-network: # ipv4_address: 172.19.0.5 - # Service image of python, that lets users interact with python scripts such as pyros. + ###################################################### + # PYROS (main image : docker_pyros) => defined in Dockerfile + # Ubuntu OS with Python3 and PyROS requirements installed + # PyROS will later be installed on this image with "pyros.py install" (PYROS_DOCKER_INSTALL) + ###################################################### pyros: + container_name: pyros + restart: always #read_only: true # app/pyros is equivalent to your PYROS_SOFT/PYROS/ directory # Change "pyros" to whatever you want for the PYROS/ dir name (if you do not want "PYROS") working_dir: /home/pyros_user/app/pyros - deploy: - restart_policy: - condition: on-failure - max_attempts: 5 - resources: - limits: - cpus: '1' - memory: 8GB - #pids: 1 # path to the Dockerfile of this image environment: # environment variables only for Docker @@ -93,7 +96,6 @@ services: uid: ${CURRENT_UID} context: .. #filename: Dockerfile - container_name: pyros hostname: ${COMPUTER_HOSTNAME} # tty is the -t option in docker exec tty: true @@ -112,28 +114,47 @@ services: links: - db - redis + deploy: + restart_policy: + condition: on-failure + max_attempts: 5 + resources: + limits: + cpus: '1' + memory: 8GB + #pids: 1 # create network to allow images to communicate with other images within the same network # networks: # pyros-network: # ipv4_address: 172.19.0.3 #ipv4_address: "${IP_PYROS_USER}" - restart: always healthcheck: test: ["CMD", "python3","-V"] timeout: 10s interval: 5s retries: 20 - + ###################################################### + # PHPMYADMIN (to interact manually with mysql db) + # (dev only) + ###################################################### phpmyadmin: - image: phpmyadmin/phpmyadmin container_name: pyros-pma + image: phpmyadmin/phpmyadmin + restart: always links: - db environment: PMA_HOST: db PMA_PORT: 3306 PMA_ARBITRARY: 1 + env_file: + - .env + # networks: + # pyros-network: + # ipv4_address: 172.19.0.4 + ports: + - "${PHPMYADMIN_PORT:-8081}:80" deploy: restart_policy: condition: on-failure @@ -143,15 +164,6 @@ services: cpus: '1' memory: 1GB #pids: 1 - - env_file: - - .env - restart: always - # networks: - # pyros-network: - # ipv4_address: 172.19.0.4 - ports: - - "${PHPMYADMIN_PORT:-8081}:80" healthcheck: test: ["CMD", 'mysqladmin', 'ping', '-h', 'db', '-u', 'root', '-p$$MYSQL_ROOT_PASSWORD' ] timeout: 10s @@ -159,12 +171,16 @@ services: retries: 20 - -# declaring volumes +###################################################### +# Declaring volumes +###################################################### volumes: db: driver: local -# declaring networks + +###################################################### +# Declaring networks +###################################################### # networks: # pyros-network: # #bridge is the default network driver diff --git a/src/core/pyros_django/majordome/doc/AgentMajordome_object_diag.pu b/src/core/pyros_django/majordome/doc/AgentMajordome_object_diag.pu deleted file mode 100755 index df734f6..0000000 --- a/src/core/pyros_django/majordome/doc/AgentMajordome_object_diag.pu +++ /dev/null @@ -1,220 +0,0 @@ - -@startuml - -!include -!include - - - -/' -UML class Diagram : can be displayed with PlantUML (plugin for Eclipse or for PyCharm) - -PlantUML: -- How to install : https://projects.irap.omp.eu/projects/pyros/wiki/Project_Development#PlantUML -- Eclipse plugin : http://plantuml.com/eclipse -- class diagrams : http://plantuml.com/class-diagram -- sequence diagrams : http://plantuml.com/sequence-diagram -- state diagrams : http://plantuml.com/state-diagram -- Use Case diagrams : http://plantuml.com/use-case-diagram -- OLD Activity diagrams : http://plantuml.com/activity-diagram-legacy -- NEW Activity diagrams : http://plantuml.com/activity-diagram-beta -- Pre-processing (include...) : http://plantuml.com/preprocessing -- GANTT diagrams : http://plantuml.com/gantt-diagram -- REAL WORLD EXAMPLES !!! : https://real-world-plantuml.com/ -- For Python: - - https://github.com/SamuelMarks/python-plantuml - - https://pythonhosted.org/plantuml/ - -UML diagrams theory : https://www.ibm.com/developerworks/rational/library/content/RationalEdge/sep04/bell/index.html -'/ - -title -__**PyROS class diagram (AgentMajordome example)**__ -'Version 16-10-2019' - -end title - - - -/' Allow to mix object/class diagram with other symbols like a "server" symbol '/ -allowmixing - -FA_SERVER(sbig_device,SBIG detector) #Red -FA_SERVER(gemini_device,Gemini telescope) #Red - - - -/' ======= AgentMajordome & AgentDevices ======= '/ - -class AgentMajordome <> #yellow -AgentMajordome -u-|> Agent -AgentDevice -u-|> Agent - -/' Aliases to AgentDevices '/ -object AD_Telescope1 -object AD_FilterSelector1 -object AD_Shutter1 -object AD_Sensor1 -object AD_Shutter2 - -/' Use l,r,u,d for left, right, up, or down row alignement '/ -AgentMajordome -d-> AD_Telescope1 : sends cmd to -AgentMajordome -d-> AD_FilterSelector1 : sends cmd to -AgentMajordome -d-> AD_Shutter1 : sends cmd to -AgentMajordome -d-> AD_Sensor1 : sends cmd to -AgentMajordome -d-> AD_Shutter2 : sends cmd to - - -class DeviceController { - ip, port - channel: ClientChannel - protocol: Protocol # abstract - gen2nat_cmds: Gen2NatCmds # abstract -} - -class DC_Mount { - gen2nat_cmds: Gen2NatCmds # abstract -} -class DC_DetectorShutter { - gen2nat_cmds: Gen2NatCmds # abstract -} -class DC_DetectorSensor { - gen2nat_cmds: Gen2NatCmds # abstract -} -class DC_FilterSelector { - gen2nat_cmds: Gen2NatCmds # abstract -} - - - - -/' ======= CHANNELS ======= '/ - -DeviceController "1" o-r- "0..1" DeviceSimulator - -DeviceController o-d- ClientChannel -class ClientChannelSerial #lightred -class ClientChannelSocket #lightred -class ClientChannelUSB #lightred -ClientChannel <|-- ClientChannelSerial -ClientChannel <|-- ClientChannelSocket -ClientChannel <|-- ClientChannelUSB - - -/' ======= GEMINI controllers (& sim) ======= '/ - -class AgentDeviceGemini #lightblue -AgentDeviceGemini -u--|> AgentDevice - -/' Components (only 1) '/ -AD_Telescope1 -d-> AgentDeviceGemini :alias of - -/'DC_Mount o-left- DS_Mount'/ - -/'AgentDeviceGemini ---> DC_Gemini :use'/ -AgentDeviceGemini "1" o--- "1" DC_Gemini :use - -/' Controllers '/ -class DC_Gemini { - (client) - protocol: Protocol # gemini - gen2nat_cmds: Gen2NatCmds # gemini -} -class DC_Gemini <> #lightblue -DC_Gemini <.l> gemini_device : channel/\nsocket -DC_Gemini ---|> DeviceController -DC_Gemini "*" o-- "1" DC_Mount -DC_Mount --|> DeviceController - -/' Simulators '/ -class DS_Gemini { - (server) - protocol: Protocol # gemini - gen2nat_cmds: Gen2NatCmds # gemini -} -class DS_Gemini #lightblue -DS_Gemini ---|> DeviceSimulator -DC_Gemini "1" o- "1" DS_Gemini - - - -/' ======= SBIG controllers (& sim) ======= '/ - -class AgentDeviceSBIG <> #lightgreen -AgentDeviceSBIG -u--|> AgentDevice - -/' Components (3) '/ -AD_FilterSelector1 --> AgentDeviceSBIG :alias of -AD_Shutter1 --> AgentDeviceSBIG :alias of -AD_Sensor1 --> AgentDeviceSBIG :alias of - -AgentDeviceSBIG "1" o-d-> "1" DC_SBIG :use -DC_SBIG "1" o- "1" DS_SBIG - -/' Controllers '/ - -class DC_SBIG { - (client) - protocol: Protocol # sbig - gen2nat_cmds: Gen2NatCmds # sbig -} -class DC_SBIG <> #lightgreen - -DC_SBIG <.r> sbig_device : channel/\nsocket -DC_SBIG ---|> DeviceController -DC_SBIG "*" o-down- "0..1" DC_DetectorSensor -DC_SBIG "*" o-down- "0..1" DC_DetectorShutter -DC_SBIG "*" o-down- "0..1" DC_FilterSelector - -DC_DetectorSensor --|> DeviceController -DC_DetectorShutter --|> DeviceController -DC_FilterSelector --|> DeviceController - -/' Simulators '/ -class DS_SBIG { - (server) - protocol: Protocol # sbig - gen2nat_cmds: Gen2NatCmds # sbig -} -class DS_SBIG #lightgreen -DS_SBIG ---|> DeviceSimulator - - -/' ======= NOTES ======= '/ - -skinparam noteFontSize 9 - -note left of DeviceController -Device client (pyros generic commands only): -- Defines (or receives) its own protocol - and "generic to native" commands dictionary (gen2nat_cmds) -- Translates an agent generic command to a native command, - and sends it to device (or DS) -- Receives device's native answer, translates it to generic - and returns it back to agent -(//every DC can include a **DS of the same name**//) - end note - -note bottom of DeviceSimulator -Device placeholder server (native commands only): -- Receives native commands from client -- Returns (simulated) native answer to client -(uses protocol and gen2nat_cmds given by its associated DC) -(//abstract DS receive only generic commands and return generic answers//) - end note - - - -/' ======= LEGEND ======= '/ - -skinparam legendFontSize 9 - -legend left -Version 06-11-2019 -AD = Agent Device ; DC = Device Controller ; DS = Device Simulator -Colors: (light) yellow : abstract classes ; red : real devices ; blue : Gemini concrete classes ; green : SBIG concrete classes -endlegend -'(E. Pallier) - - -@enduml -- libgit2 0.21.2