def _rollback():
    print("rolling back...")
    if os.path.exists(RACKATTACK_LOCK + '.lock') and os.path.exists(YAML_BACKUP_PATH):
        shutil.copyfile(YAML_BACKUP_PATH, YAML_CONF_PATH)
        print("copied back the original rack.yaml file")
        clientfactory.factory().call("admin__asyncReloadConfiguration")
        print("issued the reload configuration command")
    else:
        print("no lock or previous version of configuration found!")
Пример #2
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()
Пример #3
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()
def create_connections():
    global rackattack_client, db
    # Reload because somehow the socket gets recreated only when this happens
    reload(rackattack.tcp.transport)
    reload(clientfactory)
    rackattack_client = clientfactory.factory()
    db = elasticsearchdbwrapper.ElasticserachDBWrapper(alert_func=send_mail)
def create_connections():
    global rackattack_client, db
    # Reload because somehow the socket gets recreated only when this happens
    reload(rackattack.tcp.transport)
    reload(clientfactory)
    rackattack_client = clientfactory.factory()
    db = elasticsearch.Elasticsearch()
Пример #6
0
 def __init__(self, username, password, hostname, port, ipAddress, nodeId, info):
     self._username = username
     self._password = password
     self._hostname = hostname
     self._port = port
     self._ipAddress = ipAddress
     self._id = nodeId
     self._info = info
     self._ipcClient = clientfactory.factory()
 def run(self):
     while True:
         time.sleep(self._INTERVAL)
         try:
             client = clientfactory.factory()
         except:
             logging.exception("Unable to create ipc client")
             continue
         try:
             self._work(client)
         finally:
             client.close()
def createClientAndTryAllocating(imageLabel):
    connectionString = "tcp://*****:*****@@amqp://guest:guest@localhost:1013/%2F@@http://localhost:1016"
    print "Trying to create the client..."
    client = clientfactory.factory(connectionString)
    print "Allocating..."
    requirement = testlib.getRequirement(imageLabel)
    allocation = client.allocate(requirements={'virthost': requirement},
                                 allocationInfo=testlib.whiteboxAllocationInfo())
    print "Waiting for allocation..."
    try:
        allocation.wait()
    except Exception as e:
        print "Failed to create an allocation: %s" % e.message
 def __init__(self, nodeBaseName="node"):
     assert sum(self.SCENARIOS_PROBABILITIES.values()) == 1
     super(RackattackTestClients, self).__init__()
     self._nodeBaseName = nodeBaseName
     self._client = clientfactory.factory()
     with open(config.CONFIGURATION_FILE) as f:
         conf = yaml.load(f.read())
     self._osmosisServerIP = conf["OSMOSIS_SERVER_IP"]
     self._label = self._generateLabelName()
     self._nrHosts = self._getNrHosts()
     self._nrAllocatedHosts = 0
     self._profiledAllocation = None
     self._allocations = set()
     self._stop = False
Пример #10
0
    def __init__(self, hosts):
        self._hosts = hosts
        self._client = clientfactory.factory()
        self._allocation = self._client.allocate(
            requirements=self._rackattackRequirements(), allocationInfo=self._rackattackAllocationInfo())
#       self._allocation.setForceReleaseCallback()
        try:
            self._allocation.wait(timeout=self._TIMEOUT)
        except:
            logging.exception("Allocation failed, attempting post mortem")
            self._postMortemAllocation()
            raise
        self._nodes = self._allocation.nodes()
        assert suite.runOnEveryHost is None
        suite.runOnEveryHost = self.runOnEveryHost
Пример #11
0
 def run(self):
     while True:
         try:
             connectionString = self.CONNECTION_STRING_PATTERN.replace("<ADDR>", self._host)
             client = clientfactory.factory(connectionString)
         except:
             logging.error("Unable to create ipc client to %(host)s", dict(host=self._host))
             time.sleep(self._INTERVAL)
             continue
         try:
             self._work(client)
         except:
             time.sleep(self._INTERVAL)
         finally:
             client.close()
    def __init__(self, hosts):
        self._hosts = hosts
        self._overallPercent = 0
        self._client = clientfactory.factory()
        self._allocation = self._client.allocate(
            requirements=self._rackattackRequirements(), allocationInfo=self._rackattackAllocationInfo())
        self._allocation.registerProgressCallback(self._progress)
