예제 #1
0
    def pre_check(self):
        """
        Check that security config exists and that lD library is importable
        """
        import kavedeploy as lD
        import kaveaws as lA

        lD.debug = self.debug
        lD.strict_host_key_checking = False
        import os

        if "AWSSECCONF" not in os.environ:
            raise SystemError(
                "You need to set the environment variable AWSSECCONF to point to your security config file before "
                "running this test")
        self.assertTrue(lA.testaws(),
                        "Local aws installation incomplete, try again")
        self.assertTrue(
            len(lA.detect_region()) > 0,
            "Failed to detect aws region, have you run aws configure?")
        import json

        jsondat = open(os.path.expanduser(os.environ["AWSSECCONF"]))
        l = jsondat.read()
        jsondat.close()
        # print l
        security_config = json.loads(l)
        # print lD.checksecjson(security_config)
        self.assertTrue(
            lA.checksecjson(security_config),
            "Security config not readable correctly or does not contain enough keys!"
        )
        if self.branch == "__local__":
            self.branch = lD.run_quiet("bash -c \"cd " +
                                       os.path.dirname(__file__) +
                                       "; git branch | sed -n '/\* /s///p'\"")
        if self.branch == "__service__":
            self.branch = self.service
        if self.branch is not None:
            stdout = lD.run_quiet("bash -c 'cd " + os.path.dirname(__file__) +
                                  "; git branch -r;'")
            self.assertTrue(
                "origin/" + self.branch
                in [s.strip() for s in stdout.split()
                    if len(s.strip())], "There is no remote branch called " +
                self.branch + " push your branch back to the origin "
                "to run this automated test")
        return lD
예제 #2
0
    def pre_check(self):
        """
        Check that security config exists and that lD library is importable
        """
        import kavedeploy as lD
        import kaveaws as lA

        lD.debug = self.debug
        lD.strict_host_key_checking = False
        import os

        if "AWSSECCONF" not in os.environ:
            raise SystemError(
                "You need to set the environment variable AWSSECCONF to point to your security config file before "
                "running this test")
        self.assertTrue(lA.testaws(), "Local aws installation incomplete, try again")
        self.assertTrue(len(lA.detect_region()) > 0, "Failed to detect aws region, have you run aws configure?")
        import json

        jsondat = open(os.path.expanduser(os.environ["AWSSECCONF"]))
        l = jsondat.read()
        jsondat.close()
        # print l
        security_config = json.loads(l)
        # print lD.checksecjson(security_config)
        self.assertTrue(lA.checksecjson(security_config),
                        "Security config not readable correctly or does not contain enough keys!")
        if self.branch == "__local__":
            self.branch = lD.run_quiet(
                "bash -c \"cd " + os.path.dirname(__file__) + "; git branch | sed -n '/\* /s///p'\"")
        if self.branch == "__service__":
            self.branch = self.service
        if self.branch is not None:
            stdout = lD.run_quiet("bash -c 'cd " + os.path.dirname(__file__) + "; git branch -r;'")
            self.assertTrue("origin/" + self.branch in [s.strip() for s in stdout.split() if len(s.strip())],
                            "There is no remote branch called " + self.branch + " push your branch back to the origin "
                                                                                "to run this automated test")
        return lD
osval, machinename, secf, instancetype = parse_opts()
jsondat = open(secf)
security_config = json.loads(jsondat.read())
jsondat.close()
lA.checksecjson(security_config, requirekeys=["AWS"])

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
예제 #4
0
username, password = parse_opts()
jsondat = open(secf)
security_config = json.loads(jsondat.read())
jsondat.close()
lA.checksecjson(security_config, requirekeys=["AWS"])

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()

instancetype = lA.chooseinstancetype("c4.2xlarge")

##################################################
# Create machine
##################################################

print "upping new", instancetype
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()