@@ -109,59 +109,69 @@ public Answer executeRequest(final Command cmd) {
109109 return new Answer (cmd , false , rc .getDetails ());
110110 }
111111
112+ Answer answer ;
112113 if (cmd instanceof SetPortForwardingRulesVpcCommand ) {
113- return execute ((SetPortForwardingRulesVpcCommand )cmd );
114+ answer = execute ((SetPortForwardingRulesVpcCommand )cmd );
114115 } else if (cmd instanceof SetPortForwardingRulesCommand ) {
115- return execute ((SetPortForwardingRulesCommand )cmd );
116+ answer = execute ((SetPortForwardingRulesCommand )cmd );
116117 } else if (cmd instanceof SetStaticRouteCommand ) {
117- return execute ((SetStaticRouteCommand )cmd );
118+ answer = execute ((SetStaticRouteCommand )cmd );
118119 } else if (cmd instanceof SetStaticNatRulesCommand ) {
119- return execute ((SetStaticNatRulesCommand )cmd );
120+ answer = execute ((SetStaticNatRulesCommand )cmd );
120121 } else if (cmd instanceof LoadBalancerConfigCommand ) {
121- return execute ((LoadBalancerConfigCommand )cmd );
122+ answer = execute ((LoadBalancerConfigCommand )cmd );
122123 } else if (cmd instanceof SavePasswordCommand ) {
123- return execute ((SavePasswordCommand )cmd );
124+ answer = execute ((SavePasswordCommand )cmd );
124125 } else if (cmd instanceof DhcpEntryCommand ) {
125- return execute ((DhcpEntryCommand )cmd );
126+ answer = execute ((DhcpEntryCommand )cmd );
126127 } else if (cmd instanceof CreateIpAliasCommand ) {
127- return execute ((CreateIpAliasCommand )cmd );
128+ answer = execute ((CreateIpAliasCommand )cmd );
128129 } else if (cmd instanceof DnsMasqConfigCommand ) {
129- return execute ((DnsMasqConfigCommand )cmd );
130+ answer = execute ((DnsMasqConfigCommand )cmd );
130131 } else if (cmd instanceof DeleteIpAliasCommand ) {
131- return execute ((DeleteIpAliasCommand )cmd );
132+ answer = execute ((DeleteIpAliasCommand )cmd );
132133 } else if (cmd instanceof VmDataCommand ) {
133- return execute ((VmDataCommand )cmd );
134+ answer = execute ((VmDataCommand )cmd );
134135 } else if (cmd instanceof CheckRouterCommand ) {
135- return execute ((CheckRouterCommand )cmd );
136+ answer = execute ((CheckRouterCommand )cmd );
136137 } else if (cmd instanceof SetFirewallRulesCommand ) {
137- return execute ((SetFirewallRulesCommand )cmd );
138+ answer = execute ((SetFirewallRulesCommand )cmd );
138139 } else if (cmd instanceof BumpUpPriorityCommand ) {
139- return execute ((BumpUpPriorityCommand )cmd );
140+ answer = execute ((BumpUpPriorityCommand )cmd );
140141 } else if (cmd instanceof RemoteAccessVpnCfgCommand ) {
141- return execute ((RemoteAccessVpnCfgCommand )cmd );
142+ answer = execute ((RemoteAccessVpnCfgCommand )cmd );
142143 } else if (cmd instanceof VpnUsersCfgCommand ) {
143- return execute ((VpnUsersCfgCommand )cmd );
144+ answer = execute ((VpnUsersCfgCommand )cmd );
144145 } else if (cmd instanceof GetDomRVersionCmd ) {
145- return execute ((GetDomRVersionCmd )cmd );
146+ answer = execute ((GetDomRVersionCmd )cmd );
146147 } else if (cmd instanceof Site2SiteVpnCfgCommand ) {
147- return execute ((Site2SiteVpnCfgCommand )cmd );
148+ answer = execute ((Site2SiteVpnCfgCommand )cmd );
148149 } else if (cmd instanceof CheckS2SVpnConnectionsCommand ) {
149- return execute ((CheckS2SVpnConnectionsCommand )cmd );
150+ answer = execute ((CheckS2SVpnConnectionsCommand )cmd );
150151 } else if (cmd instanceof SetMonitorServiceCommand ) {
151- return execute ((SetMonitorServiceCommand )cmd );
152+ answer = execute ((SetMonitorServiceCommand )cmd );
152153 } else if (cmd instanceof SetupGuestNetworkCommand ) {
153- return execute ((SetupGuestNetworkCommand )cmd );
154+ answer = execute ((SetupGuestNetworkCommand )cmd );
154155 } else if (cmd instanceof SetNetworkACLCommand ) {
155- return execute ((SetNetworkACLCommand )cmd );
156+ answer = execute ((SetNetworkACLCommand )cmd );
156157 } else if (cmd instanceof SetSourceNatCommand ) {
157- return execute ((SetSourceNatCommand )cmd );
158+ answer = execute ((SetSourceNatCommand )cmd );
158159 } else if (cmd instanceof IpAssocVpcCommand ) {
159- return execute ((IpAssocVpcCommand )cmd );
160+ answer = execute ((IpAssocVpcCommand )cmd );
160161 } else if (cmd instanceof IpAssocCommand ) {
161- return execute ((IpAssocCommand )cmd );
162+ answer = execute ((IpAssocCommand )cmd );
162163 } else {
163- return Answer .createUnsupportedCommandAnswer (cmd );
164+ answer = Answer .createUnsupportedCommandAnswer (cmd );
164165 }
166+
167+ rc = _vrDeployer .cleanupCommand ((NetworkElementCommand )cmd );
168+ if (!rc .isSuccess ()) {
169+ s_logger .error ("Failed to clean up VR command due to " + rc .getDetails ());
170+ // TODO fail it more properly in the future, some commands may need specific answer rather than generic answer
171+ answer = new Answer (cmd , false , rc .getDetails ());
172+ }
173+
174+ return answer ;
165175 } catch (final IllegalArgumentException e ) {
166176 return new Answer (cmd , false , e .getMessage ());
167177 } finally {
0 commit comments