Пример #1
0
    def list(self, project, location, service_account_file=""):
        stub = node_pb2_grpc.TPUNodeServiceStub(channel.Channel())
        request = node_pb2.ListTPUNodeRequest()
        request.service_account_file = service_account_file
        request.Project = project

        request.Location = location

        return stub.ListTPUNode(request).items
Пример #2
0
    def delete(self, project, location, name, service_account_file=""):
        stub = node_pb2_grpc.TPUNodeServiceStub(channel.Channel())
        request = node_pb2.DeleteTPUNodeRequest()
        request.service_account_file = service_account_file
        request.Project = project

        request.Location = location

        request.Name = name

        response = stub.DeleteTPUNode(request)
    def delete(self):
        stub = node_pb2_grpc.TPUNodeServiceStub(channel.Channel())
        request = node_pb2.DeleteTPUNodeRequest()
        request.service_account_file = self.service_account_file
        if Primitive.to_proto(self.name):
            request.resource.name = Primitive.to_proto(self.name)

        if Primitive.to_proto(self.description):
            request.resource.description = Primitive.to_proto(self.description)

        if Primitive.to_proto(self.accelerator_type):
            request.resource.accelerator_type = Primitive.to_proto(
                self.accelerator_type
            )

        if Primitive.to_proto(self.tensorflow_version):
            request.resource.tensorflow_version = Primitive.to_proto(
                self.tensorflow_version
            )

        if Primitive.to_proto(self.network):
            request.resource.network = Primitive.to_proto(self.network)

        if Primitive.to_proto(self.cidr_block):
            request.resource.cidr_block = Primitive.to_proto(self.cidr_block)

        if NodeSchedulingConfig.to_proto(self.scheduling_config):
            request.resource.scheduling_config.CopyFrom(
                NodeSchedulingConfig.to_proto(self.scheduling_config)
            )
        else:
            request.resource.ClearField("scheduling_config")
        if Primitive.to_proto(self.labels):
            request.resource.labels = Primitive.to_proto(self.labels)

        if Primitive.to_proto(self.use_service_networking):
            request.resource.use_service_networking = Primitive.to_proto(
                self.use_service_networking
            )

        if Primitive.to_proto(self.project):
            request.resource.project = Primitive.to_proto(self.project)

        if Primitive.to_proto(self.location):
            request.resource.location = Primitive.to_proto(self.location)

        response = stub.DeleteTPUNode(request)
Пример #4
0
    def apply(self):
        stub = node_pb2_grpc.TPUNodeServiceStub(channel.Channel())
        request = node_pb2.ApplyTPUNodeRequest()
        if Primitive.to_proto(self.name):
            request.resource.name = Primitive.to_proto(self.name)

        if Primitive.to_proto(self.description):
            request.resource.description = Primitive.to_proto(self.description)

        if Primitive.to_proto(self.accelerator_type):
            request.resource.accelerator_type = Primitive.to_proto(
                self.accelerator_type)

        if Primitive.to_proto(self.tensorflow_version):
            request.resource.tensorflow_version = Primitive.to_proto(
                self.tensorflow_version)

        if Primitive.to_proto(self.network):
            request.resource.network = Primitive.to_proto(self.network)

        if Primitive.to_proto(self.cidr_block):
            request.resource.cidr_block = Primitive.to_proto(self.cidr_block)

        if NodeSchedulingConfig.to_proto(self.scheduling_config):
            request.resource.scheduling_config.CopyFrom(
                NodeSchedulingConfig.to_proto(self.scheduling_config))
        else:
            request.resource.ClearField("scheduling_config")
        if Primitive.to_proto(self.labels):
            request.resource.labels = Primitive.to_proto(self.labels)

        if Primitive.to_proto(self.use_service_networking):
            request.resource.use_service_networking = Primitive.to_proto(
                self.use_service_networking)

        if Primitive.to_proto(self.project):
            request.resource.project = Primitive.to_proto(self.project)

        if Primitive.to_proto(self.location):
            request.resource.location = Primitive.to_proto(self.location)

        request.service_account_file = self.service_account_file

        response = stub.ApplyTPUNode(request)
        self.name = Primitive.from_proto(response.name)
        self.description = Primitive.from_proto(response.description)
        self.accelerator_type = Primitive.from_proto(response.accelerator_type)
        self.ip_address = Primitive.from_proto(response.ip_address)
        self.port = Primitive.from_proto(response.port)
        self.state = NodeStateEnum.from_proto(response.state)
        self.health_description = Primitive.from_proto(
            response.health_description)
        self.tensorflow_version = Primitive.from_proto(
            response.tensorflow_version)
        self.network = Primitive.from_proto(response.network)
        self.cidr_block = Primitive.from_proto(response.cidr_block)
        self.service_account = Primitive.from_proto(response.service_account)
        self.create_time = NodeCreateTime.from_proto(response.create_time)
        self.scheduling_config = NodeSchedulingConfig.from_proto(
            response.scheduling_config)
        self.network_endpoints = NodeNetworkEndpointsArray.from_proto(
            response.network_endpoints)
        self.health = NodeHealthEnum.from_proto(response.health)
        self.labels = Primitive.from_proto(response.labels)
        self.use_service_networking = Primitive.from_proto(
            response.use_service_networking)
        self.symptoms = NodeSymptomsArray.from_proto(response.symptoms)
        self.project = Primitive.from_proto(response.project)
        self.location = Primitive.from_proto(response.location)