mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
Merge branch 'makedist'
This commit is contained in:
commit
fc8f6814aa
@ -46,6 +46,7 @@
|
|||||||
# The implementations of steps 1, 2, 4, 5, 6, and 7 will depend on the
|
# The implementations of steps 1, 2, 4, 5, 6, and 7 will depend on the
|
||||||
# distro of host we're talking to (Ubuntu, CentOS, Debian, etc.).
|
# distro of host we're talking to (Ubuntu, CentOS, Debian, etc.).
|
||||||
|
|
||||||
|
from __future__ import with_statement
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import getopt
|
import getopt
|
||||||
@ -281,7 +282,7 @@ class BaseBuilder(object):
|
|||||||
return Configurator.findOrDefault(kwargs, what, self.distro, self.version, self.arch)
|
return Configurator.findOrDefault(kwargs, what, self.distro, self.version, self.arch)
|
||||||
|
|
||||||
def runLocally(self, argv):
|
def runLocally(self, argv):
|
||||||
print argv
|
print "running %s" % argv
|
||||||
r = subprocess.Popen(argv).wait()
|
r = subprocess.Popen(argv).wait()
|
||||||
if r != 0:
|
if r != 0:
|
||||||
raise SimpleError("subcommand %s exited %d", argv, r)
|
raise SimpleError("subcommand %s exited %d", argv, r)
|
||||||
@ -345,18 +346,20 @@ class EC2InstanceBuilder (BaseBuilder):
|
|||||||
self.cert=kwargs["cert"]
|
self.cert=kwargs["cert"]
|
||||||
self.pkey=kwargs["pkey"]
|
self.pkey=kwargs["pkey"]
|
||||||
self.sshkey=kwargs["sshkey"]
|
self.sshkey=kwargs["sshkey"]
|
||||||
|
self.use_internal_name = True if "use-internal-name" in kwargs else False
|
||||||
self.terminate=False if "no-terminate" in kwargs else True
|
self.terminate=False if "no-terminate" in kwargs else True
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
"Fire up a fresh EC2 instance."
|
"Fire up a fresh EC2 instance."
|
||||||
cmd = ["ec2-run-instances",
|
argv = ["ec2-run-instances",
|
||||||
self.ami,
|
self.ami,
|
||||||
"-K", self.pkey,
|
"-K", self.pkey,
|
||||||
"-C", self.cert,
|
"-C", self.cert,
|
||||||
"-k", self.sshkey,
|
"-k", self.sshkey,
|
||||||
"-t", self.mtype,
|
"-t", self.mtype,
|
||||||
"-g", "buildbot-slave", "-g", "dist-slave", "-g", "default"]
|
"-g", "buildbot-slave", "-g", "dist-slave", "-g", "default"]
|
||||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
print "running %s" % argv
|
||||||
|
proc = subprocess.Popen(argv, stdout=subprocess.PIPE)
|
||||||
try:
|
try:
|
||||||
# for the moment, we only really care about the instance
|
# for the moment, we only really care about the instance
|
||||||
# identifier, in the second line of output:
|
# identifier, in the second line of output:
|
||||||
@ -364,6 +367,8 @@ class EC2InstanceBuilder (BaseBuilder):
|
|||||||
self.ident = proc.stdout.readline().split()[1]
|
self.ident = proc.stdout.readline().split()[1]
|
||||||
if self.ident == "":
|
if self.ident == "":
|
||||||
raise SimpleError("ident is empty")
|
raise SimpleError("ident is empty")
|
||||||
|
else:
|
||||||
|
print "Instance id: %s" % self.ident
|
||||||
finally:
|
finally:
|
||||||
r = proc.wait()
|
r = proc.wait()
|
||||||
if r != 0:
|
if r != 0:
|
||||||
@ -374,18 +379,23 @@ class EC2InstanceBuilder (BaseBuilder):
|
|||||||
# Note: it seems there can be a time interval after
|
# Note: it seems there can be a time interval after
|
||||||
# ec2-run-instance finishes during which EC2 will tell us that
|
# ec2-run-instance finishes during which EC2 will tell us that
|
||||||
# the instance ID doesn't exist. This is sort of bad.
|
# the instance ID doesn't exist. This is sort of bad.
|
||||||
self.hostname = "pending"
|
state = "pending"
|
||||||
numtries = 0
|
numtries = 0
|
||||||
giveup = 5
|
giveup = 5
|
||||||
while self.hostname == "pending":
|
while state == "pending":
|
||||||
proc = subprocess.Popen(["ec2-describe-instances", "-K", self.pkey, "-C", self.cert, self.ident], stdout=subprocess.PIPE)
|
argv = ["ec2-describe-instances", "-K", self.pkey, "-C", self.cert, self.ident]
|
||||||
|
proc = subprocess.Popen(argv, stdout=subprocess.PIPE)
|
||||||
try:
|
try:
|
||||||
proc.stdout.readline() #discard line 1
|
proc.stdout.readline() #discard line 1
|
||||||
line = proc.stdout.readline()
|
line = proc.stdout.readline()
|
||||||
if line:
|
if line:
|
||||||
fields = line.split()
|
fields = line.split()
|
||||||
if len(fields) > 2:
|
if len(fields) > 2:
|
||||||
self.hostname = fields[3]
|
state = fields[3]
|
||||||
|
if self.use_internal_name:
|
||||||
|
self.hostname = fields[4]
|
||||||
|
else:
|
||||||
|
self.hostname = fields[3]
|
||||||
else:
|
else:
|
||||||
raise SimpleError("trouble parsing ec2-describe-instances output\n%s", line)
|
raise SimpleError("trouble parsing ec2-describe-instances output\n%s", line)
|
||||||
finally:
|
finally:
|
||||||
@ -432,6 +442,9 @@ class SshableBuilder (BaseBuilder):
|
|||||||
try:
|
try:
|
||||||
s.connect((self.hostname, 22))
|
s.connect((self.hostname, 22))
|
||||||
self.sshwait = False
|
self.sshwait = False
|
||||||
|
print "connected on port 22 (ssh)"
|
||||||
|
time.sleep(5) # arbitrary timeout, in case the
|
||||||
|
# remote sshd is slow.
|
||||||
except socket.error, err:
|
except socket.error, err:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
@ -512,10 +525,11 @@ def main():
|
|||||||
# def checkEnvironment():
|
# def checkEnvironment():
|
||||||
|
|
||||||
def processArguments():
|
def processArguments():
|
||||||
# flagspec [ (short, long, argument?, description)* ]
|
# flagspec [ (short, long, argument?, description, argname)* ]
|
||||||
flagspec = [ ("?", "usage", False, "Print a (useless) usage message", None),
|
flagspec = [ ("?", "usage", False, "Print a (useless) usage message", None),
|
||||||
("h", "help", False, "Print a help message and exit", None),
|
("h", "help", False, "Print a help message and exit", None),
|
||||||
("N", "no-terminate", False, "Leave the EC2 instance running at the end of the job", None),
|
("N", "no-terminate", False, "Leave the EC2 instance running at the end of the job", None),
|
||||||
|
("I", "use-internal-name", False, "Use the EC2 internal hostname for sshing", None),
|
||||||
# These get defaulted, but the user might want to override them.
|
# These get defaulted, but the user might want to override them.
|
||||||
("A", "ami", True, "EC2 AMI id to use", "ID"),
|
("A", "ami", True, "EC2 AMI id to use", "ID"),
|
||||||
("l", "login", True, "User account for ssh access to host", "LOGIN"),
|
("l", "login", True, "User account for ssh access to host", "LOGIN"),
|
||||||
|
Loading…
Reference in New Issue
Block a user