@Override
public void executeTransaction(EntityManager em) throws Exception {
OSCEntityManager<SecurityGroup> sgEmgr = new OSCEntityManager<SecurityGroup>(SecurityGroup.class, em, this.txBroadcastUtil);
this.securityGroup = sgEmgr.findByPrimaryKey(this.securityGroup.getId());
this.log.info("Validating the Security Group project " + this.securityGroup.getProjectName() + " exists.");
try (Openstack4jKeystone keystone = new Openstack4jKeystone(new Endpoint(this.securityGroup.getVirtualizationConnector()))) {
Project project = keystone.getProjectById(this.securityGroup.getProjectId());
if (project == null) {
this.log.info("Security Group project " + this.securityGroup.getProjectName() + " Deleted from openstack. Marking Security Group for deletion.");
// project was deleted, mark Security Group for deleting as well
OSCEntityManager.markDeleted(em, this.securityGroup, this.txBroadcastUtil);
} else {
// Sync the project name if needed
if (!project.getName().equals(this.securityGroup.getProjectName())) {
this.log.info("Security Group project name updated from " + this.securityGroup.getProjectName() + " to " + project.getName());
this.securityGroup.setProjectName(project.getName());
OSCEntityManager.update(em, this.securityGroup, this.txBroadcastUtil);
}
}
}
}
ValidateSecurityGroupProjectTask.java 文件源码
java
阅读 37
收藏 0
点赞 0
评论 0
项目:osc-core
作者:
评论列表
文章目录