def runawstojson(cmd): prox = lD.detect_proxy() and lD.no_ssl_over_proxy if prox: cmd = "--no-verify-ssl " + cmd output = lD.run_quiet("aws " + cmd) if len(output.strip()): return json.loads(output.strip()) else: return {}
def runawstojson(cmd): """ Run aws CLI command and return the response as JSON :param cmd: command to be executed """ prox = lD.detect_proxy() and lD.no_ssl_over_proxy if prox: cmd = "--no-verify-ssl " + cmd output = lD.run_quiet("aws " + cmd) if len(output.strip()): return json.loads(output.strip()) else: return {}
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 time.sleep(5)
if __name__ == "__main__": ip, iid, security_conf, dest_type = parse_opts() # only needed in main function installfrom = os.path.realpath(os.sep.join(__file__.split(os.sep)[:-1])) liblocation = os.path.realpath(installfrom) jsondat = open(os.path.expanduser(security_conf)) security_config = json.loads(jsondat.read()) jsondat.close() sys.path.append(liblocation) import kavedeploy as lD import kaveaws as lA lA.checksecjson(security_config, requirefield=[], requirekeys=["SSH"]) if ip is None: lA.testaws() ip = lA.pub_ip(iid) git = False gitenv = None if lD.detect_proxy(): print "Did you already configure this machine to access port " + str( lD.proxy_port) + "? If not you'll need to turn your proxy off." lD.testproxy() remote = lD.remoteHost('root', ip, security_config["AccessKeys"]["SSH"]["KeyFile"]) if "GIT" in security_config["AccessKeys"]: git = True gitenv = security_config["AccessKeys"]["GIT"] lD.deploy_our_soft(remote, pack="kavetoolbox", git=git, gitenv=gitenv, options='--' + dest_type) # if dest_type == "workstation": # lD.confremotessh(remote)
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() upped = lA.up_default(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, username + "_dev_box") ip = lA.pub_ip(iid) acount = 0
installfrom = os.path.realpath(os.sep.join(__file__.split(os.sep)[:-1])) liblocation = os.path.realpath(installfrom) jsondat = open(os.path.expanduser(security_conf)) security_config = json.loads(jsondat.read()) jsondat.close() sys.path.append(liblocation) import kavedeploy as lD import kaveaws as lA lA.checksecjson(security_config, requirefield=[], requirekeys=["SSH"]) if ip is None: lA.testaws() ip = lA.pub_ip(iid) git = False gitenv = None if lD.detect_proxy(): print "Did you already configure this machine to access port " + str( lD.proxy_port) + "? If not you'll need to turn your proxy off." lD.testproxy() remote = lD.remoteHost('root', ip, security_config["AccessKeys"]["SSH"]["KeyFile"]) if "GIT" in security_config["AccessKeys"]: git = True gitenv = security_config["AccessKeys"]["GIT"] lD.deploy_our_soft(remote, pack="kavetoolbox", git=git, gitenv=gitenv, options='--' + dest_type) # if dest_type == "workstation": # lD.confremotessh(remote)