Esempio n. 1
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,
            self.tenant_id,
            self.project_id,
        )

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

        return thrift_vm
Esempio n. 2
0
    def to_thrift(self):
        thrift_host_config = ThriftHostConfig(self.agent_id)
        thrift_host_config.datastores = [
            ThriftDatastore(ds) for ds in self.datastores
        ]
        if self.hypervisor:
            thrift_host_config.hypervisor = self.hypervisor
        if self.vm_network:
            thrift_host_config.vm_network = self.vm_network

        return thrift_host_config
Esempio n. 3
0
    def to_thrift(self):
        thrift_disk_image = None
        thrift_datastore = None
        thrift_constraints = None
        if self.image:
            thrift_disk_image = self.image.to_thrift()
        if self.datastore:
            thrift_datastore = ThriftDatastore(self.datastore)
        if self.constraints:
            thrift_constraints = self.to_thrift_constraints()

        return ThriftDisk(self.id, self.flavor.name, self.persistent,
                          self.new_disk, self.capacity_gb,
                          thrift_disk_image, thrift_datastore,
                          self.flavor.to_thrift(), thrift_constraints)