Exemple #1
0
    def runTest(self):
        """
        Tests which cehck the function of the deployment library,
        but do not need any environment parameters or access to aws
        """
        import kavedeploy as lD

        lD.testproxy()
        self.assertIsNot(lD.which("ls"), None)
        self.assertRaises(RuntimeError, lD.run_quiet, ("thisisnotacommand"))
        stdout = lD.run_quiet(['which', 'ls'], shell=False)
        self.assertTrue('/bin/ls' in stdout)
        self.assertIsNot(lD.which("pdsh"), None,
                         "pdsh is not installed, please install it in order to test the multiremotes functionality, "
                         "sudo yum -y install pdsh")
        lD.run_quiet("touch /tmp/fake_test_ssh_key.pem")
        lD.run_quiet("chmod 400 /tmp/fake_test_ssh_key.pem")
        test = lD.remoteHost("root", "test", '/tmp/fake_test_ssh_key.pem')
        test = lD.multiremotes([test.host], access_key='/tmp/fake_test_ssh_key.pem')
security_group = security_config["SecurityGroup"]
keypair = security_config["AccessKeys"]["AWS"]["KeyName"]
keyloc = security_config["AccessKeys"]["AWS"]["KeyFile"]
subnet = None

if "Subnet" in security_config:
    subnet = security_config["Subnet"]

lA.testaws()

if lD.detect_proxy() and lD.proxy_blocks_22:
    raise SystemError(
        "This proxy blocks port 22, that means you can't ssh to your machines to do the initial configuration. To "
        "skip this check set kavedeploy.proxy_blocks_22 to false and kavedeploy.proxy_port=22")

lD.testproxy()
instancetype = lA.chooseinstancetype(instancetype)

upped = lA.up_os(osval, instancetype, security_group, keypair, subnet=subnet)
print "submitted"

iid = lA.iid_from_up_json(upped)[0]

import time

time.sleep(5)
lA.name_resource(iid, machinename)

ip = lA.pub_ip(iid)
acount = 0
while (ip is None and acount < 20):
Exemple #3
0
    print __doc__
    raise ValueError("Only one arguement allowed! The keyfile")

if len(sys.argv) == 2:
    keyfile = sys.argv[1]
else:
    if "AWSSECCONF" not in os.environ:
        print __doc__
        raise IOError(
            "please specify keyfile or set AWSSECCONF environment variable!")
    keyfile = os.path.expanduser(os.environ["AWSSECCONF"])

import kavedeploy as lD

lD.debug = verbose
lD.testproxy()
import kaveaws as lA

import json

try:
    jsondat = open(keyfile)
    security_config = json.loads(jsondat.read())
    jsondat.close()
    lA.checksecjson(security_config, requirekeys=["AWS"])
    keyfile = security_config["AccessKeys"]["AWS"]["KeyFile"]
except:
    pass

if not os.path.exists(os.path.expanduser(keyfile)):
    raise IOError("That is not a valid keyfile!", keyfile)