Example #1
0
 def _allocateOne(self):
     client = clientfactory.factory()
     try:
         requirement = api.Requirement(imageLabel=LABEL, imageHint=HINT)
         info = api.AllocationInfo(user='******',
                                   purpose='integration test')
         allocation = client.allocate(dict(it=requirement), info)
         print "Created allocation, waiting for node inauguration"
         try:
             allocation.wait(timeout=7 * 60)
             print "Allocation successfull, waiting for ssh"
             nodes = allocation.nodes()
             assert len(nodes) == 1, nodes
             it = nodes['it']
             it.fetchSerialLog()
             allocation.fetchPostMortemPack()
             print "SSH credentials:", it.rootSSHCredentials()
             ssh = connection.Connection(**it.rootSSHCredentials())
             ssh.waitForTCPServer()
             ssh.connect()
             print "SSH connected"
             yield it, ssh, allocation
         finally:
             allocation.free()
     finally:
         client.close()
Example #2
0
 def _rackattackRequirements(self):
     result = {}
     for name, requirements in self._hosts.iteritems():
         rootfs = rootfslabel.RootfsLabel(requirements['rootfs'])
         hardwareConstraints = dict(requirements)
         del hardwareConstraints['rootfs']
         result[name] = api.Requirement(
             imageLabel=rootfs.label(), imageHint=rootfs.imageHint(),
             hardwareConstraints=hardwareConstraints)
     return result
Example #3
0
 def _startInauguratorVM(self, label, sizeGB):
     with globallock.lock:
         requirement = api.Requirement(imageLabel=label,
                                       imageHint="build",
                                       hardwareConstraints=dict(
                                           minimumDisk1SizeGB=sizeGB,
                                           minimumDisk2SizeGB=1)).__dict__
         vmInstance = vm.VM.createFromNewImage(
             config.IMAGE_BUILDING_VM_INDEX, requirement)
         stateMachine = hoststatemachine.HostStateMachine(
             vmInstance, self._inaugurate, self._tftpboot)
         stateMachine.assign(self._vmChangedState,
                             imageLabel=label,
                             imageHint="build")
         stateMachine.setDestroyCallback(self._vmCommitedSuicide)
         return vmInstance, stateMachine
 def _rackattackRequirements(self):
     result = {}
     for name, requirements in self._hosts.iteritems():
         pool = None
         if "pool" in requirements:
             pool = requirements["pool"]
         serverIDWildcard = requirements.get("serverIDWildcard", "")
         rootfs = rootfslabel.RootfsLabel(
             requirements['rootfs'], requirements.get('product', 'rootfs'))
         hardwareConstraints = dict(requirements)
         del hardwareConstraints['rootfs']
         result[name] = api.Requirement(
             imageLabel=rootfs.label(),
             imageHint=rootfs.imageHint(),
             hardwareConstraints=hardwareConstraints,
             pool=pool,
             serverIDWildcard=serverIDWildcard)
     return result
parser.add_argument("--targetNode", required=True)
parser.add_argument("--rackattackUser", required=True)
parser.add_argument("--ipAddress", required=True)
parser.add_argument("--osmosisServerIP", required=True)
args = parser.parse_args()

with open(args.rackYaml) as f:
    rackYaml = yaml.load(f)
targetNode = [n for n in rackYaml['HOSTS'] if n['id'] == args.targetNode][0]
client = clientfactory.factory()
logging.info("Allocating master node")
allocationInfo = api.AllocationInfo(user=args.rackattackUser, purpose="dryrun")
label = subprocess.check_output(
    ["solvent", "printlabel", "--thisProject", "--product=rootfs"]).strip()
requirements = dict(
    master=api.Requirement(imageLabel=label, imageHint="rootfs-basic"))
