Example #1
0
def main():

    # Log the startup
    jarlog.logit('INFO', "Starting jarflyd")

    # Get the config
    confobj = config.GetConfig()

    # Set up the identity type
    pyrax.set_setting("identity_type", "rackspace")

    # Set up the credentials file
    cred_file = confobj.get("global", "credentials_file")
    jarlog.logit('INFO', "Authenticating using cred file: %s" % cred_file)
    pyrax.set_credential_file(cred_file)

    # Set up the default region
    globalRegion = confobj.get("global", "region")
    jarlog.logit('INFO', "Setting global region to: %s" % globalRegion)
    pyrax.connect_to_services(region=globalRegion)

    # Start reading in the jar sections
    sections = confobj.sections()
    for section in sections:
        if section.startswith("jar-"):
            processJar(confobj, section)
Example #2
0
 def test_connect_to_services(self):
     pyrax.connect_to_services()
     pyrax.connect_to_cloudservers.assert_called_once_with(region=None)
     pyrax.connect_to_cloudfiles.assert_called_once_with(region=None)
     pyrax.connect_to_cloud_loadbalancers.assert_called_once_with(
             region=None)
     pyrax.connect_to_cloud_databases.assert_called_once_with(region=None)
Example #3
0
 def test_connect_to_services(self):
     pyrax.connect_to_services()
     pyrax.connect_to_cloudservers.assert_called_once_with(region=None)
     pyrax.connect_to_cloudfiles.assert_called_once_with(region=None)
     pyrax.connect_to_cloud_loadbalancers.assert_called_once_with(
         region=None)
     pyrax.connect_to_cloud_databases.assert_called_once_with(region=None)
Example #4
0
def processJar(confobj, curjar):

    # Start processing the current jar
    jarlog.logit('INFO', "Processing jar %s" % curjar)

    # Set up the jar region
    try:
        globalRegion = confobj.get("global", "region")
        jarRegion = confobj.get(curjar, "region")
        if jarRegion != globalRegion:
            jarlog.logit('INFO', "Setting jar region to: %s" % jarRegion)
            pyrax.connect_to_services(region=jarRegion)
    except ConfigParser.NoOptionError:
        jarlog.logit('INFO', "Jar region not set, keeping global of %s"
                     % globalRegion)

    # Get the current domain and create it if needed
    domainEmail = confobj.get("global", "dns_email")
    try:
        globalDomain = confobj.get("global", "dns_domain")
        jarDomain = confobj.get(curjar, "dns_domain")
        if jarDomain != globalDomain:
            jarlog.logit('INFO', "Setting jar domain to: %s" % jarDomain)
            jardns.checkDomain(jarDomain, domainEmail)
    except ConfigParser.NoOptionError:
        jarlog.logit('INFO', "Jar domain not set, keeping global of %s"
                     % globalDomain)

    jardns.checkDomain(globalDomain, domainEmail)

    # Make sure networks exist
    dmznet = jarnets.configureNetwork(confobj,
                                      confobj.get(curjar, "dmznet_name"),
                                      confobj.get(curjar, "dmznet_cidr"))
    appnet = jarnets.configureNetwork(confobj,
                                      confobj.get(curjar, "appnet_name"),
                                      confobj.get(curjar, "appnet_cidr"))
    datanet = jarnets.configureNetwork(confobj,
                                       confobj.get(curjar, "datanet_name"),
                                       confobj.get(curjar, "datanet_cidr"))

    # To keep things simple, we are using a single global ssh key for the javad
    # process.  We can easily add support per jar later if needed.
    keyname = confobj.get("global", "ssh_public_key_name")
    keyfile = confobj.get("global", "ssh_public_key_file")
    addKey(keyname, keyfile)

    # Make sure vyatta server exists and is configured
    vyatta.configureDevice(confobj, curjar, dmznet, appnet, datanet, keyname)
Example #5
0
import os
import sys
import pyrax

if len(sys.argv) < 6:
    print >>sys.stderr, "Usage:\n  test_pyrax_identity_hubic.py [email] "\
                        "[password] [client_id] [client_secret] [redirect_uri]"
    sys.exit(1)

pyrax.set_setting("identity_type", "pyrax_identity_hubic.HubicIdentity")
pyrax._create_identity()
email, password = sys.argv[1], sys.argv[2]
client_id, client_secret, redirect_uri = sys.argv[3], sys.argv[4], sys.argv[5]
pyrax.identity.set_credentials(email,
                               password,
                               client_id,
                               client_secret,
                               redirect_uri,
                               authenticate=True)
pyrax.connect_to_services(region=None)
cf = pyrax.cloudfiles

for cont_name in cf.list_containers():
    cont = cf.get_container(cont_name)
    print "%s:" % (cont_name, )
    files = cont.get_object_names(full_listing=True)
    if files:
        print '\n'.join(['  - ' + f for f in files])
    else:
        print "  <empty>"
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import pyrax

if len(sys.argv) < 6:
    print >>sys.stderr, "Usage:\n  test_pyrax_identity_hubic.py [email] "\
                        "[password] [client_id] [client_secret] [redirect_uri]"
    sys.exit(1)

pyrax.set_setting("identity_type", "pyrax_identity_hubic.HubicIdentity")
pyrax._create_identity()
email, password = sys.argv[1], sys.argv[2]
client_id, client_secret, redirect_uri = sys.argv[3], sys.argv[4], sys.argv[5]
pyrax.identity.set_credentials(email, password, client_id, client_secret,
                               redirect_uri, authenticate=True)
pyrax.connect_to_services(region=None)
cf = pyrax.cloudfiles

for cont_name in cf.list_containers():
    cont = cf.get_container(cont_name)
    print "%s:" % (cont_name,)
    files = cont.get_object_names(full_listing=True)
    if files:
        print '\n'.join(['  - '+f for f in files])
    else:
        print "  <empty>"