def database(nodename=None, image=None, flavor=None): """Bootstrap a new standalone database server.""" nodename = nodename or api.env.get('nodename_database') nodename = nodename or missing_env('nodename_database') image = image or api.env.get('os_image') image = image or missing_env('os_image') flavor = flavor or api.env.get('flavor_database') flavor = flavor or missing_env('flavor_database') role = api.env.get('role_database') role = role or missing_env('role_database') runlist = ','.join([ 'role[%s]' % role, 'recipe[propertyshelf::rackspace_backup]', ]) opts = dict( environment='production', flavor=flavor, image=image, nodename=nodename, runlist=runlist, servername=nodename, ) rackspace.create(**opts)
def frontend(nodename=None, image=None, flavor=None): """Bootstrap a new standalone frontend server.""" nodename = nodename or api.env.get('nodename_frontend') nodename = nodename or missing_env('nodename_frontend') image = image or api.env.get('os_image') image = image or missing_env('os_image') flavor = flavor or api.env.get('flavor_frontend') flavor = flavor or missing_env('flavor_frontend') role = api.env.get('role_frontend') role = role or missing_env('role_frontend') runlist = ','.join([ 'role[%s]' % role, ]) opts = dict( environment='production', flavor=flavor, image=image, nodename=nodename, runlist=runlist, servername=nodename, ) rackspace.create(**opts)
def worker(nodename=None, image=None, flavor=None): """Bootstrap a new standalone application worker.""" number = rackspace.next_client_number( environment='production', rolename=api.env.role_worker, ) nodename = nodename or api.env.get('nodename_worker') + '-%02d' % number nodename = nodename or missing_env('nodename_worker') image = image or api.env.get('os_image') image = image or missing_env('os_image') flavor = flavor or api.env.get('flavor_worker') flavor = flavor or missing_env('flavor_worker') role = api.env.get('role_worker') role = role or missing_env('role_worker') runlist = ','.join([ 'role[%s]' % role, ]) opts = dict( environment='production', flavor=flavor, image=image, nodename=nodename, runlist=runlist, servername=nodename, ) rackspace.create(**opts)
def staging(nodename=None, image=None, flavor=None): """Bootstrap a staging system.""" nodename = nodename or api.env.get('nodename_staging') nodename = nodename or missing_env('nodename_staging') image = image or api.env.get('os_image') image = image or missing_env('os_image') flavor = flavor or api.env.get('flavor_staging') flavor = flavor or missing_env('flavor_staging') role = api.env.get('role_staging') role = role or missing_env('role_staging') runlist = ','.join([ 'role[%s]' % role, ]) opts = dict( environment='staging', flavor=flavor, image=image, nodename=nodename, runlist=runlist, servername=nodename, ) rackspace.create(**opts)
def get_required(): """Get a list of required roles.""" result = {} role_base = api.env.get('role_base') if role_base: result['role_base'] = role_base role_database = api.env.get('role_database') role_database = role_database or missing_env('role_database') result['role_database'] = role_database role_frontend = api.env.get('role_frontend') role_frontend = role_frontend or missing_env('role_frontend') result['role_frontend'] = role_frontend role_staging = api.env.get('role_staging') if role_staging: result['role_staging'] = role_staging role_worker = api.env.get('role_worker') role_worker = role_worker or missing_env('role_worker') result['role_worker'] = role_worker return result
def development(): """Work locally with vagrant.""" # Change the default user to 'vagrant'. result = api.local('vagrant ssh-config | grep IdentityFile', capture=True) api.env.key_filename = result.replace('"', '').split()[1] api.env.user = '******' # Connect to the port-forwarded ssh. api.env.hosts = ['127.0.0.1:2222'] nodename = api.env.get('nodename_development') nodename = nodename or api.env.get('nodename_staging') nodename = nodename or missing_env('nodename_staging') api.env.hostname = 'vagrant-%(name)s-%(user)s' % { 'name': nodename, 'user': api.env.local_user, } # Set role definitions for vagrant. api.env.roledefs = { 'worker': ['127.0.0.1:2222', ], 'frontend': ['127.0.0.1:2222', ], 'database': ['127.0.0.1:2222', ], }
def remove(): """Remove an existing MLS application client.""" role = api.env.get('role_worker') role = role or missing_env('role_worker') opts = dict( environment='production', role=role, ) rackspace.remove(**opts)
def plone_m(nodename=None, image=None, flavor=None): """Bootstrap a new 'Plone M' bundle.""" nodename = nodename or api.env.get('nodename_database') nodename = nodename or missing_env('nodename_database') image = image or api.env.get('os_image') image = image or missing_env('os_image') flavor = flavor or api.env.get('flavor_database') flavor = flavor or missing_env('flavor_database') role_database = api.env.get('role_database') role_database = role_database or missing_env('role_database') role_frontend = api.env.get('role_frontend') role_frontend = role_frontend or missing_env('role_frontend') role_worker = api.env.get('role_worker') role_worker = role_worker or missing_env('role_worker') runlist = ','.join([ 'role[%s]' % role_database, 'role[%s]' % role_frontend, 'role[%s]' % role_worker, ]) opts = dict( environment='production', flavor=flavor, image=image, nodename=nodename, runlist=runlist, servername=nodename, ) rackspace.create(**opts)
def bundle_db_fe_app(nodename=None, image=None, flavor=None): """Bootstrap a new MLS bundle: Database, Frontend, App Worker.""" nodename = nodename or api.env.get('nodename_database') nodename = nodename or missing_env('nodename_database') image = image or api.env.get('os_image') image = image or missing_env('os_image') flavor = flavor or api.env.get('flavor_database') flavor = flavor or missing_env('flavor_database') role_database = api.env.get('role_database') role_database = role_database or missing_env('role_database') role_frontend = api.env.get('role_frontend') role_frontend = role_frontend or missing_env('role_frontend') role_worker = api.env.get('role_worker') role_worker = role_worker or missing_env('role_worker') runlist = ','.join([ 'role[%s]' % role_database, 'role[%s]' % role_frontend, 'role[%s]' % role_worker, 'recipe[propertyshelf::rackspace_backup]', ]) opts = dict( environment='production', flavor=flavor, image=image, nodename=nodename, runlist=runlist, servername=nodename, ) rackspace.create(**opts)