Skip to content

CloudForms Out of Browser! Order CloudForms services via the API in bulk.

Notifications You must be signed in to change notification settings

ahsen-shah/cloudforms-oob

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CloudForms Out of Browser

This repository contains scripts to order/list/retire services from CloudForms using the CloudForms API.

Examples

order examples
# export credentials
export username=username-domain.com
export password=yourpassword
export uri=https://labs.opentlc.com


# order 5 service items 'OCP HA Lab - Testing' from catalog 'DevOps Deployment Testing' in North America
./order_svc.sh -t 5 -y \
                   -c 'DevOps Deployment Testing' \
                   -d region=na \
                   -i 'OCP HA Lab - Testing'

# order 2 x OCP HA Lab (PROD) in APAC datacenter
./order_svc.sh -t 2 -y \
                   -d region=apac \
                   -c 'OPENTLC OpenShift Labs' \
                   -i 'OpenShift HA Lab'

# order 45 x OCP HA Lab (PROD), wait 20 seconds between api calls, group by 5, pause 5 minutes between groups.
./order_svc.sh -t 45 -a 20 -g 5 -p 5 -y \
                   -d region=na \
                   -c 'OPENTLC OpenShift Labs' \
                   -i 'OpenShift HA Lab'
Delete example from terminal
[user@work cloudforms-oob]$ ./get_svc.sh
20000000059300 OTLC-ADM-gucore-redhat.com-DEV_THREE_TIER_APP-f3b8
20000000059304 OTLC-ADM-gucore-redhat.com-DEV_OCP_WORKSHOP-c53b
20000000059302 OTLC-ADM-gucore-redhat.com-DEV_OCP_DEMO_LAB-1909
20000000059301 OTLC-ADM-gucore-redhat.com-DEV_ANS_TOWER_LAB-f377
20000000059303 OTLC-ADM-gucore-redhat.com-DEV_OCP_HA_LAB-442f

[user@work cloudforms-oob]$ ./get_svc.sh | ./delete_svc.sh
20000000059300 OTLC-ADM-gucore-redhat.com-DEV_THREE_TIER_APP-f3b8
20000000059304 OTLC-ADM-gucore-redhat.com-DEV_OCP_WORKSHOP-c53b
20000000059302 OTLC-ADM-gucore-redhat.com-DEV_OCP_DEMO_LAB-1909
20000000059301 OTLC-ADM-gucore-redhat.com-DEV_ANS_TOWER_LAB-f377
20000000059303 OTLC-ADM-gucore-redhat.com-DEV_OCP_HA_LAB-442f

ORDER_SVC

Purpose

Order Red Hat CloudForms (or ManageIQ) services in bulk via the API. You must provide a catalog name and catalog item (in text format).

Argument Comment

Username

If you do not provide a user name, you will be prompted for one.

Total Requests

-t <n> - Total requests specifies the amount of services you wish to order in total.

Group Count and Wait

-g <n> - Group count allows you to break up the orders into groups equaling the number of services specified.

-p <n> - Group wait will pause ordering between groups.

API Wait

-a <n> - Api wait specifies a quick pause between API calls in the same group.

URI

-w <n> - Uri is the URI of your CloudForms/ManageIQ appliance.

Keypairs

-d <key1=value1,key2=value2…​> - Using the this flag you can specify keypairs to fill out the dialog (if any) in the order form. They are comma delimited key value pairs and the key must equal the "Name" value in the service dialog.

Non-Interactive

Use -y if you don’t want to be prompted if you are sure you wish to continue. Use at your own risk!

Usage

# order_svc.sh -c <catalog name> -i <item name> [ -u <username> -t <totalRequests> -g <groupCount> -p <groupWait> -a <apiWait> -w <uri> -d <key1=value1,key2=value2...> -y ]

get_svc.sh

Get a list of your ordered services (to get GUIDs)

The script outputs one service per line in the format ID NAME.

The output of this script can be grep-ed and passed to delete_svc.sh.

Usage

# get_svc.sh [-u <username>] [ -w <uri> ]

delete_svc.sh

Use this script with caution!

INPUT: each line is a service to delete. Each line must be of the form:

ID  NAME

for example:

20000000056794 OTLC-ADM-gucore-redhat.com-DEV_THREE_TIER_APP-a63d

You can pipe the output of get_svc.sh to delete_svc.sh:

./get_svc.sh | grep OCP | ./delete_svc.sh

Usage

Error: Usage $0 [-u <username>] [ -w <uri> ]

This script reads the input from STDIN. Each line should be ID NAME of service to retire.
ex:   . credentials.rc; ./get_svc.sh | grep 'OCP'| ./delete_svc.sh

Password cannot be prompted because the script already reads from STDIN. It has to be set as an env variable.

Automation with env variables

The mandatory variables are:

  1. username

  2. password

  3. uri

You can set the mandatory variables as environment variables, with export password=…​ for password, username and uri or source it from a file. Then the script can be run without interaction.

Example:

. credentials.rc ;  ./order_svc.sh -t 20 -g 5 -c 'OPENTLC Cloud Infrastructure Labs' -i 'DEV 3 Tier App' -y
. credentials.rc ; ./get_svc.sh
# check output before deleting!
# delete all your services:
. credentials.rc ; ./get_svc.sh | ./delete_svc.sh

About

CloudForms Out of Browser! Order CloudForms services via the API in bulk.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%