本文整理了Java中io.cattle.platform.core.model.Account.getProjectTemplateId()
方法的一些代码示例,展示了Account.getProjectTemplateId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Account.getProjectTemplateId()
方法的具体详情如下:
包路径:io.cattle.platform.core.model.Account
类名称:Account
方法名:getProjectTemplateId
[英]Getter for cattle.account.project_template_id
.
[中]cattle.account.project_template_id
的Getter。
代码示例来源:origin: rancher/cattle
protected void assignTemplate(final Account env) {
if (env.getProjectTemplateId() != null) {
return;
}
final ProjectTemplate template = objectManager.findAny(ProjectTemplate.class,
PROJECT_TEMPLATE.IS_PUBLIC, true,
PROJECT_TEMPLATE.REMOVED, null,
PROJECT_TEMPLATE.NAME, CatalogService.DEFAULT_TEMPLATE.get());
if (template == null) {
throw new IllegalStateException("Failed to find default template for upgrade");
}
DeferredUtils.nest(new Runnable() {
@Override
public void run() {
systemStackTrigger.trigger(env.getId());
objectManager.setFields(env, ACCOUNT.PROJECT_TEMPLATE_ID, template.getId());
}
});
}
代码示例来源:origin: rancher/cattle
@Override
public HandlerResult handle(ProcessState state, ProcessInstance process) {
Account account = (Account)state.getResource();
if (account.getProjectTemplateId() != null || !AccountConstants.PROJECT_KIND.equals(account.getKind())) {
return null;
}
if (StringUtils.isBlank(DEFAULT_TEMPLATE.get())) {
return null;
}
ProjectTemplate template = objectManager.findAny(ProjectTemplate.class,
PROJECT_TEMPLATE.NAME, DEFAULT_TEMPLATE.get(),
PROJECT_TEMPLATE.IS_PUBLIC, true,
PROJECT_TEMPLATE.REMOVED, null);
return new HandlerResult(
ACCOUNT.PROJECT_TEMPLATE_ID, template == null ? null : template.getId());
}
代码示例来源:origin: rancher/cattle
public List<Long> createStacks(Account account) throws IOException {
List<Long> createdStackIds = DataAccessor.fieldLongList(account, AccountConstants.FIELD_CREATED_STACKS);
if (!createdStackIds.isEmpty()) {
return createdStackIds;
}
ProjectTemplate projectTemplate = objectManager.loadResource(ProjectTemplate.class, account.getProjectTemplateId());
if (projectTemplate == null) {
return Collections.emptyList();
}
List<CatalogTemplate> templates = DataAccessor.fieldObjectList(projectTemplate, ProjectTemplateConstants.FIELD_STACKS,
CatalogTemplate.class, jsonMapper);
Map<String, CatalogTemplate> templatesById = catalogService.resolvedExternalIds(templates);
createdStackIds = new ArrayList<>();
boolean executorRunning = false;
for (Map.Entry<String, CatalogTemplate> entry : templatesById.entrySet()) {
String externalId = entry.getKey();
Stack stack = objectManager.findAny(Stack.class,
STACK.ACCOUNT_ID, account.getId(),
STACK.EXTERNAL_ID, externalId,
STACK.REMOVED, null);
if (stack == null) {
executorRunning = waitForExecutor(executorRunning);
stack = catalogService.deploy(account.getId(), entry.getValue());
}
createdStackIds.add(stack.getId());
}
objectManager.reload(account);
objectManager.setFields(account, AccountConstants.FIELD_CREATED_STACKS, createdStackIds);
return createdStackIds;
}
代码示例来源:origin: rancher/cattle
@Override
public HandlerResult handle(ProcessState state, ProcessInstance process) {
ProjectTemplate template = (ProjectTemplate)state.getResource();
if (!Boolean.TRUE.equals(template.getIsPublic()) ||
!CatalogService.DEFAULT_TEMPLATE.get().equalsIgnoreCase(template.getName())) {
return null;
}
sampleDataStartupV3.start();
Account defaultProject = getDefaultProject();
if (defaultProject == null || defaultProject.getProjectTemplateId() != null) {
return null;
}
if (!AccountConstants.ACCOUNT_VERSION.get().equals(defaultProject.getVersion())) {
return null;
}
Long projectTemplateId = defaultProject.getProjectTemplateId();
if (projectTemplateId == null) {
projectTemplateId = template.getId();
}
systemStackTrigger.trigger(defaultProject.getId());
objectManager.setFields(defaultProject,
ACCOUNT.PROJECT_TEMPLATE_ID, projectTemplateId);
return null;
}
代码示例来源:origin: rancher/cattle
@Override
public Object create(String type, ApiRequest request, ResourceManager next) {
Account account = request.proxyRequestObject(Account.class);
ProjectTemplate template = objectManager.loadResource(ProjectTemplate.class, account.getProjectTemplateId());
if (template == null) {
return super.create(type, request, next);
}
List<CatalogTemplate> templates = DataAccessor.fieldObjectList(template, ProjectTemplateConstants.FIELD_STACKS, CatalogTemplate.class, jsonMapper);
if (templates == null) {
return super.create(type, request, next);
}
List<String> ids = new ArrayList<>();
for (CatalogTemplate catalogTemplate : templates) {
String id = catalogTemplate.getTemplateVersionId();
if (StringUtils.isBlank(id)) {
id = catalogTemplate.getTemplateId();
}
if (StringUtils.isNotBlank(id)) {
ids.add(id);
}
}
Map<String, Object> input = CollectionUtils.toMap(request.getRequestObject());
input.put(AccountConstants.FIELD_ORCHESTRATION, SystemStackUpdate.chooseOrchestration(ids));
return super.create(type, request, next);
}
代码示例来源:origin: rancher/cattle
/**
* {@inheritDoc}
*/
@Override
public void from(io.cattle.platform.core.model.Account from) {
setId(from.getId());
setName(from.getName());
setKind(from.getKind());
setUuid(from.getUuid());
setDescription(from.getDescription());
setState(from.getState());
setCreated(from.getCreated());
setRemoved(from.getRemoved());
setRemoveTime(from.getRemoveTime());
setData(from.getData());
setExternalId(from.getExternalId());
setExternalIdType(from.getExternalIdType());
setHealthState(from.getHealthState());
setProjectTemplateId(from.getProjectTemplateId());
setDefaultNetworkId(from.getDefaultNetworkId());
setVersion(from.getVersion());
setRevision(from.getRevision());
}
内容来源于网络,如有侵权,请联系作者删除!