#       self._allocation.setForceReleaseCallback()
        try:
            self._waitForAllocation()
        except:
            logging.exception("Allocation failed, attempting post mortem")
            self._postMortemAllocation()
            raise
        self._nodes = self._allocation.nodes()
        assert suite.runOnEveryHost is None
        suite.runOnEveryHost = self.runOnEveryHost
Пример #13
0
 def __init__(self, hosts, allocationID=None):
     self._hosts = hosts
     self._overallPercent = 0
     self._client = clientfactory.factory()
     if allocationID is None:
         self._allocation = self._client.allocate(
             requirements=self._rackattackRequirements(),
             allocationInfo=self._rackattackAllocationInfo())
     else:
         self._allocation = self._client.allocateExisting(
             requirements=self._rackattackRequirements(),
             allocationID=allocationID)
     self._allocation.registerProgressCallback(self._progress)
     #       self._allocation.setForceReleaseCallback()
     try:
         self._waitForAllocation()
     except:
         logging.exception("Allocation failed, attempting post mortem")
         self._postMortemAllocation()
         raise
     self._nodes = self._allocation.nodes()
Пример #14
0
 def run(self):
     while True:
         assert self._hostThreads == []
         try:
             client = clientfactory.factory()
             self._connectionToProviderIsLive = True
             client.setConnectionToProviderInterruptedCallback(self._connectionToProviderInterrupted)
             try:
                 self._runPoolOverRackattackClient(client)
             finally:
                 client.close()
         except:
             logging.exception("Rackattack Client failed, retrying")
             time.sleep(10)
         finally:
             for thread in self._hostThreads:
                 logging.info("Waiting for host thread to terminate")
                 thread.join(10 * 60)
                 if thread.isAlive():
                     logging.error("Host thread still alive 10 minutes after rackattack client failure")
                 else:
                     logging.info("Host thread terminated")
         self._hostThreads = []
def main():
    print """Available commands:
        bgstress on/off
        \tRuns allocations (and frees them) in the background.
        allocate nrHosts [pool=default]
        \tAllocates the given number of hosts from the given pool.
        free
        \tFrees the current allocation (which was created with the 'allocate' command, if such allocation
        exists."""
    useFakeGeneralConfiguration()
    import pdb

    pdb.set_trace()
    global backgroundStressTestClient, profilingTestClient, profilingAllocation
    backgroundStressTestClient = RackattackTestClients("background-stress")
    profilingTestClient = RackattackTestClients("profiling")
    client = clientfactory.factory()
    profilingAllocation = False
    commands = dict(bgstress=bgStress, allocate=allocate, free=free)
    while True:
        cmdline = raw_input()
        cmdline = cmdline.strip()
        if not cmdline:
            continue
        cmdline = cmdline.split(" ")
        cmdline = [item.strip() for item in cmdline]
        commandName = cmdline[0]
        args = cmdline[1:]
        if commandName not in commands:
            print "Invalid command: %(commandName)s" % dict(commandName=commandName)
            continue
        command = commands[commandName]
        try:
            command(*args)
        except Exception as e:
            print "An error has occurred while executing command: %(message)s" % dict(message=e.message)
            continue
def main():
    client = clientfactory.factory()
    print client.call('admin__queryStatus')
import os
from rackattack import clientfactory


def setLocalRackattack():
    localProvider = "tcp://*****:*****@@amqp://guest:guest@localhost:1013@@http://localhost:1016"
    os.environ["RACKATTACK_PROVIDER"] = localProvider


if __name__ == '__main__':
    if "RACKATTACK_PROVIDER" not in os.environ:
        setLocalRackattack()
    client = clientfactory.factory()
    print client.call("admin__reloadStateMachineConfiguration")
from rackattack import clientfactory

client = clientfactory.factory()
import pprint
pprint.pprint(client.call('admin__queryStatus'))
def main():
    client = clientfactory.factory()
    print json.dumps(client.call('admin__queryStatus'))
Пример #20
0
 def __init__(self, yamlConf=YAML):
     self._yaml = yaml.load(open(yamlConf))
     self._yamlConfPath = yamlConf
     self._client = clientfactory.factory()
Пример #21
0
 def createClient(self):
     os.environ[
         'RACKATTACK_PROVIDER'] = 'tcp://*****:*****@tcp://localhost:%d' % (
             self._requestPort, self._subscribePort)
     return clientfactory.factory()
 def createClient(self):
     os.environ['RACKATTACK_PROVIDER'] = 'tcp://*****:*****@tcp://localhost:%d' % (
         self._requestPort, self._subscribePort)
     return clientfactory.factory()