Permalink
Browse files

fix network index handling during start/stop cycle

  • Loading branch information...
1 parent 2a98f04 commit fb74621c078507af06496d22aaeccad48e9bface @grze grze committed Feb 1, 2012
@@ -99,6 +99,7 @@
import com.eucalyptus.entities.Entities;
import com.eucalyptus.entities.TransactionException;
import com.eucalyptus.images.BlockStorageImageInfo;
+import com.eucalyptus.network.PrivateNetworkIndex;
import com.eucalyptus.records.EventRecord;
import com.eucalyptus.records.EventType;
import com.eucalyptus.records.Logs;
@@ -436,6 +437,9 @@ public StartInstancesResponseType startInstances( final StartInstancesType reque
Allocation allocInfo = Allocations.start( vm );
try {//scope for allocInfo
AdmissionControl.run( ).apply( allocInfo );
+ PrivateNetworkIndex vmIdx = allocInfo.getAllocationTokens( ).get( 0 ).getNetworkIndex( );
+ vmIdx.set( vm );
+ vm.setNetworkIndex( vmIdx );
vm.setState( VmState.PENDING );
ClusterAllocator.get( ).apply( allocInfo );
final int oldCode = vm.getState( ).getCode( ), newCode = VmState.PENDING.getCode( );
@@ -657,6 +657,13 @@ public VmInstance apply( final VmInstance v ) {
vm.setState( VmState.STOPPING, Reason.USER_STOPPED );
} else if ( VmState.STOPPING.equals( vm.getState( ) ) ) {
vm.setState( VmState.STOPPED, Reason.USER_STOPPED );
+ PrivateNetworkIndex vmIdx = vm.getNetworkIndex( );
+ if ( vmIdx != null ) {
+ vmIdx.release( );
+ vmIdx.teardown( );
+ vmIdx = null;
+ }
+ vm.setNetworkIndex( null );
}
db.commit( );
return vm;
@@ -1214,7 +1221,7 @@ public String toString( ) {
}
- private PrivateNetworkIndex getNetworkIndex( ) {
+ PrivateNetworkIndex getNetworkIndex( ) {
return this.networkIndex;
}

0 comments on commit fb74621

Please sign in to comment.