Skip to content

Commit

Permalink
Merge pull request Azure#909 from anuchandy/fixIpconfigAttach
Browse files Browse the repository at this point in the history
Add ipConfig to parent inside attach() not in ctr
  • Loading branch information
Martin Sawicki authored Jun 27, 2016
2 parents 0da2078 + 031fedf commit 53bd408
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ class NetworkInterfaceImpl
initializeNicIpConfigurations();
}

/**************************************************.
* Verbs
**************************************************/
// Verbs

@Override
public NetworkInterface refresh() throws Exception {
Expand All @@ -99,9 +97,7 @@ public ServiceCall applyAsync(ServiceCallback<NetworkInterface> callback) {
return createAsync(callback);
}

/**************************************************.
* Setters
**************************************************/
// Setters (fluent)

@Override
public NetworkInterfaceImpl withNewPrimaryNetwork(Creatable<Network> creatable) {
Expand Down Expand Up @@ -247,9 +243,7 @@ public NetworkInterfaceImpl withInternalDnsNameLabel(String dnsNameLabel) {
return this;
}

/**************************************************.
* Getters
**************************************************/
// Getters

@Override
public boolean isIpForwardingEnabled() {
Expand Down Expand Up @@ -377,8 +371,8 @@ public void failure(Throwable t) {

@Override
public void success(ServiceResponse<Void> result) {
initializeNicIpConfigurations();
clearCachedRelatedResources();
initializeNicIpConfigurations();
callback.success(result);
}
}));
Expand All @@ -398,6 +392,7 @@ private NicIpConfigurationImpl primaryIpConfiguration() {

if (isInCreateMode()) {
this.nicPrimaryIpConfiguration = prepareNewNicIpConfiguration("primary-nic-config");
withIpConfiguration(this.nicPrimaryIpConfiguration);
} else {
// Currently Azure supports only one IP configuration and that is the primary
// hence we pick the first one here.
Expand Down Expand Up @@ -450,7 +445,6 @@ private NicIpConfigurationImpl prepareNewNicIpConfiguration(String name) {
this,
super.myManager
);
this.nicIpConfigurations.add(nicIpConfiguration);
return nicIpConfiguration;
}

Expand All @@ -461,6 +455,12 @@ private void clearCachedRelatedResources() {
this.nicPrimaryIpConfiguration = null;
}

NetworkInterfaceImpl withIpConfiguration(NicIpConfigurationImpl nicIpConfiguration) {
this.nicIpConfigurations.add(nicIpConfiguration);
this.inner().ipConfigurations().add(nicIpConfiguration.inner());
return this;
}

void addToCreatableDependencies(Creatable<?> creatableResource) {
super.addCreatableDependency(creatableResource);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ protected static NicIpConfigurationImpl prepareNicIpConfiguration(String name,
final NetworkManager networkManager) {
NetworkInterfaceIPConfiguration ipConfigurationInner = new NetworkInterfaceIPConfiguration();
ipConfigurationInner.withName(name);
parent.inner().ipConfigurations().add(ipConfigurationInner);
return new NicIpConfigurationImpl(name,
ipConfigurationInner,
parent,
Expand Down Expand Up @@ -115,7 +114,7 @@ public String privateIpAllocationMethod() {

@Override
public NetworkInterfaceImpl attach() {
return parent();
return parent().withIpConfiguration(this);
}

@Override
Expand Down

0 comments on commit 53bd408

Please sign in to comment.