Skip to content

Commit

Permalink
Expose refreshInstanceViewAsync in VirtualMachineScaleSetVM (Azure#1901)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryland Degnan authored and jianghaolu committed Sep 26, 2017
1 parent 9f30395 commit aceddc3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.microsoft.azure.management.resources.fluentcore.model.HasInner;
import com.microsoft.azure.management.resources.fluentcore.model.Refreshable;
import rx.Completable;
import rx.Observable;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -304,6 +305,14 @@ public interface VirtualMachineScaleSetVM extends
@Method
VirtualMachineInstanceView refreshInstanceView();

/**
* Refreshes the instance view.
*
* @return an observable that emits the instance view of the virtual machine instance.
*/
@Method
Observable<VirtualMachineInstanceView> refreshInstanceViewAsync();

/**
* @return the power state of the virtual machine instance
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,21 +380,30 @@ public VirtualMachineInstanceView instanceView() {

@Override
public VirtualMachineInstanceView refreshInstanceView() {
VirtualMachineScaleSetVMInstanceViewInner instanceViewInner = this.client.getInstanceView(this.parent().resourceGroupName(),
this.parent().name(),
this.instanceId());
if (instanceViewInner != null) {
this.virtualMachineInstanceView = new VirtualMachineInstanceView()
.withBootDiagnostics(instanceViewInner.bootDiagnostics())
.withDisks(instanceViewInner.disks())
.withExtensions(instanceViewInner.extensions())
.withPlatformFaultDomain(instanceViewInner.platformFaultDomain())
.withPlatformUpdateDomain(instanceViewInner.platformUpdateDomain())
.withRdpThumbPrint(instanceViewInner.rdpThumbPrint())
.withStatuses(instanceViewInner.statuses())
.withVmAgent(instanceViewInner.vmAgent());
}
return this.virtualMachineInstanceView;
return refreshInstanceViewAsync().toBlocking().last();
}

public Observable<VirtualMachineInstanceView> refreshInstanceViewAsync() {
return this.client.getInstanceViewAsync(this.parent().resourceGroupName(),
this.parent().name(),
this.instanceId())
.map(new Func1<VirtualMachineScaleSetVMInstanceViewInner, VirtualMachineInstanceView>() {
@Override
public VirtualMachineInstanceView call(VirtualMachineScaleSetVMInstanceViewInner instanceViewInner) {
if (instanceViewInner != null) {
virtualMachineInstanceView = new VirtualMachineInstanceView()
.withBootDiagnostics(instanceViewInner.bootDiagnostics())
.withDisks(instanceViewInner.disks())
.withExtensions(instanceViewInner.extensions())
.withPlatformFaultDomain(instanceViewInner.platformFaultDomain())
.withPlatformUpdateDomain(instanceViewInner.platformUpdateDomain())
.withRdpThumbPrint(instanceViewInner.rdpThumbPrint())
.withStatuses(instanceViewInner.statuses())
.withVmAgent(instanceViewInner.vmAgent());
}
return virtualMachineInstanceView;
}
});
}

@Override
Expand Down

0 comments on commit aceddc3

Please sign in to comment.