ca.required_config = { "name": "S3 to Swift Sync", "version": "0.2.0", "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This script copies files from S3 to Swift which don't exist in Swift.""", "config": [{ "name": "s3bucket", "regexp": "^.{1,100}$", "title": "S3 Bucket", "description": "Bucket in s3 to copy from.", "type": "string", "required": True },{ "name": "s3accesskey", "regexp": "^.{1,100}$", "title": "S3 Access Key", "description": "Access Key for S3 Service.", "type": "string", "required": True },{ "name": "s3secretkey", "regexp": "^.{1,100}$", "title": "S3 Secret Key", "description": "Secret Key for S3 Service.", "type": "string", "required": True },{ "name": "region", "regexp": "^.{1,100}$", "title": "Swift Region", "description": "Region location for swift target container.", "type": "string", "required": True, "resource": "openstack.object-store.endpoints.region" },{ "name": "container", "regexp": "^.{1,100}$", "title": "Swift Container", "description": "Name of swift target container.", "type": "string", "required": True, "resource": "openstack.object-store.[region].containers" },{ "name": "emailreport", "title": "Email Report", "description": "Send an email report if files were synced.", "type": "boolean", "default": False, "required": False } ] }
ca.required_config = { "name": "Web Page Change Check", "version": "0.1.0", "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This script notifies a user if a web page content changes.""", "config": [{ "name": "url", "regexp": "^.+$", "title": "URL", "description": "HTTP or HTTPS URL to check.", "type": "string", "required": True },{ "name": "element", "regexp": "^.+$", "title": "Element", "description": "HTML Element to check for changes.", "type": "string", "required": False },{ "name": "class", "regexp": "^.+$", "title": "Class", "description": "HTML Element Class to check for changes.", "type": "string", "required": False },{ "name": "id", "regexp": "^.+$", "title": "ID", "description": "HTML Element ID to check for changes.", "type": "string", "required": False } ] }
ca.required_config = { "name": "Rolling Server Backup", "version": "0.1.0", "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This script cycles backups for a selected server.""", "config": [{ "name": "name", "regexp": "^.{1,50}$", "title": "Server Name", "description": "Name of the server to backup.", "type": "string", "required": True, "resource": "openstack.compute.[region].servers" },{ "name": "region", "regexp": "^.{1,50}$", "title": "Zone", "description": "Compute zone to create the server in (ie: az-2.region-a.geo-1).", "type": "string", "required": True, "resource": "openstack.compute.endpoints.region" },{ "name": "daily", "title": "Daily Backups", "description": "Number of daily backups to keep.", "type": "select", "required": True, "options": [ {"name": "0", "value": "0"}, {"name": "1", "value": "1"}, {"name": "2", "value": "2"}, {"name": "3", "value": "3"}, {"name": "4", "value": "4"}, {"name": "5", "value": "5"}, {"name": "6", "value": "6"}, {"name": "7", "value": "7"}, ] },{ "name": "weekly", "title": "Weekly Backups", "description": "Number of weekly backups to keep.", "type": "select", "required": True, "options": [ {"name": "0", "value": "0"}, {"name": "1", "value": "1"}, {"name": "2", "value": "2"}, {"name": "3", "value": "3"}, {"name": "4", "value": "4"}, {"name": "5", "value": "5"}, {"name": "6", "value": "6"}, {"name": "7", "value": "7"}, ] },{ "name": "weeklyday", "title": "Weekly Day", "description": "Day of the week to run weekly backup.", "type": "select", "required": True, "options": [ {"name": "Sunday", "value": "0"}, {"name": "Monday", "value": "1"}, {"name": "Tuesday", "value": "2"}, {"name": "Wednesday", "value": "3"}, {"name": "Thursday", "value": "4"}, {"name": "Friday", "value": "5"}, {"name": "Saturday", "value": "6"} ] } ] }
ca.required_config = { "name": "S3 to Swift Sync", "version": "0.2.0", "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This script copies files from S3 to Swift which don't exist in Swift.""", "config": [{ "name": "s3bucket", "regexp": "^.{1,100}$", "title": "S3 Bucket", "description": "Bucket in s3 to copy from.", "type": "string", "required": True }, { "name": "s3accesskey", "regexp": "^.{1,100}$", "title": "S3 Access Key", "description": "Access Key for S3 Service.", "type": "string", "required": True }, { "name": "s3secretkey", "regexp": "^.{1,100}$", "title": "S3 Secret Key", "description": "Secret Key for S3 Service.", "type": "string", "required": True }, { "name": "region", "regexp": "^.{1,100}$", "title": "Swift Region", "description": "Region location for swift target container.", "type": "string", "required": True, "resource": "openstack.object-store.endpoints.region" }, { "name": "container", "regexp": "^.{1,100}$", "title": "Swift Container", "description": "Name of swift target container.", "type": "string", "required": True, "resource": "openstack.object-store.[region].containers" }, { "name": "emailreport", "title": "Email Report", "description": "Send an email report if files were synced.", "type": "boolean", "default": False, "required": False }] }
sys.path.append(os.path.dirname(os.path.realpath(__file__))+'/lib') from cloudagents import CloudAgent from time import sleep ca = CloudAgent() ca.required_config = { "name": "Wringer", "version": "0.1.0", "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This script does integration testing.""", "config": [{ "name": "count", "regexp": "^\d+$", "title": "Count", "description": "Number to count down from.", "type": "string", "required": True } ] } def agent(): count = int(ca.conf['count']) for num in range(count,-1,-1): sleep(1) percent = 100-int((float(num)/float(count))*100.0)
ca.required_config = { "name": "Email File", "version": "0.1.0", "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This script sends an alert to a user including a file from a swift container.""", "config": [ { "name": "region", "regexp": "^.{1,50}$", "title": "Region", "description": "Short name for the object storage endpoint region to search. IE: region-a.geo-1", "type": "string", "required": True, "resource": "openstack.object-store.endpoints.region" }, { "name": "container", "regexp": "^.{1,50}$", "title": "Container", "description": "Name of the container to search for the file.", "type": "string", "required": True, "resource": "openstack.object-store.[region].containers" }, { "name": "date", "regexp": "^.{1,250}$", "title": "Date Adjustment", "description": "Date adjustment. Enables time substitution in object name. IE: 'yesterday'. Dates are compared in UTC.", "type": "string", "required": False, }, { "name": "name", "regexp": "^.{1,250}$", "title": "Name", "description": "Object name to email from the container. If a date adjustment is set, python datetime time substution is enabled. IE: 'reports/%Y-%m-%d.txt'", "type": "string", "required": True }, ] }
ca.required_config = { "name": "File Existence Checker", "version": "0.2.0", "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This script checks to see if a file exists inside of a swift container. It also has functions to allow for searching for files named on relative dates, daily backups for instance.""", "config": [{ "name": "region", "regexp": "^.{1,50}$", "title": "Region", "description": "Short name for the object storage endpoint region to search. IE: region-a.geo-1", "type": "string", "required": True, "resource": "openstack.object-store.endpoints.region" },{ "name": "container", "regexp": "^.{1,50}$", "title": "Container", "description": "Name of the container to search for the file.", "type": "string", "required": True, "resource": "openstack.object-store.[region].containers" },{ "name": "date", "regexp": "^.{1,250}$", "title": "Date Adjustment", "description": "Date adjustment. Enables time substitution in object name. IE: 'yesterday'. Dates are compared in UTC.", "type": "string", "required": False, },{ "name": "name", "regexp": "^.{1,250}$", "title": "Name", "description": "Object name to check for in the container. If a date adjustment is set, python datetime time substution is enabled. IE: 'backups/%Y-%m-%d.zip'", "type": "string", "required": True }, ] }
ca.required_config = { "name": "Image Gallery", "version": "0.1.0", "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This script looks for jpg/png files in a container, thumbnails them into another public container and creates html contact sheets for each directory.""", "config": [ { "name": "region", "regexp": "^.{1,50}$", "title": "Region", "description": "Short name for the source object storage endpoint region.", "type": "string", "required": True, "resource": "openstack.object-store.endpoints.region" }, { "name": "container", "regexp": "^.{1,50}$", "title": "Container", "description": "Name of the container to search for the source graphics in.", "type": "string", "required": True, "resource": "openstack.object-store.[region].containers" }, { "name": "path", "regexp": "^.{1,250}$", "title": "Path", "description": "Path to search for jpgs under (ie: uploads/pictures/).", "type": "string", "required": False }, { "name": "galleryregion", "regexp": "^.{1,50}$", "title": "Gallery Region", "description": "Short name for the object storage endpoint region.", "type": "string", "required": True, "resource": "openstack.object-store.endpoints.region" }, { "name": "gallerycontainer", "regexp": "^.{1,50}$", "title": "Gallery Container", "description": "Name of the container to put the gallery in.", "type": "string", "required": True, "resource": "openstack.object-store.[region].containers" }, { "name": "gallerypath", "regexp": "^.{1,250}$", "title": "Gallery Path", "description": "Subdirectory for the gallery (ie: gallery/).", "type": "string", "required": False }, ] }
from keystoneclient.v2_0 import client import swiftclient import novaclient.v1_1 import json import urllib2 from collections import defaultdict import StringIO import csv ca = CloudAgent() ca.required_config = { "name": "Usage Change", "version": "0.1.0", "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This script audits what resources you're using across the cloud, and sends you a notification with details and changes.""", "config": [ ] } def agent(): ca.log("Starting!") keystone = client.Client(token=ca.creds['token'], tenant_id=ca.creds['tenantId'], auth_url=ca.creds['identity_url']) catalog = keystone.service_catalog.catalog text = "" if ca.datastore:
from cloudagents import CloudAgent import urllib2 import json ca = CloudAgent() ca.required_config = { "name": "Relay", "version": "0.1.0", "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This agent schedules another single run task some time in the future with the same name, interval, etc. It's a demo for agents interacting directly with the agents service.""", "config": [{ "name": "interval", "regexp": "^\d+$", "title": "Interval", "description": "Time between agent executions.", "type": "string", "required": True }] } def agent(): # Log my config. response = agent_query(url=ca.service['api_url'],
from cloudagents import CloudAgent import urllib2 import json ca = CloudAgent() ca.required_config = { "name": "Relay", "version": "0.1.0", "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This agent schedules another single run task some time in the future with the same name, interval, etc. It's a demo for agents interacting directly with the agents service.""", "config": [{ "name": "interval", "regexp": "^\d+$", "title": "Interval", "description": "Time between agent executions.", "type": "string", "required": True } ] } def agent(): # Log my config. response = agent_query(url=ca.service['api_url'], path="/tasks/"+str(ca.service['task_id']),tenant_id=ca.creds['tenantId'], data=None,token=ca.creds['token'],method="GET")
ca.required_config = { "name": "Twitter Backup", "version": "0.2.0", "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This script grabs tweets from twitter and saves them into object storage.""", "config": [{ "name": "screen_name", "regexp": "^.{1,50}$", "title": "Screen Name", "description": "Twitter screen name to backup.", "type": "string", "required": True },{ "name": "region", "regexp": "^.{1,50}$", "title": "Region", "description": "Short name for the object storage endpoint region to use (ie: region-a.geo-1).", "type": "string", "required": True, "resource": "openstack.object-store.endpoints.region" },{ "name": "container", "regexp": "^.{1,50}$", "title": "Container", "description": "Name of the container to store backups in (ie: archive).", "type": "string", "required": True, "resource": "openstack.object-store.[region].containers" },{ "name": "path", "regexp": "^.{1,250}$", "title": "File Path", "description": "Path to store the files under (ie: backup/tweets).", "type": "string", "required": True } ] }
sys.path.append(os.path.dirname(os.path.realpath(__file__))+'/lib') from cloudagents import CloudAgent from time import sleep ca = CloudAgent() ca.required_config = { "name": "Count Up", "version": "0.1.0", "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This script counts up from 0 by the count number given, storing the end number in a datastore. If the datastore contains a number, it starts there instead of 0.""", "config": [{ "name": "count", "regexp": "^\d+$", "title": "Count", "description": "Number to count up.", "type": "string", "required": True } ] } def agent(): count = int(ca.conf['count']) if ca.datastore: start = int(ca.datastore) else:
ca.required_config = { "name": "Apache Install", "version": "0.2.0", "credentials": True, "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This script creates a new VM and installs Apache 2 on it.""", "config": [{ "name": "name", "regexp": "^.{1,50}$", "title": "Server Name", "description": "Name for the new server.", "type": "string", "required": True },{ "name": "region", "regexp": "^.{1,50}$", "title": "Zone", "description": "Compute zone to create the server in (ie: az-2.region-a.geo-1).", "type": "string", "required": True, "resource": "openstack.compute.endpoints.region" },{ "name": "keypair", "regexp": "^.{1,50}$", "title": "Key Pair", "description": "Name of the existing keypair to use for the new server.", "type": "string", "required": True, "resource": "openstack.compute.[region].keypairs" },{ "name": "flavor", "regexp": "^.{1,20}$", "title": "Flavor", "description": "Flavor/size of the server to create (ie: standard.xsmall).", "type": "string", "required": True, "resource": "openstack.compute.[region].flavors" },{ "name": "secgroup", "regexp": "^.{1,40}$", "title": "Security Group", "description": "Security group to create the server in.", "type": "string", "required": True, "resource": "openstack.compute.[region].security-groups" },{ "name": "software", "title": "CMS Software", "description": "CMS software to install on your server.", "type": "select", "required": True, "options": [ {"name": "None", "value": "none", "default": True}, {"name": "Wordpress", "value": "wordpress"}, {"name": "Drupal", "value": "drupal"}, ] } ] }
ca.required_config = { "name": "Image Gallery", "version": "0.1.0", "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This script looks for jpg/png files in a container, thumbnails them into another public container and creates html contact sheets for each directory.""", "config": [{ "name": "region", "regexp": "^.{1,50}$", "title": "Region", "description": "Short name for the source object storage endpoint region.", "type": "string", "required": True, "resource": "openstack.object-store.endpoints.region" },{ "name": "container", "regexp": "^.{1,50}$", "title": "Container", "description": "Name of the container to search for the source graphics in.", "type": "string", "required": True, "resource": "openstack.object-store.[region].containers" },{ "name": "path", "regexp": "^.{1,250}$", "title": "Path", "description": "Path to search for jpgs under (ie: uploads/pictures/).", "type": "string", "required": False },{ "name": "galleryregion", "regexp": "^.{1,50}$", "title": "Gallery Region", "description": "Short name for the object storage endpoint region.", "type": "string", "required": True, "resource": "openstack.object-store.endpoints.region" },{ "name": "gallerycontainer", "regexp": "^.{1,50}$", "title": "Gallery Container", "description": "Name of the container to put the gallery in.", "type": "string", "required": True, "resource": "openstack.object-store.[region].containers" },{ "name": "gallerypath", "regexp": "^.{1,250}$", "title": "Gallery Path", "description": "Subdirectory for the gallery (ie: gallery/).", "type": "string", "required": False }, ] }
ca.required_config = { "name": "Rolling Server Backup", "version": "0.1.0", "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This script cycles backups for a selected server.""", "config": [{ "name": "name", "regexp": "^.{1,50}$", "title": "Server Name", "description": "Name of the server to backup.", "type": "string", "required": True, "resource": "openstack.compute.[region].servers" }, { "name": "region", "regexp": "^.{1,50}$", "title": "Zone", "description": "Compute zone to create the server in (ie: az-2.region-a.geo-1).", "type": "string", "required": True, "resource": "openstack.compute.endpoints.region" }, { "name": "daily", "title": "Daily Backups", "description": "Number of daily backups to keep.", "type": "select", "required": True, "options": [ { "name": "0", "value": "0" }, { "name": "1", "value": "1" }, { "name": "2", "value": "2" }, { "name": "3", "value": "3" }, { "name": "4", "value": "4" }, { "name": "5", "value": "5" }, { "name": "6", "value": "6" }, { "name": "7", "value": "7" }, ] }, { "name": "weekly", "title": "Weekly Backups", "description": "Number of weekly backups to keep.", "type": "select", "required": True, "options": [ { "name": "0", "value": "0" }, { "name": "1", "value": "1" }, { "name": "2", "value": "2" }, { "name": "3", "value": "3" }, { "name": "4", "value": "4" }, { "name": "5", "value": "5" }, { "name": "6", "value": "6" }, { "name": "7", "value": "7" }, ] }, { "name": "weeklyday", "title": "Weekly Day", "description": "Day of the week to run weekly backup.", "type": "select", "required": True, "options": [{ "name": "Sunday", "value": "0" }, { "name": "Monday", "value": "1" }, { "name": "Tuesday", "value": "2" }, { "name": "Wednesday", "value": "3" }, { "name": "Thursday", "value": "4" }, { "name": "Friday", "value": "5" }, { "name": "Saturday", "value": "6" }] }] }
ca.required_config = { "name": "Server Resize", "version": "0.1.0", "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This script resizes a server by snapshotting it, creating a new larger server with the snapshot, and moving the floating IP.""", "config": [{ "name": "name", "regexp": "^.{1,50}$", "title": "Server Name", "description": "Name of the server to resize.", "type": "string", "required": True, "resource": "openstack.compute.[region].servers" }, { "name": "newname", "regexp": "^.{1,50}$", "title": "New Server Name", "description": "Name for the resized server (must be different than the existing server name).", "type": "string", "required": True }, { "name": "region", "regexp": "^.{1,50}$", "title": "Zone", "description": "Compute zone to create the server in (ie: az-2.region-a.geo-1).", "type": "string", "required": True, "resource": "openstack.compute.endpoints.region" }, { "name": "flavor", "regexp": "^.{1,20}$", "title": "Flavor", "description": "Flavor/size of the server to migrate to (ie: standard.xsmall).", "type": "string", "required": True, "resource": "openstack.compute.[region].flavors" }] }
ca.required_config = { "name": "Server Resize", "version": "0.1.0", "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This script resizes a server by snapshotting it, creating a new larger server with the snapshot, and moving the floating IP.""", "config": [{ "name": "name", "regexp": "^.{1,50}$", "title": "Server Name", "description": "Name of the server to resize.", "type": "string", "required": True, "resource": "openstack.compute.[region].servers" },{ "name": "newname", "regexp": "^.{1,50}$", "title": "New Server Name", "description": "Name for the resized server (must be different than the existing server name).", "type": "string", "required": True },{ "name": "region", "regexp": "^.{1,50}$", "title": "Zone", "description": "Compute zone to create the server in (ie: az-2.region-a.geo-1).", "type": "string", "required": True, "resource": "openstack.compute.endpoints.region" },{ "name": "flavor", "regexp": "^.{1,20}$", "title": "Flavor", "description": "Flavor/size of the server to migrate to (ie: standard.xsmall).", "type": "string", "required": True, "resource": "openstack.compute.[region].flavors" } ] }
ca.required_config = { "name": "Email File", "version": "0.1.0", "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This script sends an alert to a user including a file from a swift container.""", "config": [{ "name": "region", "regexp": "^.{1,50}$", "title": "Region", "description": "Short name for the object storage endpoint region to search. IE: region-a.geo-1", "type": "string", "required": True, "resource": "openstack.object-store.endpoints.region" },{ "name": "container", "regexp": "^.{1,50}$", "title": "Container", "description": "Name of the container to search for the file.", "type": "string", "required": True, "resource": "openstack.object-store.[region].containers" },{ "name": "date", "regexp": "^.{1,250}$", "title": "Date Adjustment", "description": "Date adjustment. Enables time substitution in object name. IE: 'yesterday'. Dates are compared in UTC.", "type": "string", "required": False, },{ "name": "name", "regexp": "^.{1,250}$", "title": "Name", "description": "Object name to email from the container. If a date adjustment is set, python datetime time substution is enabled. IE: 'reports/%Y-%m-%d.txt'", "type": "string", "required": True }, ] }
sys.path.append(os.path.dirname(os.path.realpath(__file__))+'/lib') from cloudagents import CloudAgent from time import sleep ca = CloudAgent() ca.required_config = { "name": "Countdown Timer", "version": "0.1.0", "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This script counts down from count to 0, returning a message per second.""", "config": [{ "name": "count", "regexp": "^\d+$", "title": "Count", "description": "Number to count down from.", "type": "string", "required": True } ] } def agent(): count = int(ca.conf['count']) for num in range(count,-1,-1): sleep(1) percent = 100-int((float(num)/float(count))*100.0)
ca.required_config = { "name": "File Existence Checker", "version": "0.2.0", "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This script checks to see if a file exists inside of a swift container. It also has functions to allow for searching for files named on relative dates, daily backups for instance.""", "config": [ { "name": "region", "regexp": "^.{1,50}$", "title": "Region", "description": "Short name for the object storage endpoint region to search. IE: region-a.geo-1", "type": "string", "required": True, "resource": "openstack.object-store.endpoints.region" }, { "name": "container", "regexp": "^.{1,50}$", "title": "Container", "description": "Name of the container to search for the file.", "type": "string", "required": True, "resource": "openstack.object-store.[region].containers" }, { "name": "date", "regexp": "^.{1,250}$", "title": "Date Adjustment", "description": "Date adjustment. Enables time substitution in object name. IE: 'yesterday'. Dates are compared in UTC.", "type": "string", "required": False, }, { "name": "name", "regexp": "^.{1,250}$", "title": "Name", "description": "Object name to check for in the container. If a date adjustment is set, python datetime time substution is enabled. IE: 'backups/%Y-%m-%d.zip'", "type": "string", "required": True }, ] }
ca.required_config = { "name": "Apache Install", "version": "0.2.0", "credentials": True, "author": "Jeff Kramer", "url": "http://www.hpcloud.com/", "help": """This script creates a new VM and installs Apache 2 on it.""", "config": [{ "name": "name", "regexp": "^.{1,50}$", "title": "Server Name", "description": "Name for the new server.", "type": "string", "required": True }, { "name": "region", "regexp": "^.{1,50}$", "title": "Zone", "description": "Compute zone to create the server in (ie: az-2.region-a.geo-1).", "type": "string", "required": True, "resource": "openstack.compute.endpoints.region" }, { "name": "keypair", "regexp": "^.{1,50}$", "title": "Key Pair", "description": "Name of the existing keypair to use for the new server.", "type": "string", "required": True, "resource": "openstack.compute.[region].keypairs" }, { "name": "flavor", "regexp": "^.{1,20}$", "title": "Flavor", "description": "Flavor/size of the server to create (ie: standard.xsmall).", "type": "string", "required": True, "resource": "openstack.compute.[region].flavors" }, { "name": "secgroup", "regexp": "^.{1,40}$", "title": "Security Group", "description": "Security group to create the server in.", "type": "string", "required": True, "resource": "openstack.compute.[region].security-groups" }, { "name": "software", "title": "CMS Software", "description": "CMS software to install on your server.", "type": "select", "required": True, "options": [ { "name": "None", "value": "none", "default": True }, { "name": "Wordpress", "value": "wordpress" }, { "name": "Drupal", "value": "drupal" }, ] }] }