Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ready For Review] Virtual machine scale sets #1071

Merged
merged 25 commits into from
Sep 21, 2016
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2b7d733
VirtualMachineScaleSet interface with defintion and update stages of …
anuchandy Sep 10, 2016
68bd2f7
Adding more intermediate stage interfaces to update stages
anuchandy Sep 10, 2016
1539d2e
Adding more definition stages of virtual machine scale set
anuchandy Sep 10, 2016
0596d03
Initial VirtualMachineScaleSetImpl and Sku models
anuchandy Sep 10, 2016
5d750dc
Enabling wither for load balancer & it's backends and nat pools
anuchandy Sep 11, 2016
b4f3018
Logic to add & remove backend and inbound nat pool association with t…
anuchandy Sep 11, 2016
ffa0139
Adding support for virtual machine scale set extensions
anuchandy Sep 11, 2016
9641f2e
Adding scale sets entry point
anuchandy Sep 11, 2016
527b1e6
using lb state variables on update
anuchandy Sep 12, 2016
607688c
implementing createInner
anuchandy Sep 13, 2016
5c5cfc9
Adding withers to set computer name prefix and to remove the backends…
anuchandy Sep 13, 2016
8b49955
Exposing some actions
anuchandy Sep 13, 2016
e819bd9
Adding actions to vmss collction and enabling replacing load balancer…
anuchandy Sep 13, 2016
d0a921c
Merge remote-tracking branch 'origin/master' into vmss-fluent2
anuchandy Sep 13, 2016
dd48691
Starting unit test and some fixes
anuchandy Sep 13, 2016
520ae9e
Merge branch 'master' of github.com:Azure/azure-sdk-for-java into vms…
anuchandy Sep 13, 2016
b4c249c
setting couple of default values and simplifying code
anuchandy Sep 14, 2016
8353c4a
first unit test that creates VMSS. Adding a check to avoid Azure putt…
anuchandy Sep 15, 2016
e100f6c
Merge branch 'master' of github.com:Azure/azure-sdk-for-java into vms…
anuchandy Sep 15, 2016
d7b1241
fix checkstyle error due to incorrect javadoc
anuchandy Sep 15, 2016
64d4056
Adding unit test validate connection to vms in a scale set via intern…
anuchandy Sep 15, 2016
fb53fc1
Merge branch 'master' of github.com:Azure/azure-sdk-for-java into vms…
anuchandy Sep 17, 2016
5be9ab4
Using updated ChildResource that exposes parent()
anuchandy Sep 17, 2016
fe9b75d
Addressing CR and adding annotations
anuchandy Sep 19, 2016
357b8bb
Merge branch 'master' of github.com:Azure/azure-sdk-for-java into vms…
anuchandy Sep 20, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Addressing CR and adding annotations
  • Loading branch information
anuchandy committed Sep 19, 2016
commit fe9b75deb96048b256c7be784affc97ff6d89deb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.microsoft.azure.management.compute;

