Python Libraries for DevOps

Python Libraries for DevOps

Table of contents

Tasks

  1. Create a Dictionary in Python and write it to a JSON File.

    Output:

  2. Read a JSON file services.json kept in this folder and print the service names of every cloud service provider.

     output
    
     aws : ec2
     azure : VM
     gcp : compute engine
    

    Here we first read the JSON file, on the left side of the image, kept in this folder and parse by using the loads() function then we print this file data by print function.

  3. Read YAML file using python, file services.yaml and read the contents to convert YAML to JSON.

    • First, we write the file data to the Yaml file using the dump() function & Then we fetch all data from Yaml by using the safe_load function.

    • File data is available in the Yaml file as we see on the left side of the image.

    • Then we converted the Yaml file to a JSON file and formatted the JSON file can be seen on the right side image as a result.

That's all guys.

Thank you for your valuable time.


Thanks for learning with me!

Keep Learning and stay healthy.