Skip to content

Commit 9ef7fbf

Browse files
authored
support withLogicalSectorSize (Azure#35433)
1 parent ffd0470 commit 9ef7fbf

File tree

6 files changed

+369
-1
lines changed

6 files changed

+369
-1
lines changed

sdk/resourcemanager/azure-resourcemanager-compute/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
### Features Added
66

7+
- Supported `withLogicalSectorSizeInBytes` in `Disk`.
8+
- Supported `PREMIUM_V2_LRS` in `DiskSkuTypes`.
9+
710
### Breaking Changes
811

912
### Bugs Fixed

sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/implementation/DiskImpl.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ public boolean isHibernationSupported() {
142142
return ResourceManagerUtils.toPrimitiveBoolean(innerModel().supportsHibernation());
143143
}
144144

145+
@Override
146+
public Integer logicalSectorSizeInBytes() {
147+
return this.innerModel().creationData().logicalSectorSize();
148+
}
149+
145150
@Override
146151
public DiskImpl withLinuxFromVhd(String vhdUrl) {
147152
this
@@ -405,6 +410,13 @@ public DiskImpl withoutHibernationSupport() {
405410
return this;
406411
}
407412

413+
@Override
414+
public DiskImpl withLogicalSectorSizeInBytes(int logicalSectorSizeInBytes) {
415+
// creation data should already be initialized in previous mandatory stages, e.g. withData()
416+
this.innerModel().creationData().withLogicalSectorSize(logicalSectorSizeInBytes);
417+
return this;
418+
}
419+
408420
@Override
409421
public Mono<Disk> createResourceAsync() {
410422
return manager()

sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/Disk.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ public interface Disk extends GroupableResource<ComputeManager, DiskInner>, Refr
8686
/** @return whether the OS on a disk supports hibernation. */
8787
boolean isHibernationSupported();
8888

89+
/** @return logical sector size in bytes for Premium SSD v2 and Ultra disks. */
90+
Integer logicalSectorSizeInBytes();
91+
8992
/** The entirety of the managed disk definition. */
9093
interface Definition
9194
extends DefinitionStages.Blank,
@@ -430,6 +433,18 @@ interface WithHibernationSupport {
430433
WithCreate withHibernationSupport();
431434
}
432435

436+
/** The stage of the managed disk definition allowing to configure logical sector size for Premium SSD v2 and Ultra Disks. */
437+
interface WithLogicalSectorSize {
438+
/**
439+
* Specifies the logical sector size in bytes for Premium SSD v2 and Ultra Disks.
440+
* Supported values are 512 and 4096. 4096 is the default.
441+
*
442+
* @param logicalSectorSizeInBytes logical sector size in bytes
443+
* @return the next stage of the definition
444+
*/
445+
WithCreate withLogicalSectorSizeInBytes(int logicalSectorSizeInBytes);
446+
}
447+
433448
/**
434449
* The stage of the definition which contains all the minimum required inputs for the resource to be created,
435450
* but also allows for any other optional settings to be specified.
@@ -440,7 +455,8 @@ interface WithCreate
440455
WithSku,
441456
WithAvailabilityZone,
442457
WithDiskEncryption,
443-
WithHibernationSupport {
458+
WithHibernationSupport,
459+
WithLogicalSectorSize {
444460

445461
/**
446462
* Begins creating the disk resource.

sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/DiskSkuTypes.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public final class DiskSkuTypes {
2626
/** Static value ULTRA_SSD_LRS for DiskSkuTypes. */
2727
public static final DiskSkuTypes ULTRA_SSD_LRS = new DiskSkuTypes(DiskStorageAccountTypes.ULTRA_SSD_LRS);
2828

29+
/** Static value PREMIUM_V2_LRS for DiskSkuTypes. */
30+
public static final DiskSkuTypes PREMIUM_V2_LRS = new DiskSkuTypes(DiskStorageAccountTypes.PREMIUM_V2_LRS);
31+
2932
/** The actual serialized value for a DiskSkuTypes instance. */
3033
private final DiskStorageAccountTypes value;
3134

sdk/resourcemanager/azure-resourcemanager-compute/src/test/java/com/azure/resourcemanager/compute/ManagedDiskOperationsTests.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,4 +361,43 @@ public void canCopyStartIncrementalSnapshot() {
361361
Assertions.assertEquals(fromSnapshotDisk.source().type(), CreationSourceType.COPIED_FROM_SNAPSHOT);
362362
Assertions.assertTrue(fromSnapshotDisk.source().sourceId().equalsIgnoreCase(snapshotNewRegion.id()));
363363
}
364+
365+
@Test
366+
public void canCreateWithLogicalSectorSize() {
367+
String diskName = generateRandomResourceName("disk", 15);
368+
369+
// logical sector size is null for standard SKU
370+
Disk defaultDisk =
371+
computeManager
372+
.disks()
373+
.define("default_disk")
374+
.withRegion(Region.US_EAST)
375+
.withNewResourceGroup(rgName)
376+
.withData()
377+
.withSizeInGB(1)
378+
.withSku(DiskSkuTypes.STANDARD_LRS)
379+
.create();
380+
381+
defaultDisk.refresh();
382+
383+
Assertions.assertNull(defaultDisk.logicalSectorSizeInBytes());
384+
385+
// can specify logical sector size on PREMIUM_V2_LRS
386+
Disk disk =
387+
computeManager
388+
.disks()
389+
.define(diskName)
390+
.withRegion(Region.US_EAST)
391+
.withExistingResourceGroup(rgName)
392+
.withData()
393+
.withSizeInGB(10)
394+
.withSku(DiskSkuTypes.PREMIUM_V2_LRS)
395+
.withLogicalSectorSizeInBytes(512)
396+
.create();
397+
398+
disk.refresh();
399+
400+
Assertions.assertEquals(DiskSkuTypes.PREMIUM_V2_LRS, disk.sku());
401+
Assertions.assertEquals(512, disk.logicalSectorSizeInBytes());
402+
}
364403
}

0 commit comments

Comments
 (0)