Exemplo n.º 1
0
def createVmResource(image):
    disk = Disk()
    disk.flavor = "some-disk-flavor"
    disk.id = str(uuid.uuid1())
    disk.persistent = False
    disk.new_disk = True
    disk.capacity_gb = 0
    disk.image = DiskImage()
    disk.image.id = image
    disk.image.clone_type = CloneType.COPY_ON_WRITE
    disk.flavor_info = Flavor()
    disk.flavor_info.name = "some-disk-flavor"
    disk.flavor_info.cost = []

    vm = Vm()
    vm.id = str(uuid.uuid1())
    vm.flavor = "some-vm-flavor"
    vm.state = State.STOPPED
    vm.flavor_info = Flavor()
    vm.flavor_info.name = "some-vm-flavor"
    vm.flavor_info.cost = [
        QuotaLineItem("vm.cpu", "1", QuotaUnit.COUNT),
        QuotaLineItem("vm.memory", "0.5", QuotaUnit.GB)]
    vm.disks = [disk]

    return vm
Exemplo n.º 2
0
def createVmResource(image):
    disk = Disk()
    disk.flavor = "some-disk-flavor"
    disk.id = str(uuid.uuid4())
    disk.persistent = False
    disk.new_disk = True
    disk.capacity_gb = 0
    disk.image = DiskImage()
    disk.image.id = image
    disk.image.clone_type = CloneType.COPY_ON_WRITE
    disk.flavor_info = Flavor()
    disk.flavor_info.name = "some-disk-flavor"
    disk.flavor_info.cost = []

    vm = Vm()
    vm.id = str(uuid.uuid4())
    vm.flavor = "some-vm-flavor"
    vm.state = State.STOPPED
    vm.flavor_info = Flavor()
    vm.flavor_info.name = "some-vm-flavor"
    vm.flavor_info.cost = [
        QuotaLineItem("vm.cpu", "1", QuotaUnit.COUNT),
        QuotaLineItem("vm.memory", "0.5", QuotaUnit.GB)
    ]
    vm.disks = [disk]

    return vm
Exemplo n.º 3
0
def createVmResource(image, network):
    disk = Disk()
    disk.flavor = "some-disk-flavor"
    disk.id = str(uuid.uuid4())
    disk.persistent = False
    disk.new_disk = True
    disk.capacity_gb = 0
    disk.image = DiskImage()
    disk.image.id = image
    disk.image.clone_type = CloneType.COPY_ON_WRITE
    disk.flavor_info = Flavor()
    disk.flavor_info.name = "some-disk-flavor"
    disk.flavor_info.cost = []

    vm = Vm()
    vm.id = str(uuid.uuid4())
    vm.flavor = "some-vm-flavor"
    vm.state = VmPowerState.STOPPED
    vm.flavor_info = Flavor()
    vm.flavor_info.name = "some-vm-flavor"
    vm.flavor_info.cost = [
        QuotaLineItem("vm.cpu", "1", QuotaUnit.COUNT),
        QuotaLineItem("vm.memory", "0.5", QuotaUnit.GB),
    ]
    vm.disks = [disk]
    if network:
        vm.resource_constraints = [ResourceConstraint(ResourceConstraintType.NETWORK, [network])]

    return vm
Exemplo n.º 4
0
def createDisksResource():
    disk = Disk()
    disk.flavor = "some-disk-flavor"
    disk.id = str(uuid.uuid1())
    disk.persistent = True
    disk.new_disk = True
    disk.capacity_gb = 2
    return [disk]
Exemplo n.º 5
0
def createDisksResource():
    disk = Disk()
    disk.flavor = "some-disk-flavor"
    disk.id = str(uuid.uuid1())
    disk.persistent = True
    disk.new_disk = True
    disk.capacity_gb = 2
    return [disk]
Exemplo n.º 6
0
def createDisksResource():
    disk = Disk()
    disk.flavor = "some-disk-flavor"
    disk.id = str(uuid.uuid4())
    disk.persistent = True
    disk.new_disk = True
    disk.capacity_gb = 2
    disk.flavor_info = Flavor()
    disk.flavor_info.name = "some-disk-flavor"
    disk.flavor_info.cost = []
    return [disk]
Exemplo n.º 7
0
def createDisksResource():
    disk = Disk()
    disk.flavor = "some-disk-flavor"
    disk.id = str(uuid.uuid4())
    disk.persistent = True
    disk.new_disk = True
    disk.capacity_gb = 2
    disk.flavor_info = Flavor()
    disk.flavor_info.name = "some-disk-flavor"
    disk.flavor_info.cost = []
    return [disk]
Exemplo n.º 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))
Exemplo n.º 9
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))