示例#1
0
    def __init__(self, file):
        self.file = Universe.get_path(file)
        content = open(self.file, 'r').read()
        config = yaml.load(content)
        self.num_hosts = config["num_hosts"]
        self.root_branchout = config["root_branchout"]
        self.sched_branchout = config["sched_branchout"]
        self.host_config = config["host_config"]
        self.id = 1

        self.tree_config = \
            {
                "overcommit": config["overcommit"],
                "root_config": config["root_config"],
                "schedulers": []
            }
示例#2
0
    def __init__(self, file):
        self.file = Universe.get_path(file)
        content = open(self.file, 'r').read()
        config = yaml.load(content)
        self.num_hosts = config["num_hosts"]
        self.root_branchout = config["root_branchout"]
        self.sched_branchout = config["sched_branchout"]
        self.host_config = config["host_config"]
        self.id = 1

        self.tree_config = \
            {
                "overcommit": config["overcommit"],
                "root_config": config["root_config"],
                "schedulers": []
            }
示例#3
0
 def __init__(self, requests_file, max_create_interval=1):
     self.requests_file = Universe.get_path(requests_file)
     self._logger = logging.getLogger(__name__)
     self.reserve_count = 1
     self.max_create_interval = max_create_interval
示例#4
0
 def __init__(self, requests_file, max_create_interval=1):
     self.requests_file = Universe.get_path(requests_file)
     self._logger = logging.getLogger(__name__)
     self.reserve_count = 1
     self.max_create_interval = max_create_interval
示例#5
0
    def __init__(self, requests_file):
        self.requests = []
        content = open(Universe.get_path(requests_file), 'r').read()
        requests = yaml.load(content)

        request_id = 1
        disk_id = 1
        if 'auto' in requests:
            requests = self.generate_requests(requests['auto'])

        for request in requests:
            place_request = PlaceRequest()
            resource = Resource()
            resource.disks = []
            env_info = {}

            if 'vm' in request:
                resource.vm = Vm()
                # Make the vm id look like a uuid by zero-padding. Otherwise
                # reference counting doesn't work.
                resource.vm.id = "{0:032d}".format(request_id)
                resource.vm.state = State.STARTED
                flavor = Universe.vm_flavors[request['vm']['flavor']]
                resource.vm.flavor = flavor.name
                resource.vm.flavor_info = flavor.to_thrift()
                resource.vm.disks = []
                if 'constraints' in request:
                    constraints = []
                    for c in request['constraints']:
                        constraint = ResourceConstraint()
                        constraint.type = RCT._NAMES_TO_VALUES[c['type']]
                        constraint.values = c['values']
                        if 'negative' in c:
                            constraint.negative = c['negative']
                        else:
                            constraint.negative = False
                        constraints.append(constraint)
                    if constraints:
                        resource.vm.resource_constraints = constraints
                if 'load' in request['vm']:
                    env_info['mem_load'] = request['vm']['load']['mem']

            if 'disks' in request:
                for d in request['disks']:
                    disk = Disk()
                    flavor = Universe.ephemeral_disk_flavors[d['flavor']]
                    disk.flavor = flavor.name
                    disk.flavor_info = flavor.to_thrift()
                    disk.id = str(disk_id)
                    disk.persistent = False
                    disk.new_disk = True
                    disk.capacity_gb = 1024  # hard coded in FakeVmManager
                    disk_id += 1
                    resource.vm.disks.append(disk)

            place_request.resource = resource
            tracing_info = TracingInfo()
            tracing_info.request_id = request_id
            place_request.tracing_info = tracing_info
            request_id += 1
            self.requests.append(PsimVmRequest(place_request, env_info))
 def __init__(self, result_file):
     self.result_file = Universe.get_path(result_file)
     content = open(self.result_file, 'r').read()
     self.expected = yaml.load(content)
示例#7
0
 def __init__(self, result_file):
     self.result_file = Universe.get_path(result_file)
     content = open(self.result_file, 'r').read()
     self.expected = yaml.load(content)
示例#8
0
    def __init__(self, requests_file):
        self.requests = []
        content = open(Universe.get_path(requests_file), 'r').read()
        requests = yaml.load(content)

        request_id = 1
        disk_id = 1
        if 'auto' in requests:
            requests = self.generate_requests(requests['auto'])

        for request in requests:
            place_request = PlaceRequest()
            resource = Resource()
            resource.disks = []
            env_info = {}

            if 'vm' in request:
                resource.vm = Vm()
                # Make the vm id look like a uuid by zero-padding. Otherwise
                # reference counting doesn't work.
                resource.vm.id = "{0:032d}".format(request_id)
                resource.vm.state = State.STARTED
                flavor = Universe.vm_flavors[request['vm']['flavor']]
                resource.vm.flavor = flavor.name
                resource.vm.flavor_info = flavor.to_thrift()
                resource.vm.disks = []
                if 'constraints' in request:
                    constraints = []
                    for c in request['constraints']:
                        constraint = ResourceConstraint()
                        constraint.type = RCT._NAMES_TO_VALUES[c['type']]
                        constraint.values = c['values']
                        if 'negative' in c:
                            constraint.negative = c['negative']
                        else:
                            constraint.negative = False
                        constraints.append(constraint)
                    if constraints:
                        resource.vm.resource_constraints = constraints
                if 'load' in request['vm']:
                    env_info['mem_load'] = request['vm']['load']['mem']

            if 'disks' in request:
                for d in request['disks']:
                    disk = Disk()
                    flavor = Universe.ephemeral_disk_flavors[d['flavor']]
                    disk.flavor = flavor.name
                    disk.flavor_info = flavor.to_thrift()
                    disk.id = str(disk_id)
                    disk.persistent = False
                    disk.new_disk = True
                    disk.capacity_gb = 1024  # hard coded in FakeVmManager
                    disk_id += 1
                    resource.vm.disks.append(disk)

            place_request.resource = resource
            tracing_info = TracingInfo()
            tracing_info.request_id = request_id
            place_request.tracing_info = tracing_info
            request_id += 1
            self.requests.append(PsimVmRequest(place_request, env_info))
示例#9
0
 def __init__(self, file):
     self.file = Universe.get_path(file)
 def __init__(self, file):
     self.file = Universe.get_path(file)