mirror of https://github.com/apache/cloudstack.git
bug 11130: Update template and script version in the database when domR started
This commit is contained in:
parent
89e45bd671
commit
b8f8989821
|
|
@ -125,6 +125,12 @@ public class DomainRouterResponse extends BaseResponse {
|
|||
@SerializedName("redundantstate") @Param(description="the state of redundant virtual router")
|
||||
private String redundantState;
|
||||
|
||||
@SerializedName("templateversion") @Param(description="the version of template")
|
||||
private String templateVersion;
|
||||
|
||||
@SerializedName("scriptsversion") @Param(description="the version of scripts")
|
||||
private String scriptsVersion;
|
||||
|
||||
@Override
|
||||
public Long getObjectId() {
|
||||
return getId();
|
||||
|
|
@ -393,4 +399,20 @@ public class DomainRouterResponse extends BaseResponse {
|
|||
public void setIsRedundantRouter(boolean isRedundantRouter) {
|
||||
this.isRedundantRouter = isRedundantRouter;
|
||||
}
|
||||
|
||||
public String getTemplateVersion() {
|
||||
return this.templateVersion;
|
||||
}
|
||||
|
||||
public void setTemplateVersion(String templateVersion) {
|
||||
this.templateVersion = templateVersion;
|
||||
}
|
||||
|
||||
public String getScriptsVersion() {
|
||||
return this.scriptsVersion;
|
||||
}
|
||||
|
||||
public void setScriptsVersion(String scriptsVersion) {
|
||||
this.scriptsVersion = scriptsVersion;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,12 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
|||
@Enumerated(EnumType.STRING)
|
||||
private Role role = Role.DHCP_FIREWALL_LB_PASSWD_USERDATA;
|
||||
|
||||
@Column(name="template_version")
|
||||
private String templateVersion;
|
||||
|
||||
@Column(name="scripts_version")
|
||||
private String scriptsVersion;
|
||||
|
||||
public DomainRouterVO(long id,
|
||||
long serviceOfferingId,
|
||||
String name,
|
||||
|
|
@ -227,4 +233,20 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
|
|||
public void setStopPending(boolean stopPending) {
|
||||
this.stopPending = stopPending;
|
||||
}
|
||||
|
||||
public String getTemplateVersion() {
|
||||
return this.templateVersion;
|
||||
}
|
||||
|
||||
public void setTemplateVersion(String templateVersion) {
|
||||
this.templateVersion = templateVersion;
|
||||
}
|
||||
|
||||
public String getScriptsVersion() {
|
||||
return this.scriptsVersion;
|
||||
}
|
||||
|
||||
public void setScriptsVersion(String scriptsVersion) {
|
||||
this.scriptsVersion = scriptsVersion;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ import com.cloud.agent.api.BumpUpPriorityCommand;
|
|||
import com.cloud.agent.api.CheckRouterAnswer;
|
||||
import com.cloud.agent.api.CheckRouterCommand;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.GetDomRVersionAnswer;
|
||||
import com.cloud.agent.api.GetDomRVersionCmd;
|
||||
import com.cloud.agent.api.ModifySshKeysCommand;
|
||||
import com.cloud.agent.api.NetworkUsageAnswer;
|
||||
import com.cloud.agent.api.NetworkUsageCommand;
|
||||
|
|
@ -1670,16 +1672,33 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
s_logger.debug("Reapplying vm data (userData and metaData) entries as a part of domR " + router + " start...");
|
||||
createVmDataCommands(router, cmds);
|
||||
|
||||
// Update router template/scripts version
|
||||
final GetDomRVersionCmd command = new GetDomRVersionCmd();
|
||||
command.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress());
|
||||
command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
|
||||
cmds.addCommand("getDomRVersion", command);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean finalizeStart(VirtualMachineProfile<DomainRouterVO> profile, long hostId, Commands cmds, ReservationContext context) {
|
||||
DomainRouterVO router = profile.getVirtualMachine();
|
||||
|
||||
CheckSshAnswer answer = (CheckSshAnswer) cmds.getAnswer("checkSsh");
|
||||
if (answer == null || !answer.getResult()) {
|
||||
s_logger.warn("Unable to ssh to the VM: " + answer.getDetails());
|
||||
return false;
|
||||
}
|
||||
|
||||
GetDomRVersionAnswer versionAnswer = (GetDomRVersionAnswer) cmds.getAnswer("getDomRVersion");
|
||||
if (answer == null || !answer.getResult()) {
|
||||
s_logger.warn("Unable to get the template/scripts version of router " + router.getInstanceName() + " due to: " + versionAnswer.getDetails() + ", but we would continue");
|
||||
return true;
|
||||
}
|
||||
router.setTemplateVersion(versionAnswer.getTemplateVersion());
|
||||
router.setScriptsVersion(versionAnswer.getScriptsVersion());
|
||||
router = _routerDao.persist(router);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -944,6 +944,8 @@ CREATE TABLE `cloud`.`domain_router` (
|
|||
`redundant_state` varchar(64) NOT NULL COMMENT 'the state of redundant virtual router',
|
||||
`stop_pending` int(1) unsigned NOT NULL COMMENT 'if this router would be stopped after we can connect to it',
|
||||
`role` varchar(64) NOT NULL COMMENT 'type of role played by this router',
|
||||
`template_version` varchar(100) COMMENT 'template version',
|
||||
`scripts_version` varchar(100) COMMENT 'scripts version',
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_domain_router__id` FOREIGN KEY `fk_domain_router__id` (`id`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8 COMMENT = 'information about the domR instance';
|
||||
|
|
|
|||
|
|
@ -90,3 +90,6 @@ INSERT IGNORE INTO configuration VALUES ('Advanced', 'DEFAULT', 'management-serv
|
|||
INSERT IGNORE INTO configuration VALUES ('Advanced', 'DEFAULT', 'management-server', 'project.invite.timeout', '86400', 'Invitation expiration time (in seconds). Default is 1 day - 86400 seconds');
|
||||
|
||||
|
||||
ALTER TABLE `cloud`.`domain_router` ADD COLUMN `template_version` varchar(100) COMMENT 'template version' AFTER role;
|
||||
ALTER TABLE `cloud`.`domain_router` ADD COLUMN `scripts_version` varchar(100) COMMENT 'scripts version' AFTER template_version;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue