예제 #1
0
    def to_thrift(self):
        disks = [disk.to_thrift() for disk in self.disks]

        resource_constraints = self.resource_constraints

        thrift_vm = ThriftVm(self.id, self.flavor.name, self.state,
                             None, self.environment, disks,
                             self.flavor.to_thrift(), resource_constraints,
                             self.tenant_id, self.project_id, self.location_id)

        if self.datastore:
            thrift_vm.datastore = ThriftDatastore(id=self.datastore,
                                                  name=self.datastore_name)

        return thrift_vm
예제 #2
0
    def to_thrift(self):
        disks = [disk.to_thrift() for disk in self.disks]

        resource_constraints = self.resource_constraints

        thrift_state = getattr(ThriftState, self.state.name)

        thrift_vm = ThriftVm(self.id, self.flavor.name, thrift_state,
                             None, self.environment, disks,
                             self.flavor.to_thrift(), resource_constraints)

        if self.datastore:
            thrift_vm.datastore = ThriftDatastore(id=self.datastore,
                                                  name=self.datastore_name)

        return thrift_vm
    def _sample_vm(self):
        flavor = Flavor(name="flavor", cost=[QuotaLineItem("a", "b", 1)])
        disks = [
            Disk(stable_uuid("%s-1" % id), flavor, False, False, 1, datastore=Datastore("ds1")),
            Disk(stable_uuid("%s-2" % id), flavor, False, False, 1, datastore=Datastore("ds2")),
        ]

        vm = Vm()
        vm.id = id
        vm.flavor = "flavor"
        vm.flavor_info = flavor
        vm.disks = disks
        vm.state = VmPowerState().STARTED
        vm.datastore = Datastore("ds1")

        return vm
    def create_resource(self, id):
        flavor = Flavor(name="flavor", cost=[QuotaLineItem("a", "b", 1)])
        disks = [
            Disk(stable_uuid("%s-1" % id), flavor, False, False, 1, datastore=Datastore("ds1")),
            Disk(stable_uuid("%s-2" % id), flavor, False, False, 1, datastore=Datastore("ds2")),
        ]

        vm = Vm()
        vm.id = id
        vm.flavor = "flavor"
        vm.flavor_info = flavor
        vm.state = State().STARTED
        vm.datastore = Datastore("ds1")

        resource = Resource(vm, disks)

        return resource
예제 #5
0
    def to_thrift(self):
        disks = [
            disk.to_thrift()
            for disk in self.disks
        ]

        resource_constraints = self.resource_constraints

        thrift_vm = ThriftVm(
            self.id, self.flavor.name,
            self.state, None, self.environment,
            disks, self.flavor.to_thrift(), resource_constraints,
            self.tenant_id, self.project_id, self.location_id
        )

        if self.datastore:
            thrift_vm.datastore = ThriftDatastore(id=self.datastore,
                                                  name=self.datastore_name)

        return thrift_vm
예제 #6
0
    def to_thrift(self):
        disks = [disk.to_thrift() for disk in self.disks]

        resource_constraints = self.resource_constraints

        thrift_state = getattr(ThriftState, self.state.name)

        thrift_vm = ThriftVm(
            self.id,
            self.flavor.name,
            thrift_state,
            None,
            self.environment,
            disks,
            self.flavor.to_thrift(),
            resource_constraints,
        )

        if self.datastore:
            thrift_vm.datastore = ThriftDatastore(id=self.datastore, name=self.datastore_name)

        return thrift_vm