Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

Commit 3a73b21

Browse files
feat: support custom scopes for service account (#92)
* feat: support custom scopes for service account in v1 --- feat: Add boot disk field in InstanceStatus --- feat: Add boot disk and image source fields to v1 InstancePolicy PiperOrigin-RevId: 507014714 Source-Link: googleapis/googleapis@12b32ef Source-Link: https://github.com/googleapis/googleapis-gen/commit/547061f90bc7e6706395ae372e0f61010bb4949e Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTQ3MDYxZjkwYmM3ZTY3MDYzOTVhZTM3MmUwZjYxMDEwYmI0OTQ5ZSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: support custom scopes for service account in v1 --- feat: Add boot disk field in InstanceStatus --- feat: Add boot disk and image source fields to v1 InstancePolicy PiperOrigin-RevId: 507014772 Source-Link: googleapis/googleapis@9d6497f Source-Link: https://github.com/googleapis/googleapis-gen/commit/13ef8a3b7efeb45866ebcea380dfd6a43ee5d486 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTNlZjhhM2I3ZWZlYjQ1ODY2ZWJjZWEzODBkZmQ2YTQzZWU1ZDQ4NiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 24de7ad commit 3a73b21

File tree

3 files changed

+104
-34
lines changed

3 files changed

+104
-34
lines changed

google/cloud/batch_v1/types/job.py

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ class InstanceStatus(proto.Message):
235235
task_pack (int):
236236
The max number of tasks can be assigned to
237237
this instance type.
238+
boot_disk (google.cloud.batch_v1.types.AllocationPolicy.Disk):
239+
The VM boot disk.
238240
"""
239241

240242
machine_type: str = proto.Field(
@@ -250,6 +252,11 @@ class InstanceStatus(proto.Message):
250252
proto.INT64,
251253
number=3,
252254
)
255+
boot_disk: "AllocationPolicy.Disk" = proto.Field(
256+
proto.MESSAGE,
257+
number=4,
258+
message="AllocationPolicy.Disk",
259+
)
253260

254261
class TaskGroupStatus(proto.Message):
255262
r"""Aggregated task status for a TaskGroup.
@@ -457,23 +464,38 @@ class Disk(proto.Message):
457464
458465
Attributes:
459466
image (str):
460-
Name of a public or custom image used as the
461-
data source.
467+
Name of a public or custom image used as the data source.
468+
For example, the following are all valid URLs: (1) Specify
469+
the image by its family name:
470+
projects/{project}/global/images/family/{image_family} (2)
471+
Specify the image version:
472+
projects/{project}/global/images/{image_version} You can
473+
also use Batch customized image in short names. The
474+
following image values are supported for a boot disk:
475+
"batch-debian": use Batch Debian images. "batch-centos": use
476+
Batch CentOS images. "batch-cos": use Batch
477+
Container-Optimized images.
462478
463479
This field is a member of `oneof`_ ``data_source``.
464480
snapshot (str):
465481
Name of a snapshot used as the data source.
466482
467483
This field is a member of `oneof`_ ``data_source``.
468484
type_ (str):
469-
Disk type as shown in ``gcloud compute disk-types list`` For
470-
example, "pd-ssd", "pd-standard", "pd-balanced",
471-
"local-ssd".
485+
Disk type as shown in ``gcloud compute disk-types list``.
486+
For example, local SSD uses type "local-ssd". Persistent
487+
disks and boot disks use "pd-balanced", "pd-extreme",
488+
"pd-ssd" or "pd-standard".
472489
size_gb (int):
473-
Disk size in GB. This field is ignored if ``data_source`` is
474-
``disk`` or ``image``. If ``type`` is ``local-ssd``, size_gb
475-
should be a multiple of 375GB, otherwise, the final size
476-
will be the next greater multiple of 375 GB.
490+
Disk size in GB. For persistent disk, this field is ignored
491+
if ``data_source`` is ``image`` or ``snapshot``. For local
492+
SSD, size_gb should be a multiple of 375GB, otherwise, the
493+
final size will be the next greater multiple of 375 GB. For
494+
boot disk, Batch will calculate the boot disk size based on
495+
source image and task requirements if you do not speicify
496+
the size. If both this field and the boot_disk_mib field in
497+
task spec's compute_resource are defined, Batch will only
498+
honor this field.
477499
disk_interface (str):
478500
Local SSDs are available through both "SCSI"
479501
and "NVMe" interfaces. If not indicated, "NVMe"
@@ -590,6 +612,10 @@ class InstancePolicy(proto.Message):
590612
accelerators (MutableSequence[google.cloud.batch_v1.types.AllocationPolicy.Accelerator]):
591613
The accelerators attached to each VM
592614
instance.
615+
boot_disk (google.cloud.batch_v1.types.AllocationPolicy.Disk):
616+
Book disk to be created and attached to each
617+
VM by this InstancePolicy. Boot disk will be
618+
deleted when the VM is deleted.
593619
disks (MutableSequence[google.cloud.batch_v1.types.AllocationPolicy.AttachedDisk]):
594620
Non-boot disks to be attached for each VM
595621
created by this InstancePolicy. New disks will
@@ -616,6 +642,11 @@ class InstancePolicy(proto.Message):
616642
number=5,
617643
message="AllocationPolicy.Accelerator",
618644
)
645+
boot_disk: "AllocationPolicy.Disk" = proto.Field(
646+
proto.MESSAGE,
647+
number=8,
648+
message="AllocationPolicy.Disk",
649+
)
619650
disks: MutableSequence["AllocationPolicy.AttachedDisk"] = proto.RepeatedField(
620651
proto.MESSAGE,
621652
number=6,
@@ -853,12 +884,21 @@ class ServiceAccount(proto.Message):
853884
account has to be specified in the instance
854885
template and it has to match the email field
855886
here.
887+
scopes (MutableSequence[str]):
888+
List of scopes to be enabled for this service
889+
account on the VM, in addition to the
890+
cloud-platform API scope that will be added by
891+
default.
856892
"""
857893

858894
email: str = proto.Field(
859895
proto.STRING,
860896
number=1,
861897
)
898+
scopes: MutableSequence[str] = proto.RepeatedField(
899+
proto.STRING,
900+
number=2,
901+
)
862902

863903

864904
__all__ = tuple(sorted(__protobuf__.manifest))

google/cloud/batch_v1alpha/types/job.py

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ class InstanceStatus(proto.Message):
316316
task_pack (int):
317317
The max number of tasks can be assigned to
318318
this instance type.
319+
boot_disk (google.cloud.batch_v1alpha.types.AllocationPolicy.Disk):
320+
The VM boot disk.
319321
"""
320322

321323
machine_type: str = proto.Field(
@@ -331,6 +333,11 @@ class InstanceStatus(proto.Message):
331333
proto.INT64,
332334
number=3,
333335
)
336+
boot_disk: "AllocationPolicy.Disk" = proto.Field(
337+
proto.MESSAGE,
338+
number=4,
339+
message="AllocationPolicy.Disk",
340+
)
334341

335342
class TaskGroupStatus(proto.Message):
336343
r"""Aggregated task status for a TaskGroup.
@@ -554,23 +561,38 @@ class Disk(proto.Message):
554561
555562
Attributes:
556563
image (str):
557-
Name of a public or custom image used as the
558-
data source.
564+
Name of a public or custom image used as the data source.
565+
For example, the following are all valid URLs: (1) Specify
566+
the image by its family name:
567+
projects/{project}/global/images/family/{image_family} (2)
568+
Specify the image version:
569+
projects/{project}/global/images/{image_version} You can
570+
also use Batch customized image in short names. The
571+
following image values are supported for a boot disk:
572+
"batch-debian": use Batch Debian images. "batch-centos": use
573+
Batch CentOS images. "batch-cos": use Batch
574+
Container-Optimized images.
559575
560576
This field is a member of `oneof`_ ``data_source``.
561577
snapshot (str):
562578
Name of a snapshot used as the data source.
563579
564580
This field is a member of `oneof`_ ``data_source``.
565581
type_ (str):
566-
Disk type as shown in ``gcloud compute disk-types list`` For
567-
example, "pd-ssd", "pd-standard", "pd-balanced",
568-
"local-ssd".
582+
Disk type as shown in ``gcloud compute disk-types list``.
583+
For example, local SSD uses type "local-ssd". Persistent
584+
disks and boot disks use "pd-balanced", "pd-extreme",
585+
"pd-ssd" or "pd-standard".
569586
size_gb (int):
570-
Disk size in GB. This field is ignored if ``data_source`` is
571-
``disk`` or ``image``. If ``type`` is ``local-ssd``, size_gb
572-
should be a multiple of 375GB, otherwise, the final size
573-
will be the next greater multiple of 375 GB.
587+
Disk size in GB. For persistent disk, this field is ignored
588+
if ``data_source`` is ``image`` or ``snapshot``. For local
589+
SSD, size_gb should be a multiple of 375GB, otherwise, the
590+
final size will be the next greater multiple of 375 GB. For
591+
boot disk, Batch will calculate the boot disk size based on
592+
source image and task requirements if you do not speicify
593+
the size. If both this field and the boot_disk_mib field in
594+
task spec's compute_resource are defined, Batch will only
595+
honor this field.
574596
disk_interface (str):
575597
Local SSDs are available through both "SCSI"
576598
and "NVMe" interfaces. If not indicated, "NVMe"

tests/unit/gapic/batch_v1/test_batch_service.py

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2610,15 +2610,16 @@ def test_create_job_rest(request_type):
26102610
"install_gpu_drivers": True,
26112611
}
26122612
],
2613+
"boot_disk": {
2614+
"image": "image_value",
2615+
"snapshot": "snapshot_value",
2616+
"type_": "type__value",
2617+
"size_gb": 739,
2618+
"disk_interface": "disk_interface_value",
2619+
},
26132620
"disks": [
26142621
{
2615-
"new_disk": {
2616-
"image": "image_value",
2617-
"snapshot": "snapshot_value",
2618-
"type_": "type__value",
2619-
"size_gb": 739,
2620-
"disk_interface": "disk_interface_value",
2621-
},
2622+
"new_disk": {},
26222623
"existing_disk": "existing_disk_value",
26232624
"device_name": "device_name_value",
26242625
}
@@ -2628,7 +2629,10 @@ def test_create_job_rest(request_type):
26282629
"install_gpu_drivers": True,
26292630
}
26302631
],
2631-
"service_account": {"email": "email_value"},
2632+
"service_account": {
2633+
"email": "email_value",
2634+
"scopes": ["scopes_value1", "scopes_value2"],
2635+
},
26322636
"labels": {},
26332637
"network": {
26342638
"network_interfaces": [
@@ -2952,15 +2956,16 @@ def test_create_job_rest_bad_request(
29522956
"install_gpu_drivers": True,
29532957
}
29542958
],
2959+
"boot_disk": {
2960+
"image": "image_value",
2961+
"snapshot": "snapshot_value",
2962+
"type_": "type__value",
2963+
"size_gb": 739,
2964+
"disk_interface": "disk_interface_value",
2965+
},
29552966
"disks": [
29562967
{
2957-
"new_disk": {
2958-
"image": "image_value",
2959-
"snapshot": "snapshot_value",
2960-
"type_": "type__value",
2961-
"size_gb": 739,
2962-
"disk_interface": "disk_interface_value",
2963-
},
2968+
"new_disk": {},
29642969
"existing_disk": "existing_disk_value",
29652970
"device_name": "device_name_value",
29662971
}
@@ -2970,7 +2975,10 @@ def test_create_job_rest_bad_request(
29702975
"install_gpu_drivers": True,
29712976
}
29722977
],
2973-
"service_account": {"email": "email_value"},
2978+
"service_account": {
2979+
"email": "email_value",
2980+
"scopes": ["scopes_value1", "scopes_value2"],
2981+
},
29742982
"labels": {},
29752983
"network": {
29762984
"network_interfaces": [

0 commit comments

Comments
 (0)