1616// under the License.
1717package org .apache .cloudstack .api .command .user .vpc ;
1818
19- import org .apache .log4j .Logger ;
20-
2119import org .apache .cloudstack .acl .SecurityChecker .AccessType ;
2220import org .apache .cloudstack .api .ACL ;
2321import org .apache .cloudstack .api .APICommand ;
2826import org .apache .cloudstack .api .ServerApiException ;
2927import org .apache .cloudstack .api .response .SuccessResponse ;
3028import org .apache .cloudstack .api .response .VpcResponse ;
29+ import org .apache .log4j .Logger ;
3130
3231import com .cloud .event .EventTypes ;
3332import com .cloud .exception .ConcurrentOperationException ;
3736import com .cloud .user .Account ;
3837
3938@ APICommand (name = "restartVPC" , description = "Restarts a VPC" , responseObject = VpcResponse .class , entityType = {Vpc .class },
40- requestHasSensitiveInfo = false , responseHasSensitiveInfo = false )
39+ requestHasSensitiveInfo = false , responseHasSensitiveInfo = false )
4140public class RestartVPCCmd extends BaseAsyncCmd {
4241 public static final Logger s_logger = Logger .getLogger (RestartVPCCmd .class .getName ());
4342 private static final String s_name = "restartvpcresponse" ;
@@ -49,6 +48,12 @@ public class RestartVPCCmd extends BaseAsyncCmd {
4948 @ Parameter (name = ApiConstants .ID , type = CommandType .UUID , entityType = VpcResponse .class , required = true , description = "the id of the VPC" )
5049 private Long id ;
5150
51+ @ Parameter (name = ApiConstants .CLEANUP , type = CommandType .BOOLEAN , required = false , description = "If cleanup old network elements" )
52+ private Boolean cleanup ;
53+
54+ @ Parameter (name = ApiConstants .MAKEREDUNDANTE , type = CommandType .BOOLEAN , required = false , description = "Turn a single VPC into a redundant one." )
55+ private Boolean makeredundant ;
56+
5257 /////////////////////////////////////////////////////
5358 /////////////////// Accessors ///////////////////////
5459 /////////////////////////////////////////////////////
@@ -57,6 +62,20 @@ public Long getId() {
5762 return id ;
5863 }
5964
65+ public Boolean getCleanup () {
66+ if (cleanup != null ) {
67+ return cleanup ;
68+ }
69+ return true ;
70+ }
71+
72+ public Boolean getMakeredundant () {
73+ if (makeredundant != null ) {
74+ return makeredundant ;
75+ }
76+ return true ;
77+ }
78+
6079 /////////////////////////////////////////////////////
6180 /////////////// API Implementation///////////////////
6281 /////////////////////////////////////////////////////
@@ -67,7 +86,7 @@ public String getCommandName() {
6786
6887 @ Override
6988 public long getEntityOwnerId () {
70- Vpc vpc = _entityMgr .findById (Vpc .class , getId ());
89+ final Vpc vpc = _entityMgr .findById (Vpc .class , getId ());
7190 if (vpc != null ) {
7291 return vpc .getAccountId ();
7392 }
@@ -78,20 +97,20 @@ public long getEntityOwnerId() {
7897 @ Override
7998 public void execute () {
8099 try {
81- boolean result = _vpcService .restartVpc (getId ());
100+ final boolean result = _vpcService .restartVpc (getId (), getCleanup (), getMakeredundant ());
82101 if (result ) {
83- SuccessResponse response = new SuccessResponse (getCommandName ());
102+ final SuccessResponse response = new SuccessResponse (getCommandName ());
84103 setResponseObject (response );
85104 } else {
86105 throw new ServerApiException (ApiErrorCode .INTERNAL_ERROR , "Failed to restart VPC" );
87106 }
88- } catch (ResourceUnavailableException ex ) {
107+ } catch (final ResourceUnavailableException ex ) {
89108 s_logger .warn ("Exception: " , ex );
90109 throw new ServerApiException (ApiErrorCode .RESOURCE_UNAVAILABLE_ERROR , ex .getMessage ());
91- } catch (ConcurrentOperationException ex ) {
110+ } catch (final ConcurrentOperationException ex ) {
92111 s_logger .warn ("Exception: " , ex );
93112 throw new ServerApiException (ApiErrorCode .INTERNAL_ERROR , ex .getMessage ());
94- } catch (InsufficientCapacityException ex ) {
113+ } catch (final InsufficientCapacityException ex ) {
95114 s_logger .info (ex );
96115 s_logger .trace (ex );
97116 throw new ServerApiException (ApiErrorCode .INSUFFICIENT_CAPACITY_ERROR , ex .getMessage ());
0 commit comments