Code Monkey home page Code Monkey logo

openstackclient-docker's Introduction

OpenStackClient

A simple container image containing the OpenStack client and QEmu image tools.

Can be used in a cron-mode, executing the task regularly ($USE_CRON=1) or run only once (unset $USE_CRON). In cron-mode, it can execute a user-specified crontab ($CRONTAB=/path/to/file) or an arbitrary command ($COMMAND=/path/to/script), the latter defaulting to the OpenStack client (/usr/bin/openstack). Likewise, in non-cron-mode, the command being run can be configured in the same way ($COMMAND=/path/to/script).

Basic usage

As with the non-container OpenStack client, you need to prepare following environment variables: OS_AUTH_URL, OS_TENANT_ID, OS_TENANT_NAME, OS_PROJECT_NAME, OS_REGION_NAME, OS_USERNAME and OS_PASSWORD. You usually receive them in form of an openrc.sh script from your cloud provider.

The difference with the container image is that you need to pass these variables through to the container. In Bash you could e.g. run:

. openrc.sh
docker run $(for v in OS_AUTH_URL OS_TENANT_ID OS_TENANT_NAME OS_PROJECT_NAME OS_REGION_NAME OS_USERNAME OS_PASSWORD ; do echo --env $v=${!v} ; done) quay.io/urzds/openstackclient --version

Or in Fish shell:

. openrc.fish
docker run (for v in OS_AUTH_URL OS_TENANT_ID OS_TENANT_NAME OS_PROJECT_NAME OS_REGION_NAME OS_USERNAME OS_PASSWORD ; echo --env $v=$$v ; end) quay.io/urzds/openstackclient --version

This will expand to:

docker run --env OS_AUTH_URL=... --env OS_TENANT_ID=... --env OS_TENANT_NAME=... --env OS_PROJECT_NAME=... --env OS_REGION_NAME=... --env OS_USERNAME=... --env OS_PASSWORD=... quay.io/urzds/openstackclient --version

Cron usage

Runs the OpenStack client (or a custom crontab)

The script understands the five environment variables to control time, representing the first 5 columns of a regular crontab (see crontab(5) for details) and takes the command line parameters to the OpenStackClient as arguments:

docker run --env USE_CRON=1 --env MINUTE=... --env HOUR=... --env DAY=... --env MONTH=... --env WEEKDAY=... quay.io/urzds/openstackclient $OPENSTACKCLIENT_ARGUMENTS

All five time related variables default to *, having the regular crontab meaning of any time.

If you need a more complex setup, you can mount an entire crontab into the container and set CRONTAB=/path/to/your/crontab and the container's crontab will be initialised from there.

For how to pass the necessary environment variables to the OpenStack client, please refer to the documentation above.

Examples

In the following, ... represents the Docker flags necessary to pass the OpenStack client environment flags into the container. Please see above for details.

To print the version of the OpenStack client once per minute, you could run it like this:

docker run ... --env USE_CRON=1 quay.io/urzds/openstackclient --version

To print the list of servers accessible to you once per hour (i.e. everytime minute is 0), you would execute:

docker run ... --env USE_CRON=1 --env MINUTE=0 quay.io/urzds/openstackclient server list

openstackclient-docker's People

Watchers

James Cloos 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.