import com.microsoft.azure.management.apigeneration.LangDefinition;
import com.microsoft.azure.management.compute.implementation.VirtualMachineScaleSetExtensionInner;
import com.microsoft.azure.management.resources.fluentcore.arm.models.ChildResource;
import com.microsoft.azure.management.resources.fluentcore.model.Attachable;
@@ -13,6 +14,7 @@
* An immutable client-side representation of an extension associated with virtual machines in a scale set.
* An extension associated with a virtual machine scale set will be created from a {@link VirtualMachineExtensionImage }.
*/
@LangDefinition()
public interface VirtualMachineScaleSetExtension extends
Wrapper<VirtualMachineScaleSetExtensionInner>,
ChildResource<VirtualMachineScaleSet> {
@@ -52,9 +54,25 @@ public interface VirtualMachineScaleSetExtension extends
*/
String provisioningState();

/**
* The entirety of a virtual machine scale set extension definition as a part of parent definition.
*
* @param <ParentT> the return type of the final {@link Attachable#attach()}
*/
@LangDefinition(ContainerName = "~/VirtualMachineScaleSetExtension.Definition", ContainerFileName = "IDefinition")
interface Definition<ParentT> extends
DefinitionStages.Blank<ParentT>,
DefinitionStages.WithImageOrPublisher<ParentT>,
DefinitionStages.WithPublisher<ParentT>,
DefinitionStages.WithType<ParentT>,
DefinitionStages.WithVersion<ParentT>,
DefinitionStages.WithAttach<ParentT> {
}

/**
* Grouping of virtual machine scale set extension definition stages as a part of parent virtual machine scale set definition.
*/
@LangDefinition(ContainerName = "~/VirtualMachineScaleSetExtension.Definition", ContainerFileName = "IDefinition", IsContainerOnly = true)
interface DefinitionStages {
/**
* The first stage of a virtual machine scale set extension definition.
@@ -206,23 +224,10 @@ interface WithSettings<ParentT> {
}
}

/**
* The entirety of a virtual machine scale set extension definition as a part of parent definition.
*
* @param <ParentT> the return type of the final {@link Attachable#attach()}
*/
interface Definition<ParentT> extends
DefinitionStages.Blank<ParentT>,
DefinitionStages.WithImageOrPublisher<ParentT>,
DefinitionStages.WithPublisher<ParentT>,
DefinitionStages.WithType<ParentT>,
DefinitionStages.WithVersion<ParentT>,
DefinitionStages.WithAttach<ParentT> {
}

/**
* Grouping of virtual machine scale set extension definition stages as part of parent virtual machine scale set update.
*/
@LangDefinition(ContainerName = "~/VirtualMachineScaleSetExtension.Update", ContainerFileName = "IUpdateDefinition", IsContainerOnly = true)
interface UpdateDefinitionStages {
/**
* The first stage of a virtual machine scale set extension definition.
@@ -318,14 +323,14 @@ interface WithAttach<ParentT> extends
*/
interface WithAutoUpgradeMinorVersion<ParentT> {
/**
* enables auto upgrade of the extension.
* Enables auto upgrade of the extension.
*
* @return the next stage of the definition
*/
WithAttach<ParentT> withAutoUpgradeMinorVersionEnabled();

/**
* disables auto upgrade of the extension.
* Disables auto upgrade of the extension.
*
* @return the next stage of the definition
*/
@@ -378,6 +383,7 @@ interface WithSettings<ParentT> {
* The entirety of a virtual machine scale set extension definition as a part of parent update.
* @param <ParentT> the return type of the final {@link Attachable#attach()}
*/
@LangDefinition(ContainerName = "~/VirtualMachineScaleSetExtension.Update", ContainerFileName = "IUpdateDefinition")
interface UpdateDefinition<ParentT> extends
UpdateDefinitionStages.Blank<ParentT>,
UpdateDefinitionStages.WithImageOrPublisher<ParentT>,
@@ -390,6 +396,7 @@ interface UpdateDefinition<ParentT> extends
/**
* Grouping of virtual machine extension update stages.
*/
@LangDefinition(ContainerName = "~/VirtualMachineScaleSetExtension.Update", ContainerFileName = "IUpdate", IsContainerOnly = true)
interface UpdateStages {
/**
* The stage of the virtual machine scale set extension update allowing to enable or disable auto upgrade of the
@@ -454,6 +461,7 @@ interface WithSettings {
/**
* The entirety of virtual machine scale set extension update as a part of parent virtual machine scale set update.
*/
@LangDefinition(ContainerName = "~/VirtualMachineScaleSetExtension.Update", ContainerFileName = "IUpdate")
interface Update extends
Settable<VirtualMachineScaleSet.Update>,
UpdateStages.WithAutoUpgradeMinorVersion,
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.microsoft.azure.management.compute;

import com.microsoft.azure.management.apigeneration.LangDefinition;

/**
* A type representing sku available for virtual machines in a scale set.
*/
@LangDefinition(ContainerName = "~/")
public interface VirtualMachineScaleSetSku {
/**
* @return the type of resource the sku applies to.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.microsoft.azure.management.compute;

import com.microsoft.azure.management.apigeneration.LangDefinition;

/**
* Scale set virtual machine sku types.
*/
@LangDefinition
public class VirtualMachineScaleSetSkuTypes {
/** Static value Standard_A0 for VirtualMachineScaleSetSkuTypes. */
public static final VirtualMachineScaleSetSkuTypes STANDARD_A0 = new VirtualMachineScaleSetSkuTypes("Standard_A0", "Standard");
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.microsoft.azure.management.compute;

import com.microsoft.azure.CloudException;
import com.microsoft.azure.management.apigeneration.LangDefinition;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById;
@@ -15,6 +16,7 @@
/**
* Entry point to virtual machine scale set management API.
*/
@LangDefinition(ContainerName = "~/")
public interface VirtualMachineScaleSets extends
SupportsListing<VirtualMachineScaleSet>,
SupportsListingByGroup<VirtualMachineScaleSet>,
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.microsoft.azure.management.compute.implementation;

import com.microsoft.azure.management.apigeneration.LangDefinition;
import com.microsoft.azure.management.compute.VirtualMachineExtensionImage;
import com.microsoft.azure.management.compute.VirtualMachineScaleSet;
import com.microsoft.azure.management.compute.VirtualMachineScaleSetExtension;
@@ -13,12 +14,13 @@
/**
* Implementation of {@link VirtualMachineScaleSetExtension}.
*/
@LangDefinition()
public class VirtualMachineScaleSetExtensionImpl
extends ChildResourceImpl<VirtualMachineScaleSetExtensionInner, VirtualMachineScaleSetImpl, VirtualMachineScaleSet>
implements
VirtualMachineScaleSetExtension,
VirtualMachineScaleSetExtension.Definition<VirtualMachineScaleSet.DefinitionStages.WithCreate>,
VirtualMachineScaleSetExtension.UpdateDefinition<VirtualMachineScaleSet.UpdateStages.WithApplicable>,
VirtualMachineScaleSetExtension.UpdateDefinition<VirtualMachineScaleSet.UpdateStages.WithApply>,
VirtualMachineScaleSetExtension.Update {

private HashMap<String, Object> publicSettings;
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import com.microsoft.azure.CloudException;
import com.microsoft.azure.PagedList;
import com.microsoft.azure.SubResource;
import com.microsoft.azure.management.apigeneration.LangDefinition;
import com.microsoft.azure.management.compute.ApiEntityReference;
import com.microsoft.azure.management.compute.CachingTypes;
import com.microsoft.azure.management.compute.DiskCreateOptionTypes;
@@ -54,6 +55,7 @@
/**
* Implementation of {@link VirtualMachineScaleSet}.
*/
@LangDefinition
public class VirtualMachineScaleSetImpl
extends GroupableParentResourceImpl<
VirtualMachineScaleSet,
@@ -71,8 +73,6 @@ public class VirtualMachineScaleSetImpl
// used to generate unique name for any dependency resources
private final ResourceNamer namer;
private boolean isMarketplaceLinuxImage = false;
// reference to an existing network that needs to be used in virtual machine's primary network interface
private Network existingPrimaryNetworkToAssociate;
// name of an existing subnet in the primary network to use
private String existingPrimaryNetworkSubnetNameToAssociate;
// unique key of a creatable storage accounts to be used for virtual machines child resources that
@@ -137,10 +137,10 @@ protected void initializeChildrenFromInner() {
}
}

@Override
public PagedList<VirtualMachineScaleSetSku> availableSkus() throws CloudException, IOException {
@Override
public PagedList<VirtualMachineScaleSetSku> availableSkus() throws CloudException, IOException {
return this.skuConverter.convert(this.client.listSkus(this.resourceGroupName(), this.name()));
}
}

@Override
public void deallocate() throws CloudException, IOException, InterruptedException {
@@ -321,14 +321,8 @@ public VirtualMachineScaleSetImpl withSku(VirtualMachineScaleSetSku sku) {
}

@Override
public VirtualMachineScaleSetImpl withExistingPrimaryNetwork(Network network) {
this.existingPrimaryNetworkToAssociate = network;
return this;
}

@Override
public VirtualMachineScaleSetImpl withSubnet(String name) {
this.existingPrimaryNetworkSubnetNameToAssociate = name;
public VirtualMachineScaleSetImpl withExistingPrimaryNetworkSubnet(Network network, String subnetName) {
this.existingPrimaryNetworkSubnetNameToAssociate = mergePath(network.id(), "subnets", subnetName);
return this;
}

@@ -390,7 +384,7 @@ public VirtualMachineScaleSetImpl withPrimaryInternalLoadBalancer(LoadBalancer l
}

if (isInCreateMode()) {
String vmNICNetworkId = this.existingPrimaryNetworkToAssociate.id();
String vmNICNetworkId = ResourceUtils.parentResourcePathFromResourceId(this.existingPrimaryNetworkSubnetNameToAssociate);
// Azure has a really wired BUG that - it throws exception when vnet of VMSS and LB are not same
// (code: NetworkInterfaceAndInternalLoadBalancerMustUseSameVnet) but at the same time Azure update
// the VMSS's network section to refer this invalid internal LB. This makes VMSS un-usable and portal
@@ -645,15 +639,31 @@ public VirtualMachineScaleSetImpl withSsh(String publicKeyData) {
}

@Override
public VirtualMachineScaleSetImpl disableVmAgent() {
public VirtualMachineScaleSetImpl withVmAgent() {
this.inner()
.virtualMachineProfile()
.osProfile().windowsConfiguration().withProvisionVMAgent(true);
return this;
}

@Override
public VirtualMachineScaleSetImpl withoutVmAgent() {
this.inner()
.virtualMachineProfile()
.osProfile().windowsConfiguration().withProvisionVMAgent(false);
return this;
}

@Override
public VirtualMachineScaleSetImpl disableAutoUpdate() {
public VirtualMachineScaleSetImpl withAutoUpdate() {
this.inner()
.virtualMachineProfile()
.osProfile().windowsConfiguration().withEnableAutomaticUpdates(true);
return this;
}

@Override
public VirtualMachineScaleSetImpl withoutAutoUpdate() {
this.inner()
.virtualMachineProfile()
.osProfile().windowsConfiguration().withEnableAutomaticUpdates(false);
@@ -983,12 +993,8 @@ private void setPrimaryIpConfigurationSubnet() {
}

VirtualMachineScaleSetIPConfigurationInner ipConfig = this.primaryNicDefaultIPConfiguration();
ipConfig.withSubnet(new ApiEntityReference().withId(this.existingPrimaryNetworkToAssociate.id()
+ "/"
+ "subnets"
+ "/"
+ existingPrimaryNetworkSubnetNameToAssociate));
this.existingPrimaryNetworkToAssociate = null;
ipConfig.withSubnet(new ApiEntityReference().withId(this.existingPrimaryNetworkSubnetNameToAssociate));
this.existingPrimaryNetworkSubnetNameToAssociate = null;
}

private void setPrimaryIpConfigurationBackendsAndInboundNatPools() {
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.microsoft.azure.management.compute.implementation;

import com.microsoft.azure.management.apigeneration.LangDefinition;
import com.microsoft.azure.management.compute.VirtualMachineScaleSetSku;
import com.microsoft.azure.management.compute.VirtualMachineScaleSetSkuCapacity;
import com.microsoft.azure.management.compute.VirtualMachineScaleSetSkuTypes;
@@ -8,6 +9,7 @@
/**
* implementation of {@link VirtualMachineScaleSetSku}.
*/
@LangDefinition
class VirtualMachineScaleSetSkuImpl
extends WrapperImpl<VirtualMachineScaleSetSkuInner>
implements VirtualMachineScaleSetSku {
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.microsoft.azure.management.compute.implementation;

import com.microsoft.azure.PagedList;
import com.microsoft.azure.management.apigeneration.LangDefinition;
import com.microsoft.azure.management.compute.VirtualMachineScaleSet;
import com.microsoft.azure.management.compute.VirtualMachineScaleSetNetworkProfile;
import com.microsoft.azure.management.compute.VirtualMachineScaleSetOSDisk;
@@ -17,6 +18,7 @@
/**
* The implementation for {@link VirtualMachineScaleSets}.
*/
@LangDefinition
public class VirtualMachineScaleSetsImpl
extends GroupableResourcesImpl<
VirtualMachineScaleSet,
Original file line number Diff line number Diff line change
@@ -60,8 +60,7 @@ public void canCreateVirtualMachineScaleSetWithCustomScriptExtension() throws Ex
.withRegion(LOCATION)
.withExistingResourceGroup(resourceGroup)
.withSku(VirtualMachineScaleSetSkuTypes.STANDARD_A0)
.withExistingPrimaryNetwork(network)
.withSubnet("subnet1")
.withExistingPrimaryNetworkSubnet(network, "subnet1")
.withPrimaryInternetFacingLoadBalancer(publicLoadBalancer)
.withoutPrimaryInternalLoadBalancer()
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS)
@@ -143,8 +142,7 @@ public void canCreateVirtualMachineScaleSet() throws Exception {
.withRegion(LOCATION)
.withExistingResourceGroup(resourceGroup)
.withSku(VirtualMachineScaleSetSkuTypes.STANDARD_A0)
.withExistingPrimaryNetwork(network)
.withSubnet("subnet1")
.withExistingPrimaryNetworkSubnet(network, "subnet1")
.withPrimaryInternetFacingLoadBalancer(publicLoadBalancer)
.withPrimaryInternetFacingLoadBalancerBackends(backends.get(0), backends.get(1))
.withoutPrimaryInternalLoadBalancer()