public VMInstance asVM() { if (!isVM()) { throw new IllegalStateException("Unable to cast an plain external component instance to a VM instance"); } return (VMInstance) this; }
public VMInstanceGroup onlyVMs() { final VMInstanceGroup selected = new VMInstanceGroup(); for (ExternalComponentInstance<? extends ExternalComponent> instance: this) { if (instance.isVM()) { selected.add(instance.asVM()); } } return selected; }
public VMInstanceGroup onlyVMs() { final VMInstanceGroup selection = new VMInstanceGroup(); for (final T instance: this) { if (instance.isExternal()) { final ExternalComponentInstance<? extends ExternalComponent> external = instance.asExternal(); if (external.isVM()) { selection.add(external.asVM()); } } } return selection; }
/** * Extract the tag that can be identified on the given component instance. * * @param componentInstance the component whose tags are needed * @param tagged the already initialised maps of tags, to be filled in */ private void extractTags(ComponentInstance componentInstance, Map<String, List<String>> tagged) { assert componentInstance != null: "Unable to extract tags from 'null'"; assert !tagged.isEmpty(): "The map of tag must have been initialized"; if (componentInstance.isExternal()) { tagged.get(EXTERNAL.getLabel()).add(componentInstance.getName()); if (componentInstance.asExternal().isVM()) { tagged.get(VM.getLabel()).add(componentInstance.getName()); } } if (componentInstance.isInternal()) { tagged.get(INTERNAL.getLabel()).add(componentInstance.getName()); } if (isService(componentInstance)) { tagged.get(SERVICE.getLabel()).add(componentInstance.getName()); } else { tagged.get(NOT_SERVICE.getLabel()).add(componentInstance.getName()); } }
for(Property p : c.getProperties()){ if(p.getName().startsWith("env:")){ if(c.getHost().asExternal().isVM()){ prepareSetEnv(d,c,p);
private Boolean isPaaS2PaaS(RelationshipInstance bi){ if(bi.getRequiredEnd().getOwner().get().isInternal()){ if(bi.getProvidedEnd().getOwner().get().isInternal()){ if(!bi.getRequiredEnd().getOwner().get().asInternal().externalHost().isVM() && !bi.getProvidedEnd().getOwner().get().asInternal().externalHost().isVM()){ return true; } } } return false; }
public String toString(){ String result=" Component instances:\n"; for(ComponentInstance c: components){ if(c.isExternal()){ if(c.asExternal().isVM()){ result+=" VM-> "+c.asExternal().asVM().getId()+"::"+c.getName()+"\n"; }else{ result+=" External component-> "+c.getQualifiedName()+"\n"; } }else{ result+=" Instance component-> "+c.getQualifiedName()+"\n"; } } return result; } }
/** * For each component, execute the puppet manifest associated * @param components */ private void configureWithPuppet(ComponentInstanceGroup<InternalComponentInstance> components){ unlessNotNull("Cannot configure null!", components); Connector jc; for (InternalComponentInstance ic : components) { if(ic.externalHost().isVM()){ for(Resource r: ic.getType().getResources()){ if(r instanceof PuppetResource){ PuppetResource pr=(PuppetResource)r; if(!pr.getConfigurationFile().isEmpty()){ journal.log(Level.INFO, ">> Using Puppet to configure the following component: "+ic.getName()); VMInstance n= ic.getHost().asExternal().asVM(); Provider p = n.getType().getProvider(); managePuppet(pr,n, pr.getName(),pr.getConfigurationFile()); } } } } } }
public Deployment scaleOut(ExternalComponentInstance eci, Provider provider){ if(eci.isVM()){ scaleOut(eci.asVM(),provider); return currentModel; }else{ Deployment targetModel=cloneCurrentModel(); ExternalComponentInstance eci2=targetModel.getComponentInstances().onlyExternals().firstNamed(eci.getName()); ExternalComponent ec=eci2.getType().asExternal(); ec.setProvider(provider); eci2.setStatus(ComponentInstance.State.STOPPED); dep.deploy(targetModel); return targetModel; } }
if (!alreadyDeployed.contains(instance) && (instance.getRequiredExecutionPlatform() != null)) { ExternalComponentInstance host = instance.externalHost(); if (host.isVM()) { VMInstance ownerVM = host.asVM(); VM n = ownerVM.getType();
if (bi.getRequiredEnd().getType().isMandatory() && x.getRequiredPorts().contains(bi.getRequiredEnd())) { final ComponentInstance<? extends Component> serverComponent = bi.getServerComponent(); if( getDestination(serverComponent).isVM()){ VMInstance owner = (VMInstance) getDestination(serverComponent); if (owner == null) {