Skip to content

Floor PC Deployment

This document is intended to serve as a guideline on how to deploy the necessary SooperWizer components on the floor computers.

The following components are deployed on the floor computers:

  • SooperWizer API
  • TiZnp

SooperWizer Scanning API is a Python based API server written with FastAPI. The API server is responsible for receiving scan data from the smart boxes and storing it in a database.

This document is intended to serve as a guideline on how to deploy for scanning.

There are some prerequisites that needs to be satisfy before setting up environment:

  1. There should be a separate machine with ubuntu setup on it.
  2. Floor PC's with controller attached to them.
  3. Floor PCs` and server should be able to ping each other.

After completing above steps you can work on setting up server and clients using following steps:

  1. First you need to install following packages: ansible,ssh. ansible: should be setup on server. ssh: server should be able to do ssh connection to floor PC's

  2. To Setup ansible and ssh on server just clone this repository ansible-deployment using command: git clone https://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@github.com/WiMetrixDev/ansible-deployments.git. You need git installed on server. To install git run following command: sudo apt install git

  3. Go to the clone repository using cd ansible-deployments. make script executable using command sudo chmod +x install_prerequisites.sh. Now run the script using sudo ./install_prerequisites.sh. This will install all the necessary tools and packages.

  4. Now go to the inventory file and open it in text editor and edit the linuxserver line. ansible_host should be localhost, ansible_ssh_user you need to pass the server username, for ansible_ssh_pass add the server sudo password, for ansible_sudo_pass paste the same password, zone_id you need to confirm from embedded team or you can pass the random number, for node_name should be server. After editing the inventory file save it.

  5. First you need to install docker and required packages on server. For that purpose there are two ansible scripts name install_docker.yml and install_docker_new.yml. The difference between them is simple: for ubuntu version 20.04 or older you need to use install_docker.yml and for ubuntu version 22.04 and newer you need to use install_docker_new.yml. For install_docker.yml you need to change the hosts in the script. for that purpose open install_docker.yml in text editor and change hosts: NCL3 to hosts: server.

  6. After knowing your operating system version you can run the command sudo ansible-playbook script_name.yml - inventory. <script_name.yml> can be install_docker.yml and install_docker_new.yml depending on your operating system version.

  7. This will install docker and required packages.

  8. After that you need to setup portainer.

  9. For Portainer there is only one script named deploy_portainer.yml.Firstly, you need to change the hosts: NCL3 to hosts: server in this script also. After that you can execute that script using ansible-playboot deploy_portainer.yml -i inventory. After Completing it will show the message which contains admin password for the portainer. Portainer Password

  10. Use your preferred browser to go to address http://localhost:9000 and portainer login screen will appear. Portainer Login Enter the username admin and password admin@331122.

  11. Now you need to clone the repository sooperwizer_api into the same folder. For cloning the repository use git clone -b default-v1 https://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@github.com/WiMetrixDev/sooperwizer_api.git. There are two branches named default-v1 and default-v2. In most cases, we use default-v1 because it contains the latest code. However, in some instances, when requested by the embedded team, we clone the code from default-v2.

  12. First, you need to update some credentials in the sooperwizer_api. Navigate to the cloned sooperwizer_api directory and edit the docker-compose.yml file. Modify the environment settings to match the current client credentials.

    sooperwizer_api:
    container_name: sooperwizer_api
    build: .
    ports:
    - "8000:8000"
    volumes:
    - .:/app
    environment:
    SQL_DIALECT: "mssql+pyodbc"
    SQL_USERNAME: "sa"
    SQL_PASSWORD: "admin@3311"
    SQL_HOST: "sqlserver"
    SQL_PORT: "1433"
    SQL_DATABASE: "SooperWizer"
    SQL_DRIVER: "ODBC Driver 18 for SQL Server"
    TEST_SQL_DATABASE: "NA"
    SQL_REMOTE_DB: "NA"
    SQL_REMOTE_DB_HOST: "NA"
    SQL_REMOTE_DB_PASSWORD: "NA"
    SQL_REMOTE_DB_USER: "NA"
    SQL_REMOTE_DB_PORT: "0"
    SQL_LOCAL_SCANNING_DB: "NA"
    TZ: "Asia/Karachi"
  13. Additionally, update the configuration to match the credentials at the end of the same file, docker-compose.yml.

    mssql_exporter:
    container_name: prometheus_mssql_exporter
    image: awaragi/prometheus-mssql-exporter
    environment:
    USERNAME: "sa"
    PASSWORD: "admin@3311"
    SERVER: "sqlserver"
    TZ: "Asia/Karachi"
  14. Return to the main directory ansible-deployments and change the hosts: NCL2 configuration in start_sooperwizer_api.yml to hosts: server. There are two scripts: start_sooperwizer_api.yml and start_sooperwizer_api_new.yml. Use start_sooperwizer_api.yml if your Ubuntu version is 20.04 or older. Use start_sooperwizer_api_new.yml if your operating system version is 22.04 or later.

  15. To run the script, open the Terminal and execute ansible-playbook script.yml -i inventory. Replace script.yml with either start_sooperwizer_api.yml or start_sooperwizer_api_new.yml according to your operating system version.

  16. This will complete the deployment on the server side.

TiZnp is a lower end application that is use to run on Floor PC which is being used as a controller device to control all the scanning devices.

We can deploy everything on Floor PC using the Server which we have setup in sooperwizer_api guide. You just need ssh setup on floor pc and Server can ping the floor pc. After making sure these conditions are satisfied Follow these steps:

  1. First you need to edit the inventory file. In the inventory file go to [nodes] section and edit the first node. First enter the node name in place of qa, for ansible_host=you can remove the existing ip address and enter the floor pc ip address. ansible_user= you will enter the floor pc username and in ansible_ssh_pass, ansible_sudo_pass enter the user password for floor pc. For zone_id you can define some number or you can ask embedded team about zone_id. node_name should be floor pc name and company_id should be company name.

  2. After completing above steps you need to clone the TiZnp repository. Run git clone -b branch_name https://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@github.com/WiMetrixDev/TiZnp-gateway.git. The branch_name should be ZStack-3 or ZStack-Mesh. For the new client or latest application we deploy ZStack-3 and for older clients we deploy ZStack-Mesh. For the confirmation asks the embedded team which branch we need to deploy.

  3. First, we need to install docker and deploy Portainer on the floor PC. To do this, edit the hosts: NCL3 entry in either install_docker.yml or install_docker_new.yml and change it to the node name previously added in the inventory file.

  4. There are two scripts available: install_docker.yml and install_docker_new.yml, depending on your operating system version. If the Ubuntu version is 20.04 or older, use install_docker.yml. If the operating system version is 22.04 or later, use install_docker_new.yml on the floor PC.

  5. After selecting the appropriate script and editing the hosts setting in the file, run ansible-playbook script.yml -i inventory. The script should be either install_docker.yml or install_docker_new.yml. This will install Docker and the necessary prerequisites on the floor PC.

  6. Once the above script has successfully executed, change the hosts setting in deploy_portainer.yml and deploy Portainer using ansible-playbook deploy_portainer.yml -i inventory.

  7. After deploying Portainer, you need to edit some settings in the start_TiZNP_service.yml file on the server. Open the file in a text editor and update the SERVER= entry to match the IP address of the machine where sooperwizer_api is deployed. Additionally, update the API_ENDPOINT= entry to match the sooperwizer_api server IP address. Adjust the TZ= entry according to the client’s time zone.

    - name: Creating environment file
    copy:
    dest: /home/{{ansible_ssh_user}}/workspace/TiZnp-gateway/znp.env
    content: |
    PORT=3000
    SERVER=172.16.4.70
    API_ENDPOINT=sooperwizer_api
    API_PORT=8000
    NATS_PORT=4222
    CLIENT={{ansible_host}}
    PRODUCER_TOPIC="znpproduce
    CONSUMER_TOPIC=lights
    TZ=Asia/Amman
    DEBUG=cc-znp
    ZONE={{zone_id}}
    NODE={{node_name}}
    COMPANY={{company_id}}
  8. After completing all the above steps, run ansible-playbook start_TiZNP_service.yml -i inventory. This will deploy the TiZnp service on the floor PC.