<fix>[applianceVm]: set virtualrouter state running after it is started
when create/reboot/start virtualrouter, it state is running
untils mn send all config to it, it not reasonable.
after virtualrouter vm started, set its state to running,
after mn send all config to it, set its status to connected
Resolves:
@@ -576,6 +576,7 @@ public abstract class ApplianceVmBase extends VmInstanceBase implements Applianc
prepareLifeCycleInfo(chain);
prepareFirewallInfo(chain);
+ chain.then(setApplianceStateRunningFlow());
addBootstrapFlows(chain, HypervisorType.valueOf(inv.getHypervisorType()));
List<Flow> subRebootFlows = getPostRebootFlows();
@@ -626,6 +627,7 @@ public abstract class ApplianceVmBase extends VmInstanceBase implements Applianc
}
});
+ chain.then(setApplianceStateRunningFlow());
prepareLifeCycleInfo(chain);
prepareFirewallInfo(chain);
@@ -748,6 +750,7 @@ public abstract class ApplianceVmBase extends VmInstanceBase implements Applianc
chain.getData().put(VmInstanceConstant.Params.VmInstanceSpec.toString(), spec);
chain.getData().put(ApplianceVmConstant.Params.applianceVmFirewallRules.toString(), aspec.getFirewallRules());
+ chain.then(setApplianceStateRunningFlow());
addBootstrapFlows(chain, VolumeFormat.getMasterHypervisorTypeByVolumeFormat(imvo.getFormat()));
List<Flow> subCreateFlows = getPostCreateFlows();
@@ -842,4 +845,16 @@ public abstract class ApplianceVmBase extends VmInstanceBase implements Applianc
logger.debug(String.format("the virtual router [uuid:%s, name:%s] changed status from %s to %s",
self.getUuid(), self.getName(), oldStatus.toString(), newStatus.toString()));
}
+
+ private Flow setApplianceStateRunningFlow() {
+ return new NoRollbackFlow() {
+ String __name__ = "set applianceVm state running";
+
+ @Override
+ public void run(FlowTrigger trigger, Map data) {
+ changeVmStateInDb(VmInstanceStateEvent.running);
+ trigger.next();
+ }
+ };
+ }
}
