diff --git a/ocaml/events/event_listen.py b/ocaml/events/event_listen.py deleted file mode 100755 index 79c0f8c4735..00000000000 --- a/ocaml/events/event_listen.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/python - -import xmlrpclib, sys - -# Don't forget to include the port in the url (eg http://melton:8086/) -if len(sys.argv) <> 4: - raise "Expected arguments: " - -server = xmlrpclib.Server(sys.argv[1]); -session = server.session.login_with_password(sys.argv[2], sys.argv[3], "1.0", "xen-api-event-listen.py")['Value'] - -server.event.register(session, ["*"]) -while True: - events = server.event.next(session)['Value'] - for event in events: - print event['id'], " ", event['class'], " ", event['operation'], " ",event['ref'], " ", - if "snapshot" in event.keys(): - print "OK" - else: - print "(no snapshot)" diff --git a/ocaml/message-switch/core_test/message_switch_test.py b/ocaml/message-switch/core_test/message_switch_test.py deleted file mode 100644 index 5566adf8a08..00000000000 --- a/ocaml/message-switch/core_test/message_switch_test.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env python - -# Copyright (c) 2012 Citrix Systems Inc -# -# Permission to use, copy, modify, and distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import unittest, os -from message_switch import * - -try: - tmpdir = os.environ["TMPDIR"] -except KeyError: - tmpdir = "/tmp" - -basedir = os.path.join(tmpdir, "link_test") - -rpc_req = Message("hello", 1L, "reply_to") -rpc_res = Message("hello", 1L) - -class Internal_invariants(unittest.TestCase): - def test_Message_save_load(self): - for m in [rpc_req, rpc_res]: - n = Message.load(m.save()) - assert m.payload == n.payload - assert m.correlation_id == n.correlation_id - assert m.reply_to == n.reply_to - -def load(x): - path = os.path.join(basedir, x) - f = open(path, "r") - try: - return f.read() - finally: - f.close() - -class Ocaml_interop(unittest.TestCase): - def test_login(self): - py = Login("hello").to_request().to_string() - ocaml = load("login") - assert py == ocaml - def test_create_named(self): - py = Create_request("service").to_request().to_string() - ocaml = load("create") - assert py == ocaml - def test_create_anon(self): - py = Create_request().to_request().to_string() - ocaml = load("create.anon") - assert py == ocaml - def test_subscribe(self): - py = Subscribe("service").to_request().to_string() - ocaml = load("subscribe") - assert py == ocaml - def test_request(self): - py = Send("service", rpc_req).to_request().to_string() - ocaml = load("request") - assert py == ocaml - def test_response(self): - py = Send("service", rpc_res).to_request().to_string() - ocaml = load("reply") - assert py == ocaml - def test_transfer(self): - py = Transfer_request(3, 5.0).to_request().to_string() - ocaml = load("transfer") - assert py == ocaml - def test_ack(self): - py = Ack(3).to_request().to_string() - ocaml = load("ack") - assert py == ocaml - - def test_create_reply(self): - ocaml = Create_response.of_response(Http_response.of_string(load("create.reply"))) - assert ocaml.name == "service" - def test_transfer_reply(self): - ocaml = Transfer_response.of_response(Http_response.of_string(load("transfer.reply"))) - m = { - 1L: rpc_req, - 2L: rpc_res, - } - py = Transfer_response(m) - for k in py.messages: - assert k in ocaml.messages - assert str(py.messages[k]) == str(ocaml.messages[k]) - for k in ocaml.messages: - assert k in py.messages - assert str(py.messages[k]) == str(ocaml.messages[k]) - -if __name__ == "__main__": - unittest.main() diff --git a/ocaml/message-switch/python/message_switch.py b/ocaml/message-switch/python/message_switch.py deleted file mode 100755 index 460d4ee2e04..00000000000 --- a/ocaml/message-switch/python/message_switch.py +++ /dev/null @@ -1,414 +0,0 @@ -#!/usr/bin/env python - -# Copyright (c) 2012 Citrix Systems Inc -# -# Permission to use, copy, modify, and distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -import json - -class Http_request: - def __init__(self, method, uri, body = None): - self.method = method - self.uri = uri - self.body = body - - def to_string(self): - body = "" - if self.body: - body = self.body - lines = [ - "%s %s HTTP/1.1" % (self.method, self.uri), - "Content-Length: %d" % len(body), - "", - body - ] - return "\r\n".join(lines) - -class Http_response: - def __init__(self, body): - self.body = body - - def to_string(self): - lines = [ - "HTTP/1.1 200 OK", - "Content-Length: %d" % len(self.body), - "", - self.body - ] - return "\r\n".join(lines) - - @classmethod - def of_string(cls, txt): - lines = txt.split("\r\n") - if lines[0] <> "HTTP/1.1 200 OK": - raise "Unexpected status line: %s" % lines[0] - rest = "\r\n".join(lines[3:]) - return cls(rest) - -class Message: - def __init__(self, payload, correlation_id, reply_to = None): - self.payload = payload - self.correlation_id = correlation_id - self.reply_to = reply_to - - def save(self): - result = { - "payload": self.payload, - "correlation_id": self.correlation_id - } - if self.reply_to: - result["reply_to"] = self.reply_to - return result - - @classmethod - def load(cls, x): - payload = x["payload"] - correlation_id = x["correlation_id"] - reply_to = None - if "reply_to" in x: - reply_to = x["reply_to"] - return cls(payload, correlation_id, reply_to) - - def __str__(self): - return json.dumps(self.save()) - -class Login: - def __init__(self, some_credential): - self.some_credential = some_credential - - def to_request(self): - return Http_request("GET", "/login/%s" % self.some_credential) - -class Create_request: - def __init__(self, name = None): - self.name = name - - def to_request(self): - uri = "/create" - if self.name: - uri = uri + "/" + self.name - return Http_request("GET", uri) - -class Create_response: - def __init__(self, name = None): - self.name = name - - @classmethod - def of_response(cls, response): - return cls(response.body) - - def to_response(self): - return Http_response(self.name) - -class Subscribe: - def __init__(self, name): - self.name = name - - def to_request(self): - return Http_request("GET", "/subscribe/%s" % self.name) - -class Send: - def __init__(self, name, message): - self.name = name - self.message = message - def to_request(self): - if self.message.reply_to: - return Http_request("POST", "/send/%s/%d/%s" % (self.name, self.message.correlation_id, self.message.reply_to), self.message.payload) - else: - return Http_request("POST", "/send/%s/%d" % (self.name, self.message.correlation_id), self.message.payload) - -class Transfer_request: - def __init__(self, ack_to, timeout): - self.ack_to = ack_to - self.timeout = timeout - - def to_request(self): - return Http_request("GET", "/transfer/%Ld/%.16g" % (self.ack_to, self.timeout)) - -class Transfer_response: - def __init__(self, messages): - self.messages = messages - - @classmethod - def of_response(cls, response): - x = json.loads(response.body) - result = {} - for (k, v) in x["messages"]: - result[long(k)] = Message.load(v) - return Transfer_response(result) - -class Ack: - def __init__(self, ack): - self.ack = ack - - def to_request(self): - return Http_request("GET", "/ack/%Ld" % self.ack) - -import string, socket - -default_config = { - "ip": "169.254.0.1", # HIMN IP of dom0 - "port": 8080, # default for xenswitch -} - -class End_of_file(Exception): - def __init__(self): - pass -class Bad_status(Exception): - def __init__(self, status): - self.status = status -class Missing_content_length(Exception): - def __init__(self): - pass -class StreamReader: - def __init__(self, sock): - self.sock = sock - self.buffered = "" - def read_fragment(self, n): - if len(self.buffered) > 0: - num_available = min(n, len(self.buffered)) - fragment = self.buffered[0:num_available] - self.buffered = self.buffered[num_available:] - return fragment - else: - self.buffered = self.sock.recv(16384) - if len(self.buffered) == 0: - raise End_of_file() - return self.read_fragment(n) - def read(self, n): - results = "" - while n > 0: - fragment = self.read_fragment(n) - n = n - len(fragment) - results = results + fragment - return results - - def readline(self): - results = "" - eol = False - while not eol: - byte = self.read(1) - if byte == "\n": - eol = True - else: - results = results + byte - return results - -def link_send(sock, m): - sock.sendall(m.to_request().to_string()) - -def link_recv(reader): - status = reader.readline() - if not(status.startswith("HTTP/1.1 200 OK")): - raise Bad_status(status) - content_length = None - eoh = False - while not eoh: - header = reader.readline().strip() - if header == "": - eoh = True - else: - bits = header.split(":") - key = string.lower(bits[0]) - if key == "content-length": - content_length = int(bits[1]) - if content_length == None: - raise Missing_content_length() - body = reader.read(content_length) - return Http_response(body) - -def login(sock, reader, some_credential): - link_send(sock, Login(some_credential)) - link_recv(reader) - -def create(sock, reader, name = None): - link_send(sock, Create_request(name)) - return Create_response.of_response(link_recv(reader)).name - -def subscribe(sock, reader, name): - link_send(sock, Subscribe(name)) - link_recv(reader) - -def send(sock, reader, name, msg): - link_send(sock, Send(name, msg)) - link_recv(reader) - -def transfer(sock, reader, ack_to, timeout): - link_send(sock, Transfer_request(ack_to, timeout)) - return Transfer_response.of_response(link_recv(reader)).messages - -def ack(sock, reader, id): - link_send(sock, Ack(id)) - link_recv(reader) - -from threading import Thread, Event, Lock - -class Receiver(Thread): - def __init__(self, sock, reader, server): - Thread.__init__(self) - self.daemon = True - self.sock = sock - self.reader = reader - self.server = server - self.events = {} - self.replies = {} - def register_correlation_id(self, correlation_id): - event = Event() - self.events[correlation_id] = event - return event - def get_reply(self, correlation_id): - reply = self.replies[correlation_id] - del self.replies[correlation_id] - return reply - def set_listen_callback(self, listen_callback): - self.listen_callback = listen_callback - def run(self): - ack_to = -1L - timeout = 5.0 - while True: - messages = transfer(self.sock, self.reader, ack_to, timeout) - for id in messages.keys(): - ack_to = max(ack_to, id) - m = messages[id] - reply_to = m.reply_to - if reply_to: - reply = self.server.dispatch(m) - send(self.sock, self.reader, reply_to, reply) - ack(self.sock, self.reader, id) - else: - if m.correlation_id not in self.events: - print >>sys.stderr, "Unknown correlation_id: %d" % m.correlation_id - else: - self.replies[m.correlation_id] = m.payload - event = self.events[m.correlation_id] - del self.events[m.correlation_id] - event.set() - -class Connection: - def __init__(self, client, name): - self.client = client - self.name = name - def rpc(self, request): - return self.client.rpc(self.name, request) - -class Server: - def __init__(self): - pass - def dispatch(self, request): - # echo the request back - request.reply_to = None - return request - -class Switch: - def __init__(self, some_credential, config = default_config, server = Server()): - self.some_credential = some_credential - self.config = config - self.server = server - - # Open a connection for requests and one for events - self.request_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.request_sock.connect((config["ip"], config["port"])) - self.request_stream_reader = StreamReader(self.request_sock) - self.request_mutex = Lock() - login(self.request_sock, self.request_stream_reader, some_credential) - - self.event_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.event_sock.connect((config["ip"], config["port"])) - self.event_stream_reader = StreamReader(self.event_sock) - login(self.event_sock, self.event_stream_reader, some_credential) - - self.receiver_thread = Receiver(self.event_sock, self.event_stream_reader, self.server) - self.receiver_thread.start() - self.next_correlation_id = 0 - self.next_correlation_id_mutex = Lock() - - def correlation_id(self): - self.next_correlation_id_mutex.acquire() - try: - correlation_id = self.next_correlation_id - self.next_correlation_id = self.next_correlation_id + 1 - return correlation_id - finally: - self.next_correlation_id_mutex.release() - - def rpc(self, name, request): - correlation_id = self.correlation_id() - event = self.receiver_thread.register_correlation_id(correlation_id) - - self.request_mutex.acquire() - try: - reply_queue = create(self.request_sock, self.request_stream_reader) - subscribe(self.request_sock, self.request_stream_reader, reply_queue) - send(self.request_sock, self.request_stream_reader, name, Message(request, correlation_id, reply_queue)) - finally: - self.request_mutex.release() - - event.wait() - return self.receiver_thread.get_reply(correlation_id) - - def connect(self, service): - self.request_mutex.acquire() - try: - create(self.request_sock, self.request_stream_reader, service) - finally: - self.request_mutex.release() - - return Connection(self, service) - - def listen(self, service): - self.request_mutex.acquire() - try: - create(self.request_sock, self.request_stream_reader, service) - subscribe(self.request_sock, self.request_stream_reader, service) - finally: - self.request_mutex.release() - - -if __name__ == "__main__": - from optparse import OptionParser - import sys, time - - parser = OptionParser() - parser.add_option("-x", "--switch", dest="switch", type="string", - help="address of message switch", metavar="SWITCH") - parser.add_option("-l", "--listen", dest="listen", action="store_true", - help="listen for RPCs, instead of sending them") - parser.add_option("-s", "--service", dest="service", type="string", - help="name of the remote service") - parser.add_option("-c", "--client", dest="client_name", type="string", - help="name which identifies this client") - - (options, args) = parser.parse_args() - config = default_config - if options.switch: - bits = options.switch.split(":") - config["ip"] = bits[0] - if len(bits) == 2: - config["port"] = int(bits[1]) - - client_name = "test_python" - if options.client_name: - client_name = options.client_name - if not options.service: - print >> sys.stderr, "Must provide a --service name" - sys.exit(1) - - if options.listen: - s = Switch(client_name, server = Server()) - s.listen(options.service) - while True: - time.sleep(5) - else: - s = Switch(client_name) - c = s.connect(options.service) - print c.rpc("hello") diff --git a/ocaml/tests/has_vendor_device_test.py b/ocaml/tests/has_vendor_device_test.py deleted file mode 100644 index 5d5ceaf542d..00000000000 --- a/ocaml/tests/has_vendor_device_test.py +++ /dev/null @@ -1,159 +0,0 @@ -#!/usr/bin/env python - -from __future__ import print_function -import xmlrpclib -import sys - -s=xmlrpclib.Server("http://localhost/") -sess=s.session.login_with_password("root","xenroot")['Value'] - -pool = s.pool.get_all(sess)['Value'][0] -restrictions = s.pool.get_restrictions(sess,pool)['Value'] - -base_request = {'user_version':'1', 'is_a_template':False, 'affinity':'', 'memory_static_max':'4', 'memory_static_min':'1', 'memory_dynamic_max':'3', 'memory_dynamic_min':'2', 'VCPUs_params':{}, 'VCPUs_max':'1', 'VCPUs_at_startup':'1', 'name_label':'hello', 'name_description':'hi', 'memory_target':'2', 'actions_after_shutdown':'destroy', 'actions_after_reboot':'restart', 'actions_after_crash':'destroy', 'PV_bootloader':'', 'PV_kernel':'', 'PV_ramdisk':'', 'PV_args':'', 'PV_bootloader_args':'', 'PV_legacy_args':'', 'HVM_boot_policy':'', 'HVM_boot_params':{}, 'HVM_shadow_multiplier':1.0, 'platform':{}, 'PCI_bus':'', 'other_config':{}, 'recommendations':'', 'xenstore_data':{}, 'ha_always_run':False, 'ha_restart_priority':'1', 'tags':[], 'blocked_operations':{}, 'protection_policy':'', 'is_snapshot_from_vmpp':False, 'appliance':'', 'start_delay':'0', 'shutdown_delay':'0', 'order':'0', 'suspend_SR':'', 'version':'0', 'generation_id':'', 'hardware_platform_version':'0'} - -# - -def create(): - res = s.VM.create(sess, base_request) - return res - -def create_with_vd(b): - request = base_request.copy() - request['has_vendor_device']=b - return s.VM.create(sess,request) - -# VD in request | OK by license | pool.policy_no_vendor_device | resulting VM.has_vendor_device -# - | False | False | False -# False | False | False | False -# True | False | False | Failure -# - | False | True | False -# False | False | True | False -# True | False | True | Failure - - -def test_with_restriction(): # OK by license column above - # Expect this to be successful on an unlicensed host, and for the field to be 'false' - print("running restricted tests (license says you're not allowed the vendor device)") - - s.pool.set_policy_no_vendor_device(sess,pool,False) - -# - | False | False | False - res = create() - vm = res['Value'] - expected = False - found = s.VM.get_has_vendor_device(sess,vm)['Value'] - print("Expecting has-vendor-device to be %s: got %s" % (expected,found)) - assert(expected == found) - -# False | False | False | False - res = create_with_vd(False) - vm = res['Value'] - expected = False - found = s.VM.get_has_vendor_device(sess,vm)['Value'] - print("Expecting has-vendor-device to be %s: got %s" % (expected,found)) - assert(expected == found) - -# True | False | False | Failure - res = create_with_vd(True) - print("Expecting failure: got %s" % res['Status']) - assert(res['Status']=='Failure') - - s.pool.set_policy_no_vendor_device(sess,pool,True) - -# - | False | True | False - res = create() - vm = res['Value'] - expected = False - found = s.VM.get_has_vendor_device(sess,vm)['Value'] - print("Expecting has-vendor-device to be %s: got %s" % (expected,found)) - assert(expected == found) - -# False | False | True | False - res = create_with_vd(False) - vm = res['Value'] - expected = False - found = s.VM.get_has_vendor_device(sess,vm)['Value'] - print("Expecting has-vendor-device to be %s: got %s" % (expected,found)) - assert(expected == found) - -# True | False | True | Failure - res = create_with_vd(True) - print("Expecting failure: got %s" % res['Status']) - assert(res['Status']=='Failure') - - - -def test_no_restriction(): - print("running unrestricted tests") - -# - | True | False | True -# False | True | False | False -# True | True | False | True -# - | True | True | False -# False | True | True | False -# True | True | True | True - - s.pool.set_policy_no_vendor_device(sess,pool,False) - -# - | True | False | True - res = create() - vm = res['Value'] - expected = True - found = s.VM.get_has_vendor_device(sess,vm)['Value'] - print("Expecting has-vendor-device to be %s: got %s" % (expected,found)) - assert(expected == found) - -# False | True | False | False - res = create_with_vd(False) - vm = res['Value'] - expected = False - found = s.VM.get_has_vendor_device(sess,vm)['Value'] - print("Expecting has-vendor-device to be %s: got %s" % (expected,found)) - assert(expected == found) - -# True | True | False | True - res = create_with_vd(True) - vm = res['Value'] - expected = True - found = s.VM.get_has_vendor_device(sess,vm)['Value'] - print("Expecting has-vendor-device to be %s: got %s" % (expected,found)) - assert(expected == found) - - s.pool.set_policy_no_vendor_device(sess,pool,True) - -# - | True | True | False - res = create() - vm = res['Value'] - expected = False - found = s.VM.get_has_vendor_device(sess,vm)['Value'] - print("Expecting has-vendor-device to be %s: got %s" % (expected,found)) - assert(expected == found) - -# False | True | True | False - res = create_with_vd(False) - vm = res['Value'] - expected = False - found = s.VM.get_has_vendor_device(sess,vm)['Value'] - print("Expecting has-vendor-device to be %s: got %s" % (expected,found)) - assert(expected == found) - -# True | True | True | True - res = create_with_vd(True) - vm = res['Value'] - expected = True - found = s.VM.get_has_vendor_device(sess,vm)['Value'] - print("Expecting has-vendor-device to be %s: got %s" % (expected,found)) - assert(expected == found) - - - -if restrictions['restrict_pci_device_for_auto_update'] == "true": - test_with_restriction() -else: - test_no_restriction() - - - - - diff --git a/pyproject.toml b/pyproject.toml index abcdd512aab..764ff6e60e1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -250,7 +250,6 @@ discard_messages_matching = [ ] expected_to_fail = [ # Need 2to3 -w and maybe a few other minor updates: - "scripts/hatests", "scripts/backup-sr-metadata.py", "scripts/restore-sr-metadata.py", # SSLSocket.send() only accepts bytes, not unicode string as argument: diff --git a/scripts/hatests b/scripts/hatests deleted file mode 100755 index 8828820ecb3..00000000000 --- a/scripts/hatests +++ /dev/null @@ -1,260 +0,0 @@ -#!/usr/bin/env python - -from __future__ import print_function -import XenAPI -import getopt -import sys -import os -import commands -import random -import time -import httplib -import urllib - -def check(svm, ip): - """ - checking that the pool is in the same condition as before - """ - global master - global masterref - global hosts - global vmrunning - flag = True - masterref2 = svm.xenapi.pool.get_all_records().values()[0]['master'] - if masterref2 != masterref : - print("From " + ip + " point of view the pool master is " + svm.xenapi.host.get_record(masterref2)["address"]) - flag = False - hosts2 = svm.xenapi.host.get_all_records() - if len(hosts) != len(hosts2) : - print("From " + ip + " point of view the number of hosts is changed.") - flag = False - for k in hosts.keys() : - if k not in hosts2 : - print("From " + ip + " point of view " + hosts[k]["address"] + " is not present any more.") - vmrecords2 = svm.xenapi.VM.get_all_records() - vmrunning2 = {} - for k, v in vmrecords2.iteritems() : - if v['power_state'] == 'Running' and int(v['domid']) == 0: - vmrunning2[k] = v - if len(vmrunning) != len(vmrunning2) : - print("From " + ip + " point of view some VMs have changed state.") - flag = False - for k, v in vmrunning.iteritems() : - if k not in vmrunning2 : - print("From " + ip + " point of view " + v['name_label'] + " is not online any more.") - if flag : - print("On %s everything is consistent." % ip) - -def help() : - print(""" - Usage: hatests - - where options can be: - -w, --wait wait time between stopping an host and restarting it - (default 120) - - where test can be: - master_hard_failure - master_soft_failure - slave_hard_failure - slave_soft_failure - master_vif_unplug - """) - -###### START ###### - -secs = 120 - -optlist, args = getopt.getopt(sys.argv[1:],"w:h", ["wait=", "help"]) -for o, a in optlist: - if o == "-w" or o == "--wait": - secs = int(a) - elif o == "-h" or o == "--help" : - help() - sys.exit(0) - -if len(args) != 1 : - help() - sys.exit(1) - -##read config file -#config = open(sys.args[1], "r") -#slave = [] -#for line in config : -# type, ip = line.lstrip().split() -# if type == "master" : -# master = ip -# else : -# slave.append(ip) - -#connection -s = XenAPI.Session('http://localhost') -s.login_with_password('root', 'xenroot', '1.0', 'xen-api-scripts-hatest') - -#Getting all the installed and running VMs with dom-id > 0 -slaves = [] -master = None -vmrecords = s.xenapi.VM.get_all_records() -for k, v in vmrecords.iteritems() : - if v['power_state'] == 'Running' and int(v['domid']) > 0: - ip = commands.getoutput("xenstore-ls /local/domain/" + v['domid'] + " | grep ip") - try: - ip = ip.split()[2] - ip = ip[1:-1] - slaves.append((k, ip)) - except: - print("VM in dom" + v['domid'] + " doesn't have an IP address") - -#finding out which one is the master -svm = XenAPI.Session("http://" + slaves[0][1]) -try : - svm.login_with_password('root', 'xenroot', '1.0', 'xen-api-scripts-hatest') - masterref = svm.xenapi.pool.get_all_records().values()[0]['master'] - masterrecord = svm.xenapi.host.get_record(masterref) - masterip = masterrecord['address'] -except XenAPI.Failure as inst: - masterip = inst.details[1] - svm = XenAPI.Session("http://" + masterip) - svm.login_with_password('root', 'xenroot', '1.0', 'xen-api-scripts-hatest') - masterref = svm.xenapi.pool.get_all_records().values()[0]['master'] -for i in slaves : - if masterip == i[1] : - master = i - slaves.remove(i) - break -print("Master ip address is " + master[1]) - -#getting ip -> hostref references -hosts = {} -hostsrecs = svm.xenapi.host.get_all_records() -for k, v in hostsrecs.iteritems() : - hosts[v['address']] = k - -#getting the VM running -vmrunning = {} -vmrecords = svm.xenapi.VM.get_all_records() -for k, v in vmrecords.iteritems() : - if v['power_state'] == 'Running' and int(v['domid']) == 0: - vmrunning[k] = v - -bringup = None -vifbringup = None -if sys.argv[-1] == "master_hard_failure" : - print("Shutting down the master") - s.xenapi.VM.hard_shutdown(master[0]) - bringup = master[0] -elif sys.argv[-1] == "master_soft_failure" : - print("Shutting down the master") - s.xenapi.VM.clean_shutdown(master[0]) - bringup = master[0] -elif sys.argv[-1] == "slave_hard_failure" : - r = random.randint(0, len(slaves) - 1) - print("Shutting down slave " + slaves[r][1]) - s.xenapi.VM.hard_shutdown(slaves[r][0]) - bringup = slaves[r][0] -elif sys.argv[-1] == "slave_hard_failure" : - r = random.randint(0, len(slaves) - 1) - print("Shutting down slave " + slaves[r][1]) - s.xenapi.VM.clean_shutdown(slaves[r][0]) - bringup = slaves[r][0] -elif sys.argv[-1] == "master_vif_unplug" : - print("Unplugging the first found attached VIF in the master") - allvifs = s.xenapi.VIF.get_all_records() - for k, v in allvifs.iteritems() : - if v['currently_attached'] and v['VM'] == master[0]: - vifbringup = k - s.xenapi.VIF.unplug(vifbringup) - break - - -print("Waiting " + str(secs) + " seconds") -count = 0 -while count < secs : - time.sleep(1) - sys.stdout.write(".") - sys.stdout.flush() - count = count + 1 -sys.stdout.write("\n") - -if bringup is not None : - print("Bringing the host up again") - s.xenapi.VM.start(bringup, False, True) -if vifbringup is not None : - print("Plugging the VIF back again") - s.xenapi.VIF.plug(vifbringup) - -print("Waiting " + str(secs) + " seconds") -count = 0 -while count < secs : - time.sleep(1) - sys.stdout.write(".") - sys.stdout.flush() - count = count + 1 -sys.stdout.write("\n") - -print("Collecting logs now...") -try : - fileout = open("master-" + master[1] + "-log.tar.bz2", "w") - f = urllib.urlopen("http://root:xenroot@" + master[1] + "/system-status?host_id=" + hosts[master[1]]) - buf = f.read(50) - if len(buf) == 0 : - print(master[1] + " returned an empty log.") - else : - print("Wrote master log to master-" + master[1] + "-log.tar.bz2") - while len(buf) > 0 : - fileout.write(buf) - buf = f.read(50) -except IOError: - print("Unable to connect to %s: network error." % master[1]) -try: - fileout.close() - f.close() -except: - pass - -for k, ip in slaves : - try : - fileout = open("slave-" + ip + "-log.tar.bz2", "w") - f = urllib.urlopen("http://root:xenroot@" + ip + "/system-status?host_id=" + hosts[ip]) - buf = f.read(50) - if len(buf) == 0 : - print(ip + " returned an empty log.") - else : - print("Wrote slave " + ip + " log to slave-" + ip + "-log.tar.bz2") - while len(buf) > 0 : - fileout.write(buf) - buf = f.read(50) - except IOError: - print("Unable to connect to %s: network error." % ip) - try: - fileout.close() - f.close() - except: - pass - -#checking if everything is still OK -print("Connecting to " + master[1] + "...") -svm = XenAPI.Session("http://" + master[1]) -try : - svm.login_with_password('root', 'xenroot', '1.0', 'xen-api-scripts-hatest') - check(svm, master[1]) -except XenAPI.Failure as inst: - if inst.details[0] == "HOST_IS_SLAVE" : - print(master[0] + " is not master any more") -except IOError: - print("Unable to connect to %s: network error." % master[1]) - -for slave in slaves : - print("Connecting to " + slave[1] + "...") - svm = XenAPI.Session("http://" + slave[1]) - try: - svm.login_with_password('root', 'xenroot', '1.0', 'xen-api-scripts-hatest') - print("Connection succeeded! Is %s still a slave?" % slave[1]) - check(svm, slave[1]) - except XenAPI.Failure as inst: - if inst.details[0] == "HOST_IS_SLAVE" : - print("Connection failed because %s is still a slave." % slave[1]) - else : - print("Unable to connect to %s: XenAPI failure." % slave[1]) - except IOError: - print("Unable to connect to %s: network error." % slave[1]) diff --git a/scripts/mtcerrno-to-ocaml.py b/scripts/mtcerrno-to-ocaml.py deleted file mode 100755 index 399d265f724..00000000000 --- a/scripts/mtcerrno-to-ocaml.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python - -# Convert the MTC exit codes into a disjoint union type. Each line in the file looks like: - -# errdef, MTC_EXIT_SUCCESS, 0, 0, "", - -# Usage: -# cat ../xha.hg/include/mtcerrno.def | ./scripts/mtcerrno-to-ocaml.py > ocaml/xapi/xha_errno.ml - -from __future__ import print_function -import sys - -def parse(file): - all = [] - while True: - line = file.readline() - if line == "": - return all - if line.startswith("errdef, MTC_EXIT"): - bits = line.split(",") - name = bits[1].strip() - code = bits[2].strip() - desc = bits[4].strip() - this = { "name": name, "code": code, "desc": desc } - all.append(this) - -def ctor_name(x): - ctor = x['name'] - return ctor[0].upper() + ctor[1:].lower() - -def make_datatype(all): - print("type code = ") - for x in all: - print("| %s" % ctor_name(x)) - -def to_string(all): - print("let to_string : code -> string = function") - for x in all: - print("| %s -> \"%s\"" % (ctor_name(x), x['name'])) - -def to_description_string(all): - print("let to_description_string : code -> string = function") - for x in all: - print("| %s -> %s" % (ctor_name(x), x['desc'])) - -def of_int(all): - print("let of_int : int -> code = function") - for x in all: - print("| %s -> %s" % (x['code'], ctor_name(x))) - print("| x -> failwith (Printf.sprintf \"Unrecognised MTC exit code: %d\" x)") - -if __name__ == "__main__": - all = parse(sys.stdin) - print("(* Autogenerated by %s -- do not edit *)" % (sys.argv[0])) - make_datatype(all) - to_string(all) - to_description_string(all) - of_int(all) - - - - - diff --git a/scripts/scalability-tests/event-count.py b/scripts/scalability-tests/event-count.py deleted file mode 100644 index 24f3c0b5354..00000000000 --- a/scripts/scalability-tests/event-count.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python - -# Count the number of events received from the master - -from __future__ import print_function -import XenAPI, sys, time - -iso8601 = "%Y-%m-%dT%H:%M:%SZ" - - -def main(session): - global iso8601 - - token = '' - call_timeout = 30.0 - - while True: - sys.stdout.flush() - - now = time.time() - now_string = time.strftime(iso8601, time.gmtime(now)) - - try: - output = session.xenapi.event_from(["*"], token, call_timeout) - events = output['events'] - token = output['token'] - print("%s %10d 0" % (now_string, len(events))) - time.sleep(5) - - except KeyboardInterrupt: - break - - except XenAPI.Failure as e: - print(e.details) - sys.exit(1) - - -if __name__ == "__main__": - if len(sys.argv) != 4: - print("Usage:") - print(sys.argv[0], " ") - sys.exit(1) - - url = sys.argv[1] - if url[:5] != "https": - raise Exception("Must use SSL for a realistic test") - - username = sys.argv[2] - password = sys.argv[3] - - new_session = XenAPI.Session(url) - try: - new_session.xenapi.login_with_password(username, password, "1.0", "xen-api-scripts-eventcount.py") - except XenAPI.Failure as f: - print("Failed to acquire a session: %s" % f.details) - sys.exit(1) - - try: - main(new_session) - finally: - new_session.xenapi.logout() diff --git a/scripts/scalability-tests/ping-master.py b/scripts/scalability-tests/ping-master.py deleted file mode 100755 index 048c5d4c938..00000000000 --- a/scripts/scalability-tests/ping-master.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python - -# Send back-to-back 'Host.get_servertime' calls to simulate the GUI's heartbeat and record latency. - -from __future__ import print_function -import XenAPI, sys, time - -iso8601 = "%Y%m%dT%H:%M:%SZ" - -def main(session): - global iso8601 - pool = session.xenapi.pool.get_all()[0] - host = session.xenapi.pool.get_master(pool) - while True: - start = time.time() - session.xenapi.host.get_servertime(host) - latency = time.time() - start - date = time.strftime(iso8601, time.gmtime(start)) - print("%s %.2f" % (date, latency)) - sys.stdout.flush() - time.sleep(5) - - -if __name__ == "__main__": - if len(sys.argv) != 4: - print("Usage:") - print(sys.argv[0], " ") - sys.exit(1) - url = sys.argv[1] - if url[:5] != "https": - raise "Must use SSL for a realistic test" - - username = sys.argv[2] - password = sys.argv[3] - - session = XenAPI.Session(url) - session.xenapi.login_with_password(username, password, "1.0", "xen-api-scripts-pingmaster.py") - try: - main(session) - finally: - session.xenapi.logout() - diff --git a/scripts/scalability-tests/plot-result b/scripts/scalability-tests/plot-result deleted file mode 100755 index 830590c306b..00000000000 --- a/scripts/scalability-tests/plot-result +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# -# Copyright (c) Citrix Systems 2008. All rights reserved. -# -# ./plot-result vm_per_host host1 ... hostN -# - -if [ $# -le 1 ]; then - echo "Usage: $0 vm_per_host host1 [host2 ... hostN]" - echo "${0} plot the result of ./stress-tests. Need to have all the resulting .dat files of the test in the current directory. Results are .ps files." - exit 1 -fi - -VM_PER_HOST=$1 - -shift -HOSTS=$@ -MASTER=$1 - -for OP in "start-shutdown" "suspend-resume" "reboot" "live-migrate" "non-live-migrate"; do - STR="" - for HOST in $HOSTS; do - for i in `seq 1 ${VM_PER_HOST}`; do - if [ "${STR}" == "" ] - then - STR="'debian-etch-${HOST}-${i}.${OP}.dat' title '${HOST}-${i}' with lines" - else - STR+=", 'debian-etch-${HOST}-${i}.${OP}.dat' title '${HOST}-${i}' with lines" - fi - done - done - echo "set terminal postscript color eps" > tmp.conf - echo "set output '${OP}.ps'" >> tmp.conf - echo "plot ${STR}" >> tmp.conf - gnuplot tmp.conf -done - - diff --git a/scripts/scalability-tests/pool-size-tests b/scripts/scalability-tests/pool-size-tests deleted file mode 100755 index b3ea46eb9c7..00000000000 --- a/scripts/scalability-tests/pool-size-tests +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# -# Copyright (c) Citrix Systems 2008. All rights reserved. -# -# ./test-pool-size n -# -# Host1 will become the master of the pool, with host2 ... hostN as slaves. -# Then, on each host, vm_per_host VMs are created, with names debian-etch-HOST_NAME-i (for i in 1..vm_per_host) - -if [ $# -ne 1 ]; then - echo "Usage: $0 number_of_vm" - echo "Need :" - echo " * ./repeat, ./repeat-clone, ./repeat-start and ./repeat-destroy scripts to be in the same directory that ${0};" - echo " * a pool already set up with a shared NFS storage and a HVM VM called dsl;" - echo " * ${0} must be started on the master of this pool;" - echo "${0} clones , then starts them all, then shutdown them all, then destroy them all. Then it ejects one host of the pool, and do the same tests again until the master remains the last host in the pool. Each operation is recoreded into a .dat file." - exit 1 -fi - -N=${1} -IFS=:',' -HOSTS=`xe host-list --minimal` -MASTER=`xe pool-list params=master --minimal` - -c=`xe host-list --minimal | sed -e 's/,/\n/g' | wc -l` - - -#main loop -for HOST in $HOSTS; -do - if [ ${HOST} != ${MASTER} ]; then - ./repeat-clone ${N} dsl > clone-${c}.dat - ./repeat-start ${N} dsl > start-${c}.dat - ./repeat ${N} shutdown dsl --force > shutdown-${c}.dat - ./repeat-destroy ${N} dsl > destroy-${c}.dat - - echo "Ejecting ${HOST}." - xe pool-eject host-uuid=${HOST} --force - #xe host-forget uuid=${HOST} - ((c--)) - echo "Ejected." - fi -done diff --git a/scripts/scalability-tests/provision-vm b/scripts/scalability-tests/provision-vm deleted file mode 100755 index 03fa99663e3..00000000000 --- a/scripts/scalability-tests/provision-vm +++ /dev/null @@ -1,153 +0,0 @@ -#!/bin/bash -# -# Copyright (c) Citrix Systems 2008. All rights reserved. -# -# ./provision-vm vm_per_host host1 host2 ... hostN -# -# Host1 will become the master of the pool, with host2 ... hostN as slaves. -# Then, on each host, vm_per_host VMs are created, with names debian-etch-HOST_NAME-i (for i in 1..vm_per_host) - -if [ $# -le 1 ]; then - echo "Usage: ${0} vm_per_host host1 [host2 ... hostN]" - echo "${0} provisions debiant-etch VMs on each host and installs them on a local VHD disk. Moreover, all the hosts join a common pool." - echo "if PROVISION_VM_WITH_CD is set to 1, then attach guest tools ISO CD-ROM to the initial Debian Etch VM before cloning it." - exit 1 -fi - -VM_PER_HOST=$1 - -shift -HOSTS=$@ -MASTER=$1 - -if [ "${PROVISION_VM_WITH_CD}" == "1" ]; then - DEB="debian-etch-withCD" -else - DEB="debian-etch" -fi - -install-vhd () { - HOST=$1 - XE="xe -u root -pw xenroot -s ${HOST}" - SR=`${XE} sr-list name-label='Local storage' --minimal` - if [ $SR ] - then - -# forget the local storage - echo "[${HOST}] Forgeting local storage." - PBD=`${XE} sr-list uuid=$SR params=PBDs --minimal` - ${XE} pbd-unplug uuid=${PBD} - ${XE} sr-forget uuid=${SR} - echo "[${HOST}] Forgotten." - -# build a local VHD storage - echo "[${HOST}] Creating a local VHD storage." - SR=`${XE} sr-create type=ext name-label=localvhd device-config:device=/dev/sda3` - ${XE} pool-param-set uuid=$(${XE} pool-list params=uuid --minimal) default-SR=${SR} crash-dump-SR=${SR} suspend-image-SR=${SR} - echo "[${HOST}] Created." - - fi -} - -install () { - HOST=$1 - XE="xe -u root -pw xenroot -s ${HOST}" - - echo "[${HOST}] Installing the Debian Etch VM." - UUID=`${XE} vm-install new-name-label=${DEB} template="Debian Etch 4.0"` - echo "[${HOST}] Installed." - - echo "[${HOST}] Setting the IP address and the memory size of the VM." - NETWORK=`${XE} network-list bridge=xenbr0 --minimal` - VIF=`${XE} vif-create vm-uuid=${UUID} network-uuid=${NETWORK} device=0` - ${XE} vm-param-set uuid=${UUID} PV-args="noninteractive" - ${XE} vm-param-set uuid=${UUID} memory-static-max="50MiB" - ${XE} vm-param-set uuid=${UUID} memory-static-min="50MiB" - ${XE} vm-param-set uuid=${UUID} memory-dynamic-max="50MiB" - ${XE} vm-param-set uuid=${UUID} memory-dynamic-min="50MiB" - echo "[${HOST}] Set." - - if [ "${PROVISION_VM_WITH_CD}" == "1" ]; then - echo "[${HOST}] Attaching a CD-ROM." - TOOLS_ISO=`${XE} vdi-list is-tools-iso=ture params=name-label --minimal` - ${XE} vm-cd-add vm=${DEB} cd-name=${TOOLS_ISO} device=3 - echo "[${HOST}] Attached." - fi - -} - -#start () { -# HOST=$1 -# XE="xe -u root -pw xenroot -s ${HOST}" -# -# echo "[${HOST}] Starting VM." -# ${XE} vm-start vm="${DEB}" -# UUID=`${XE} vm-list name-label=${DEB} params=uuid --minimal` -# -# echo "[${HOST}] Waiting for the IP address of the VM to appear. This can take a minute or so." -# RC=1 -# while [ ${RC} -ne 0 ] -# do -# sleep 10 -# IP=`${XE} vm-param-get uuid=${UUID} param-name=networks param-key="0/ip"` -# RC=$? -# done -# -# echo "[${HOST}] Debian Etch VM installed (IP=${IP})." -#} - -#shutdown () { -# HOST=$1 -# XE="xe -u root -pw xenroot -s ${HOST}" -# -# echo "[${HOST}] Shutting down the VM." -# ${XE} vm-shutdown vm=${DEB} -# echo "[${HOST}] Shut down." -#} - -clone () { - HOST=$1 - XE="xe -u root -pw xenroot -s ${HOST}" - - echo "# vm_number cumulative_time load_average vhd_size" > clone-${DEB}-${HOST}.dat - SR=`${XE} sr-list --minimal name-label=localvhd` - START=$(date +%s) - - for i in `seq 1 ${VM_PER_HOST}`; do - echo "[${HOST}] Cloning VM ${i}/${VM_PER_HOST}." - TMP=`${XE} vm-clone vm=${DEB} new-name-label=${DEB}-${HOST}-${i}` - CURR=$(date +%s) - DIFF=$(( ${CURR} - ${START} )) - LOADAVG=`${XE} host-data-source-query data-source=loadavg host=${HOST}` - VHDSIZE=`${XE} vdi-list --minimal sr-uuid=${SR} | sed -e 's/,/\n/g' | wc -l` - echo "${i} ${DIFF} ${LOADAVG} ${VHDSIZE}" >> clone-${DEB}-${HOST}.dat - echo "[${HOST}] Done." - done -} - -uninstall () { - HOST=$1 - XE="xe -u root -pw xenroot -s ${HOST}" - - echo "[{$HOST}] Uninstalling the Debian Etch initial VM." - ${XE} vm-uninstall force=true vm=${DEB} - echo "[${HOST}] Uninstalled." -} - -join-master () { - HOST=$1 - if [ ${HOST} != ${MASTER} ] - then - XE="xe -u root -pw xenroot -s ${HOST}" - echo "[${HOST}] Joining ${MASTER} pool." - ${XE} pool-join master-address=${MASTER} master-username=root master-password=xenroot; - echo "[${HOST}] Joined." - fi -} - -#main loop -echo "Provisioning ${VM_PER_HOST} VMs on hosts: ${HOSTS} (master is ${MASTER})." -for HOST in $HOSTS; -do - (install-vhd $HOST; install $HOST; clone $HOST; uninstall $HOST; join-master $HOST) & -done diff --git a/scripts/scalability-tests/repeat b/scripts/scalability-tests/repeat deleted file mode 100755 index c2990a2d171..00000000000 --- a/scripts/scalability-tests/repeat +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# -# Copyright (c) Citrix Systems 2008. All rights reserved. -# -# ./repeat n operation vm_name optional_args -# - -if [ $# -le 2 ]; then - echo "usage: $0 n operation vm_name [optional arguments]" - exit 1 -fi -N=$1 -OP=$2 -VM=$3 -EXTRA=$4 - -MASTER=`xe pool-list params=master --minimal` -START=$(date +%s) - -echo "# vm_number cumulative_time load_average" - -perform () { - i=$1 - TMP=`xe vm-${OP} ${EXTRA} vm=${VM}${i}` - CURR=$(date +%s) - DIFF=$(( ${CURR} - ${START} )) - LOADAVG=`xe host-data-source-query data-source=loadavg host=${MASTER}` - echo "${i} ${DIFF} ${LOADAVG}"; -} - -for i in `seq 1 ${N}`; do - perform $i -done diff --git a/scripts/scalability-tests/repeat-clone b/scripts/scalability-tests/repeat-clone deleted file mode 100755 index f293465b605..00000000000 --- a/scripts/scalability-tests/repeat-clone +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# -# Copyright (c) Citrix Systems 2008. All rights reserved. -# -# ./repeat-clone n vm_name -# - -if [ $# -ne 2 ]; then - echo "usage: $0 n vm_name" - exit 1 -fi -N=$1 -VM=$2 - -SR=`xe sr-list --minimal name-label='NFS virtual disk storage'` -MASTER=`xe pool-list params=master --minimal` -START=$(date +%s) - -echo "# vm_number cumulative_time load_average vhd_size" - -perform () { - i=$1 - TMP=`xe vm-clone vm=${VM} new-name-label=${VM}${i}` - CURR=$(date +%s) - DIFF=$(( ${CURR} - ${START} )) - LOADAVG=`xe host-data-source-query data-source=loadavg host=${MASTER}` - VHDSIZE=` xe vdi-list --minimal sr-uuid=${SR} | sed -e 's/,/\n/g' | wc -l` - echo "${i} ${DIFF} ${LOADAVG} ${VHDSIZE}" -} - -for i in `seq 1 ${N}`; do - perform $i -done diff --git a/scripts/scalability-tests/repeat-destroy b/scripts/scalability-tests/repeat-destroy deleted file mode 100755 index b8031e781e4..00000000000 --- a/scripts/scalability-tests/repeat-destroy +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# -# Copyright (c) Citrix Systems 2008. All rights reserved. -# -# ./repeat n operation vm_name optional_args -# - -if [ $# -ne 2 ]; then - echo "usage: $0 n vm_name" - exit 1 -fi -N=$1 -VM=$2 - -MASTER=`xe pool-list params=master --minimal` -START=$(date +%s) - -echo "# vm_number cumulative_time load_average" -perform () { - i=$1 - VM_UUID=`xe vm-list name-label=${VM}${i} params=uuid --minimal` - if [ "${VM_UUID}" != "" ]; then - TMP=`xe vm-destroy uuid=${VM_UUID}` - fi - CURR=$(date +%s); - DIFF=$(( ${CURR} - ${START} )); - LOADAVG=`xe host-data-source-query data-source=loadavg host=${MASTER}` - echo "${i} ${DIFF} ${LOADAVG}"; -} - -for i in `seq 1 ${N}`; do - perform $i; -done diff --git a/scripts/scalability-tests/repeat-start b/scripts/scalability-tests/repeat-start deleted file mode 100755 index a439b7ac8b9..00000000000 --- a/scripts/scalability-tests/repeat-start +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# -# Copyright (c) Citrix Systems 2008. All rights reserved. -# -# ./repeat n operation vm_name optional_args -# - -if [ $# -ne 2 ]; then - echo "Usage: $0 n vm_name" - echo "Starts VMs nammed vm_name<1> .. vm_name and output the time taken and the load average." - echo "if WAIT_FOR_IP is set to 1, then wait the IP address to appear before starting the next VM. need xgetip executable to be in the current directory." - exit 1 -fi - -N=$1 -VM_NAME=$2 - -MASTER=`xe pool-list params=master --minimal` -START=$(date +%s) - -wait_IP () { - i=$1 - VM_UUID=`xe vm-list name-label=${VM_NAME}${i} params=uuid --minimal` - MAC=`xe vif-list vm-uuid=${VM_UUID} params=MAC --minimal` - echo "Waiting for the IP address of ${VM_NAME}${i} to appear." - IP=`./xgetip xenbr0 ${MAC} &> /dev/null` - echo "IP address of ${VM_NAME}${i} is ${IP}." -} - -echo "# vm_number cumulative_time load_average" - -perform () { - i=$1 - TMP=`xe vm-start vm=${VM_NAME}${i}` - if [ "${WAIT_FOR_IP}" == "1" ]; then - wait_IP ${i} - fi - CURR=$(date +%s) - DIFF=$(( ${CURR} - ${START} )) - LOADAVG=`xe host-data-source-query data-source=loadavg host=${MASTER}` - echo "${i} ${DIFF} ${LOADAVG}" -} - -for i in `seq 1 ${N}`; do - perform $i -done diff --git a/scripts/scalability-tests/start-tests b/scripts/scalability-tests/start-tests deleted file mode 100755 index 06fc671f135..00000000000 --- a/scripts/scalability-tests/start-tests +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -# -# Copyright (c) Citrix Systems 2008. All rights reserved. -# -# ./test-pool-size n vm_name -# -# Host1 will become the master of the pool, with host2 ... hostN as slaves. -# Then, on each host, vm_per_host VMs are created, with names debian-etch-HOST_NAME-i (for i in 1..vm_per_host) - -if [ $# -ne 2 ]; then - echo "Usage: $0 number_of_vm initial_vm_name" - echo "Need :" - echo " * ./repeat, ./repeat-clone, ./repeat-start and ./repeat-destroy scripts to be in the same directory that ${0};" - echo " * a pool already set up with a shared NFS storage and a HVM VM called dsl;" - echo " * ${0} must be started on the master of this pool;" - echo "${0} clones , then starts them all, then shutdown them all, then destroy them all." - echo "If WAIT_FOR_IP is set to 1, the script waits for the IP address of the VM to appear before starting the next VM." - exit 1 -fi - -N=${1} -VM=${2} - -./repeat-clone ${N} ${VM} > clone-${VM}.dat -./repeat-start ${N} ${VM} > start-${VM}.dat -./repeat ${N} shutdown ${VM} --force > shutdown-${VM}.dat -./repeat-destroy ${N} ${VM} > destroy-${VM}.dat \ No newline at end of file diff --git a/scripts/scalability-tests/stress-tests b/scripts/scalability-tests/stress-tests deleted file mode 100755 index e193728c9e7..00000000000 --- a/scripts/scalability-tests/stress-tests +++ /dev/null @@ -1,121 +0,0 @@ -#!/bin/bash -# -# Copyright (c) Citrix Systems 2008. All rights reserved. -# -# ./stress-tests number_of_tests vm_per_host master slave1 slave2 ... slaveN -# - -if [ $# -le 2 ]; then - echo "Usage: $0 number_of_tests vm_per_host master [slave1 ... slaveN]" - echo "You need debian-etch--<1..vm_per_host> VMs installed in each host of the pool (use ./provision-vm to set them up)." - echo "${0} is a XenRT-like script. It performs: " - echo " for each VM, do sequentialy:" - echo " start/wait IP/shutdown" - echo " suspend/resume" - echo " reboot" - echo " live migrate" - echo " non-live migrate" - exit 1 -fi - -N=$1 -VM_PER_HOST=$2 - -shift -shift -HOSTS=$@ -MASTER=$1 - -XE="xe -u root -pw xenroot -s ${MASTER}" - -wait_IP () { - VM=$1 - UUID=`${XE} vm-list name-label=${VM} params=uuid --minimal` - RC=1 - while [ ${RC} -ne 0 ] - do - sleep 2 - IP=`${XE} vm-param-get uuid=${UUID} param-name=networks param-key="0/ip" &> /dev/null` - RC=$? - done -} - -start () { - VM=$1 - - ${XE} vm-start vm=${VM} - wait_IP ${VM} -} - -perform () { - OP=$1 - VM=$2 - EXTRA=$3 - - ${XE} vm-${OP} vm=${VM} $EXTRA -} - -tests () { - HOST=$1 - VM=$2 - - echo "[${VM}] start/stop tests." - START=$(date +%s) - for i in `seq 1 ${N}`; do - start ${VM}; - perform shutdown ${VM}; - CURR=$(date +%s); - DIFF=$(( ${CURR} - ${START} )); - echo "${i} ${DIFF}" >> ${VM}.start-shutdown.dat - done - - echo "[${VM}] suspend/resume tests." - start ${VM} - START=$(date +%s) - for i in `seq 1 ${N}`; do - perform suspend ${VM} - perform resume ${VM} - CURR=$(date +%s); - DIFF=$(( ${CURR} - ${START} )); - echo "${i} ${DIFF}" >> ${VM}.suspend-resume.dat - done - - echo "[${VM}] reboot tests." - START=$(date +%s) - for i in `seq 1 ${N}`; do - perform reboot ${VM} - CURR=$(date +%s); - DIFF=$(( ${CURR} - ${START} )); - echo "${i} ${DIFF}" >> ${VM}.reboot.dat - done - - wait_IP ${VM} - - echo "[${VM}] live migrate tests." - START=$(date +%s) - for i in `seq 1 ${N}`; do - perform migrate ${VM} "live=true host=${HOST}" - CURR=$(date +%s); - DIFF=$(( ${CURR} - ${START} )); - echo "${i} ${DIFF}" >> ${VM}.live-migrate.dat - done - - echo "[${VM}] non-live migrate tests." - START=$(date +%s) - for i in `seq 1 ${N}`; do - perform migrate ${VM} "live=false host=${HOST}" - CURR=$(date +%s); - DIFF=$(( ${CURR} - ${START} )); - echo "${i} ${DIFF}" >> ${VM}.non-live-migrate.dat - done - - perform shutdown ${VM} -} - -for HOST in ${HOSTS}; do - for i in `seq 1 ${VM_PER_HOST}`; do - VM="debian-etch-${HOST}-$i" - echo "Starting tests on ${VM}." - tests ${HOST} ${VM} & - done -done diff --git a/scripts/time-vm-boots.py b/scripts/time-vm-boots.py deleted file mode 100755 index 85ec19f20f8..00000000000 --- a/scripts/time-vm-boots.py +++ /dev/null @@ -1,168 +0,0 @@ -#!/usr/bin/env python - -# Copyright (c) 2006-2007 XenSource, Inc. -# -# Permission to use, copy, modify, and distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - - -# Simple python example to demonstrate the event system. Logs into the server, -# registers for events on the VM_guest_metrics and computes the time taken for -# the guest agent to report an IP address. - -from __future__ import print_function -import XenAPI -import sys -import time - -vgm_to_vm = {} - - -def register_vm_metrics(session, vm_ref, vgm): - global vgm_to_vm - - try: - # avoid putting invalid references in the cache - tmp = session.xenapi.VM_guest_metrics.get_other(vgm) - vgm_to_vm[vgm] = vm_ref - except: - pass - - -def vm_of_metrics(ref): - global vgm_to_vm - if not(ref in vgm_to_vm.keys()): - return None - return vgm_to_vm[ref] - -interesting_vms = [] -vm_boot_times = {} -boots_seen = 0 - - -def dump_table(session): - global vm_boot_times - for vm_ref in vm_boot_times.keys(): - name = session.xenapi.VM.get_name_label(vm_ref) - print("%s %s" % (name, vm_boot_times[vm_ref])) - - -def seen_possible_boot(session, vm_ref): - global vm_boot_times - global interesting_vms - global boots_seen - if not(vm_ref in vm_boot_times.keys()) and vm_ref in interesting_vms: - t = time.strftime( "%Y%m%dT%H:%M:%SZ", time.gmtime()) - vm_boot_times[vm_ref] = t - boots_seen += 1 - - name = session.xenapi.VM.get_name_label(vm) - print("%d %s %s" % (boots_seen, name, t), file=sys.stdout) - print("%d %s %s" % (boots_seen, name, t), file=sys.stderr) - sys.stderr.flush() - - -def process_guest_metrics(session, ref, snapshot): - if "other" in snapshot.keys(): - other = snapshot["other"] - if "feature-shutdown" in other.keys(): - the_vm = vm_of_metrics(ref) - seen_possible_boot(session, the_vm) - - -def poll_metrics(session): - while True: - time.sleep(10) - all_recs = session.xenapi.VM_guest_metrics.get_all_records() - for ref in all_recs.keys(): - snapshot = all_recs[ref] - process_guest_metrics(session, ref, snapshot) - - -def process_metrics_event(session, ref): - vm_ref = vm_of_metrics(ref) - if vm_ref is None: - return - if session.xenapi.VM.get_power_state(vm_ref) != "Running": - return - other = {} - try: - other=session.xenapi.VM_guest_metrics.get_other(ref) - except Exception as e: - print(repr(e)) - - if "feature-shutdown" in other.keys(): - seen_possible_boot(session, vm_ref) - - -def watch_events_on_vm(session): - try: - token = '' - call_timeout = 30.0 - while True: - output = session.xenapi.event_from(["VM", "VM_guest_metrics"], token, call_timeout) - events = output['events'] - token = output['token'] - - for event in events: - if event['operation'] == 'del': - continue - if event['class'] == 'vm' and event['operation'] == 'mod': - register_vm_metrics(session, event['ref'], event['snapshot']['guest_metrics']) - continue - if event['class'] == 'vm_guest_metrics': - process_metrics_event(session, event['ref']) - continue - - except XenAPI.Failure as e: - print(e.details) - sys.exit(1) - finally: - session.xenapi.session.logout() - - -if __name__ == "__main__": - if len(sys.argv) > 4 or len(sys.argv) < 2: - print(""" -Watches all offline VMs for boots -Usage: - %s -or - %s [http://]localhost [] [] -""" % (sys.argv[0], sys.argv[0])) - sys.exit(1) - - url = sys.argv[1] - username = sys.argv[2] if len(sys.argv) > 2 else "" - password = sys.argv[3] if len(sys.argv) > 3 else "" - - if url == "http://localhost" or url == "localhost": - new_session = XenAPI.xapi_local() - else: - new_session = XenAPI.Session(url) - - # First acquire a valid session by logging in - try: - new_session.xenapi.login_with_password(username, password, "1.0", "xen-api-scripts-timevmboots.py") - except XenAPI.Failure as f: - print("Failed to acquire a session: %s" % f.details) - sys.exit(1) - - # We start watching all Halted VMs - all_halted_vms = new_session.xenapi.VM.get_all_records() - for vm in all_halted_vms.keys(): - vm_rec = all_halted_vms[vm] - if vm_rec["power_state"] == "Halted" and not vm_rec["is_a_template"]: - interesting_vms.append(vm) - print("Watching %d offline VMs" % (len(interesting_vms)), file=sys.stderr) - - watch_events_on_vm(new_session)