allocation = client.allocate(requirements, allocationInfo)
allocation.wait(timeout=5 * 60)
logging.info("Allocation successful, waiting for ssh")
masterNode = allocation.nodes()['master']
ssh = connection.Connection(**masterNode.rootSSHCredentials())
ssh.waitForTCPServer()
ssh.connect()
logging.info("Connected to ssh")
ssh.ftp.putFile("/tmp/master.egg", "build/master.egg")
try:
    print ssh.run.script(
        "PYTHONPATH=/tmp/master.egg "
        "strace -fF -o /tmp/trace "
        "python -m rackattack.dryrun.master.main "
        "--hostID=%(targetNodeID)s --macAddress=%(macAddress)s "
Example #6
0
import subprocess
from rackattack import clientfactory
from rackattack.ssh import connection
from rackattack import api
import pdb

hint = 'rootfs-basic'
label = subprocess.check_output([
    "solvent", "printlabel", "--product", "rootfs", "--repositoryBasename",
    "rootfs-basic"
]).strip()

client = clientfactory.factory()
try:
    requirement = api.Requirement(imageLabel=label, imageHint=hint)
    info = api.AllocationInfo(user='******',
                              purpose='integration test')
    allocation = client.allocate(dict(it=requirement), info)
    print "Created allocation, waiting for node inauguration"
    allocation.wait(timeout=7 * 60)
    print "Allocation successfull, waiting for ssh"
    try:
        nodes = allocation.nodes()
        assert len(nodes) == 1, nodes
        it = nodes['it']
        ssh = connection.Connection(**it.rootSSHCredentials())
        ssh.waitForTCPServer()
        ssh.connect()
        print "SSH connected"
        pdb.set_trace()
        echo = ssh.run.script("echo hello")
Example #7
0
import argparse
import time

parser = argparse.ArgumentParser()
parser.add_argument("--label", required=True)
parser.add_argument("--user", required=True, help="User to report to provider")
parser.add_argument("--nice", type=float, default=1)
parser.add_argument("--noSSH", action='store_true', default=False)
args = parser.parse_args()

print "Connecting"
client = clientfactory.factory()
print "Allocating"
allocation = client.allocate(requirements={
    'node':
    api.Requirement(imageLabel=args.label, imageHint="playaround")
},
                             allocationInfo=api.AllocationInfo(
                                 user=args.user,
                                 purpose="playaround",
                                 nice=args.nice))
allocation.wait(timeout=8 * 60)
assert allocation.done(), "Allocation failed"
print "Done allocating, Waiting for boot to finish"
try:
    node = allocation.nodes()['node']
    credentials = dict(port=22)
    credentials.update(node.rootSSHCredentials())
    print "ROOT SSH Credentials:"
    print credentials
    if not args.noSSH:
parser.add_argument("--label", required=True)
parser.add_argument("--user", required=True, help="User to report to provider")
parser.add_argument("--nice", type=float, default=1)
parser.add_argument("--noSSH", action='store_true', default=False)
parser.add_argument("--disk1SizeGB", type=int, default=None)
args = parser.parse_args()

print "Connecting"
client = clientfactory.factory()
print "Allocating"
hardwareConstraints = dict()
if args.disk1SizeGB is not None:
    hardwareConstraints['disk1SizeGB'] = args.disk1SizeGB
print "Hardware Constraints:", hardwareConstraints
requirement = api.Requirement(imageLabel=args.label,
                              imageHint="playaround",
                              hardwareConstraints=hardwareConstraints)
allocation = client.allocate(requirements={'node': requirement},
                             allocationInfo=api.AllocationInfo(
                                 user=args.user,
                                 purpose="playaround",
                                 nice=args.nice))
allocation.wait(timeout=8 * 60)
assert allocation.done(), "Allocation failed"
print "Done allocating, Waiting for boot to finish"
try:
    node = allocation.nodes()['node']
    credentials = dict(port=22)
    credentials.update(node.rootSSHCredentials())
    print "ROOT SSH Credentials:"
    print credentials