Giter VIP home page Giter VIP logo

cwp_custom_csv's Introduction

Intro

This script demonstrates generating custom CSV output from the /api/v1/hosts and /api/v1/containers endpoints. It is "throwaway" code and does not include test cases, is not optimized or elegant, and is not intended to be reused for other purposes.

Setup

Clone repo

git clone https://github.com/cfarquhar/cwp_custom_csv

Set up environment

Exact steps will vary depending on what you use to manage python versions and virtual environments. This works for pyenv and poetry :

cd cwp_custom_csv
pyenv install 3.10.0
pyenv local 3.10.0
poetry install
poetry shell

If you are not using poetry , install the dependencies as shown below after activating your virtualenv:

cd cwp_custom_csv
pip install -r requirements.txt

Collect & set configuration items

CWP console path

  1. Log in to SaaS console
  2. Navigate to Compute > System > Utilities
  3. In the "Path to Console" section, copy the value
  4. Create TWISTLOCK_ADDRESS environment variable with this value:
# export TWISTLOCK_ADDRESS=<CONSOLE_PATH>

CWP access key

If you already have access keys created, configure them in the environment variables as shown below.

  1. Log in to SaaS console
  2. Navigate to Settings > Access Control > Access Keys
  3. Click Add > Access Key in the top right
  4. Enter a name and expiration time (if desired)
  5. Click "Save"
  6. Copy the "Access Key ID" and "Secret Key" values
  7. Create TWISTLOCK_USER and TWISTLOCK_PASSWORD environment variables with these values:
# export TWISTLOCK_USER=<ACCESS_KEY_ID>
# export TWISTLOCK_PASSWORD=<SECRET_KEY>

Run script

$ python ./generate.py
Summary:
--------

Output file: hosts.csv
        Records retrieved from API: 127
        Rows written to CSV: 127

Output file: containers.csv
        Records retrieved from API: 405
        Rows written to CSV: 405

Output file: container_compliance.csv
        Records retrieved from API: 406
        Rows written to CSV: 1272

$ ls -1 *csv
container_compliance.csv
containers.csv
hosts.csv

cwp_custom_csv's People

Contributors

cfarquhar avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.