def to_thrift(self): thrift_host_config = ThriftHostConfig(self.agent_id, self.availability_zone) thrift_host_config.datastores = [ThriftDatastore(ds) for ds in self.datastores] if self.availability_zone: thrift_host_config.availability_zone = self.availability_zone 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
def to_thrift(self): thrift_host_config = ThriftHostConfig(self.agent_id, self.availability_zone) thrift_host_config.datastores = [ ThriftDatastore(ds) for ds in self.datastores ] if self.availability_zone: thrift_host_config.availability_zone = self.availability_zone 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
def get_register_host_request(self, port=8080): """ Generates a random register host request which has same datastore and same availability zone """ host_id = str(uuid.uuid4()) if not hasattr(self, "image_datastore"): self.image_datastore = str(uuid.uuid4()) datastores = [Datastore(self.image_datastore)] networks = [Network("nw1", [NetworkType.VM])] host_config = HostConfig(agent_id=host_id, datastores=datastores, address=ServerAddress("127.0.0.1", port=port), networks=networks) host_config.availability_zone = "foo" host_config.image_datastore_ids = set(self.image_datastore) return RegisterHostRequest(host_id, host_config)