Updated smart deployment tab, CelarOpDeployApplication and
CelarizedFetch
Removed initial number of component's instances
Signed-off-by: Stalo Sofokleous <stalosof@cs.ucy.ac.cy>
diff --git a/plugins/org.eclipse.camf.connectors.celar/META-INF/MANIFEST.MF b/plugins/org.eclipse.camf.connectors.celar/META-INF/MANIFEST.MF
index 5322c09..6d1fc52 100644
--- a/plugins/org.eclipse.camf.connectors.celar/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.camf.connectors.celar/META-INF/MANIFEST.MF
@@ -13,6 +13,7 @@
org.eclipse.camf.core.model,
org.eclipse.camf.core.model.impl,
org.eclipse.camf.core.reporting,
+ org.eclipse.camf.infosystem.model.base,
org.eclipse.camf.tosca,
org.eclipse.camf.tosca.core,
org.eclipse.camf.tosca.editor,
diff --git a/plugins/org.eclipse.camf.connectors.celar/src/org/eclipse/camf/connectors/celar/operation/AbstractCelarOpDeployApplication.java b/plugins/org.eclipse.camf.connectors.celar/src/org/eclipse/camf/connectors/celar/operation/AbstractCelarOpDeployApplication.java
new file mode 100644
index 0000000..6d777dc
--- /dev/null
+++ b/plugins/org.eclipse.camf.connectors.celar/src/org/eclipse/camf/connectors/celar/operation/AbstractCelarOpDeployApplication.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Laboratory for Internet Computing, University of Cyprus.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Initial development of the original code was made for the
+ * CELAR project founded by European Union
+ * project number: FP7-317790 http://www.celarcloud.eu
+ *
+ * Contributors:
+ * Stalo Sofokleous - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.camf.connectors.celar.operation;
+
+import org.eclipse.camf.connectors.celar.operation.IOperation;
+
+
+public abstract class AbstractCelarOpDeployApplication implements IOperation {
+
+ /** Any exception which came up during the inquiry. */
+ private Exception exception;
+
+ private Object result;
+
+ /* (non-Javadoc)
+ * @see java.lang.Runnable#run()
+ */
+ @Override
+ abstract public void run();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.camf.connectors.celar.operation.IOperation#getResult()
+ */
+ @Override
+ public Object getResult() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.camf.connectors.celar.operation.IOperation#getException()
+ */
+ @Override
+ public Exception getException() {
+ // TODO Auto-generated method stub
+ return this.exception;
+ }
+
+ protected void setException( final Exception ex ) {
+ this.exception = ex;
+ }
+
+ protected void setResult (final Object result) {
+ this.result = result;
+ }
+}
diff --git a/plugins/org.eclipse.camf.connectors.celar/src/org/eclipse/camf/connectors/celar/operation/CelarOpDeployApplication.java b/plugins/org.eclipse.camf.connectors.celar/src/org/eclipse/camf/connectors/celar/operation/CelarOpDeployApplication.java
new file mode 100644
index 0000000..6b67335
--- /dev/null
+++ b/plugins/org.eclipse.camf.connectors.celar/src/org/eclipse/camf/connectors/celar/operation/CelarOpDeployApplication.java
@@ -0,0 +1,1077 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Laboratory for Internet Computing, University of Cyprus.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Initial development of the original code was made for the
+ * CELAR project founded by European Union
+ * project number: FP7-317790 http://www.celarcloud.eu
+ *
+ * Contributors:
+ * Stalo Sofokleous - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.camf.connectors.celar.operation;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+//import org.apache.http.HttpEntity;
+//import org.apache.http.HttpResponse;
+//import org.apache.http.client.ClientProtocolException;
+//import org.apache.http.client.HttpClient;
+//import org.apache.http.client.methods.HttpPost;
+//import org.apache.http.entity.mime.MultipartEntity;
+//import org.apache.http.entity.mime.content.FileBody;
+//import org.apache.http.impl.client.DefaultHttpClient;
+//import org.apache.http.util.EntityUtils;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.camf.core.Preferences;
+import org.eclipse.camf.core.model.impl.GenericCloudProvider;
+import org.eclipse.camf.core.model.CloudModel;
+import org.eclipse.camf.core.model.ICloudDeploymentService;
+import org.eclipse.camf.core.model.ICloudElement;
+import org.eclipse.camf.core.model.ICloudProject;
+import org.eclipse.camf.core.model.ICloudProvider;
+import org.eclipse.camf.core.model.ICloudProviderManager;
+import org.eclipse.camf.core.reporting.ProblemException;
+import org.eclipse.camf.tosca.DocumentRoot;
+import org.eclipse.camf.tosca.core.TOSCAModel;
+import org.eclipse.camf.tosca.core.TOSCAResource;
+import org.eclipse.camf.tosca.editor.ToscaDiagramEditor;
+import org.eclipse.camf.tosca.elasticity.ServicePropertiesType;
+
+import org.eclipse.ui.browser.IWebBrowser;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleManager;
+import org.eclipse.ui.console.MessageConsole;
+import org.eclipse.ui.console.MessageConsoleStream;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * Main class that gathers the necessary elements from the TOSCA description and
+ * makes the deployment to the OpenStack provider
+ */
+public class CelarOpDeployApplication extends AbstractCelarOpDeployApplication {
+
+ private final TOSCAResource toscaResource;
+ private final ICloudProject project;
+
+ private TOSCAModel toscaModel;
+ private File csar;
+ private IFile deploymentIFile;
+ private ArrayList<String> zipEntries = new ArrayList<String>();
+ private ArrayList<String> selectedProvidersNames = new ArrayList<String>();
+ private ArrayList<ICloudProvider> selectedProviders = new ArrayList<ICloudProvider>();
+
+ public CelarOpDeployApplication(final TOSCAResource tosca) {
+ this.toscaResource = tosca;
+ this.project = this.toscaResource.getProject();
+
+ this.toscaModel = this.toscaResource.getTOSCAModel();
+ IResource resourceName = this.toscaResource.getResource();
+ this.deploymentIFile = (IFile) resourceName;
+
+ ServicePropertiesType serviceProperties = ( ServicePropertiesType )this.toscaModel.getDocumentRoot()
+ .getDefinitions()
+ .getServiceTemplate()
+ .get( 0 )
+ .getBoundaryDefinitions()
+ .getProperties()
+ .getAny()
+ .get( 0 )
+ .getValue();
+ for( String providerName : serviceProperties.getHostingEnvironment() ) {
+ this.selectedProvidersNames.add( providerName );
+ }
+ // final ICloudProviderManager manager =
+ // CloudModel.getCloudProviderManager();
+ ICloudElement[] providers = null;
+ providers = Preferences.getDefinedCloudProviders();
+ // try {
+ // providers = manager.getChildren( null );
+ // } catch( ProblemException e ) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+ for( String providerName : this.selectedProvidersNames ) {
+ for( ICloudElement provider : providers ) {
+ if( providerName.compareTo( ( ( ICloudProvider )provider ).getName() ) == 0 )
+ {
+ this.selectedProviders.add( ( ICloudProvider )provider );
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.camf.connectors.celar.operation.AbstractCelarOpDeployApplication
+ * #run()
+ */
+
+ @Override
+ public void run() {
+ setResult(null);
+ setException(null);
+ try {
+ // set Start time of the deployment
+ String start_time = new SimpleDateFormat("dd/M/yyyy hh:mm:ss")
+ .format(Calendar.getInstance().getTime());
+
+ } catch (Exception ex) {
+ this.setException(ex);
+ ex.printStackTrace();
+ }
+ // Export CSAR file
+ try {
+ exportCSAR();
+ } catch( IOException e1 ) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch( CoreException e1 ) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ openISbrowser();
+ MessageConsole myConsole = findConsole( "MyConsole" );
+ MessageConsoleStream out = myConsole.newMessageStream();
+ out.println( "Starting deployment procedure..." );
+ for( ICloudProvider selectedProvider : this.selectedProviders ) {
+ GenericCloudProvider provider = ( GenericCloudProvider )selectedProvider;
+ String uri = provider.getUri();
+ if( uri != null ) {
+ if( uri.endsWith( "/" ) ) {
+ uri = uri.substring( 0, uri.length() - 1 );
+ }
+ } else {
+ continue;
+ }
+ String port = provider.getPort();
+ if( port != null ) {
+ if( port.endsWith( "/" ) ) {
+ port = port.substring( 0, port.length() - 1 );
+ }
+ uri = uri + ":" + port;
+ }
+ String applicationId = describeApplication( uri );
+ // String applicationId = describeApplicationHttps(uri);
+ String deploymentId = null;
+ if( applicationId != null ) {
+ deploymentId = deployApplication( uri, applicationId );
+ // deploymentId = deployApplicationHttps(uri, applicationId);
+ }
+ if( deploymentId != null ) {
+ // getDeploymentState(uri, deploymentId);
+ // terminateDeployment(uri, deploymentId);
+ }
+ }
+ }
+
+ public Object getResult() {
+ return null;
+ }
+
+ public void exportCSAR() throws IOException, CoreException {
+ // Export monitoring probes to jar files
+ // IWorkspaceRoot workspaceRoot =
+ // ResourcesPlugin.getWorkspace().getRoot();
+ // IProject monitoringProbesProject = workspaceRoot.getProject(
+ // "MonitoringProbe" );
+ // IFolder srcFolder = monitoringProbesProject.getFolder( "src" );
+ // IResource[] monitoringProbes = srcFolder.members();
+ // for( IResource monitoringProbeFile : monitoringProbes )
+ // exportProbe( ( IFile )monitoringProbeFile );
+
+ // Create CSAR
+ String csarName = this.toscaResource.getName();
+ this.csar = new File(
+ System.getProperty("user.home") + System.getProperty("file.separator") + "Desktop" + System.getProperty("file.separator") + csarName.replace("tosca", "csar")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ FileOutputStream fos = new FileOutputStream(csar);
+ ZipOutputStream zos = new ZipOutputStream(fos);
+ // File names
+ String metaFile = "TOSCA.meta"; //$NON-NLS-1$
+ String defFileName = "Application.tosca"; //$NON-NLS-1$
+ String keyFileName = "celar.pub"; //$NON-NLS-1$
+ // Create dummy TOSCA meta
+ addToCSARFile(
+ "TOSCA-Metadata", metaFile, getMetaContent(defFileName), zos); //$NON-NLS-1$
+ // Create Valid TOSCA
+ // DocumentRoot toscaDescription = toscaModel.getDocumentRoot();
+ // addToCSARFile( "Definitions", defFileName, convertToXml( toscaDescription ), zos ); //$NON-NLS-1$
+ addToCSARFile(
+ "Definitions", defFileName, getFileContents(this.deploymentIFile), zos); //$NON-NLS-1$
+ // Create a dummy SSH public key-pair file
+ addToCSARFile("Keys", keyFileName, getKeyPair(), zos); //$NON-NLS-1$
+ IProject activeProject = null;
+
+ ICloudProject cloudProject = this.toscaResource.getProject();
+ activeProject = (IProject) cloudProject.getResource();
+
+ // IProject activeProject = ToscaDiagramEditor.getActiveProject();
+ IFolder scriptsFolder = activeProject
+ .getFolder(new Path(
+ System.getProperty("file.separator") + "Artifacts" + System.getProperty("file.separator") + "Deployment Scripts")); //$NON-NLS-1$ //$NON-NLS-2$
+ IResource[] scriptFiles = scriptsFolder.members();
+ for (IResource resource : scriptFiles) {
+ IFile tempFile = (IFile) resource;
+ String fileName = tempFile.getName();
+ if (this.zipEntries.contains(fileName)) {
+ System.out.println("zip entry exists");
+ } else {
+ this.zipEntries.add(fileName);
+ String content = getFileContents(tempFile);
+ addToCSARFile("Scripts", fileName, content, zos); //$NON-NLS-1$
+ }
+ }
+ IFolder resizingScriptsFolder = activeProject
+ .getFolder(new Path(
+ System.getProperty("file.separator") + "Artifacts" + System.getProperty("file.separator") + "Reconfiguration Scripts")); //$NON-NLS-1$ //$NON-NLS-2$
+ scriptFiles = resizingScriptsFolder.members();
+ for (IResource resource : scriptFiles) {
+ IFile tempFile = (IFile) resource;
+ String fileName = tempFile.getName();
+ if (this.zipEntries.contains(fileName)) {
+ System.out.println("zip entry exists");
+ } else {
+ String content = getFileContents(tempFile);
+ addToCSARFile("Scripts", fileName, content, zos); //$NON-NLS-1$
+ }
+ }
+ addToCSARFile(
+ "TUW",
+ "CompositionRules",
+ getFileFromGit(
+ "https://raw.githubusercontent.com/CELAR/c-Eclipse/master/pom.xml",
+ "pom.xml"), zos);
+ zos.close();
+ fos.close();
+ }
+
+ private static String getFileContents(IFile file) {
+ InputStream in = null;
+ try {
+ in = file.getContents();
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ InputStreamReader is = new InputStreamReader(in);
+ StringBuilder sb = new StringBuilder();
+ BufferedReader br = new BufferedReader(is);
+ String read;
+ try {
+ read = br.readLine();
+ while (read != null) {
+ sb.append(read);
+ sb.append(System.getProperty("line.separator"));
+ read = br.readLine();
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return sb.toString();
+ }
+
+ private static String getKeyPair() {
+ return "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCn3TzXwzRDtoPRUyRm784Wwa61EhhEd7rvr9qrLVjNvvCv/JP80sgE43LzxlEx7uiHEbzhhQdVHvTozTA2WEzyhVfYEhDhqt5xVl2Xf0skbAc3qLP42hguYXZ7NPtCUEUbQqN0Oo4WafUo4sRG+FNIu+nO66DbZEcmRBv3YYtcOw== AWS-RSA-1024"; //$NON-NLS-1$
+ }
+
+ void exportProbe(IFile file) throws IOException {
+ IProject activeProject = ToscaDiagramEditor.getActiveProject();
+ IFolder monitoringFolder = activeProject.getFolder("Monitoring"); //$NON-NLS-1$
+ IPath jarFilePath = monitoringFolder.getRawLocation()
+ .append(file.getName()).removeFileExtension()
+ .addFileExtension("jar"); //$NON-NLS-1$
+ byte buffer[] = new byte[10240];
+ // Open archive file
+ FileOutputStream stream = new FileOutputStream(jarFilePath.toString());
+ JarOutputStream out = new JarOutputStream(stream, new Manifest());
+ // Add probe file archive entry
+ JarEntry jarAdd = new JarEntry(file.getName());
+ out.putNextEntry(jarAdd);
+ // Write file to archive
+ FileInputStream in = new FileInputStream(file.getRawLocation()
+ .toString());
+ while (true) {
+ int nRead = in.read(buffer, 0, buffer.length);
+ if (nRead <= 0)
+ break;
+ out.write(buffer, 0, nRead);
+ }
+ in.close();
+ out.closeEntry();
+ // Add ProbePack.jar file archive entry
+ jarAdd = new JarEntry("ProbePack.jar"); //$NON-NLS-1$
+ out.putNextEntry(jarAdd);
+ // Write file to archive
+ in = new FileInputStream(
+ "C:\\Users\\stalo.cs8526\\Desktop\\ProbePack.jar"); //$NON-NLS-1$
+ while (true) {
+ int nRead = in.read(buffer, 0, buffer.length);
+ if (nRead <= 0)
+ break;
+ out.write(buffer, 0, nRead);
+ }
+ in.close();
+ out.closeEntry();
+ out.close();
+ stream.close();
+ // Refresh Cloud Model
+ IProgressMonitor monitor = null;
+ try {
+ CloudModel.getRoot().refresh(monitor);
+ } catch (ProblemException e2) {
+ e2.printStackTrace();
+ }
+ }
+
+ private boolean isRedirected(Map<String, List<String>> header) {
+ for (String hv : header.get(null)) {
+ if (hv.contains(" 301 ") || hv.contains(" 302 "))
+ return true;
+ }
+ return false;
+ }
+
+ private String getFileFromGit(String link, String fileName)
+ throws IOException {
+ URL url = new URL(link);
+ HttpURLConnection http = (HttpURLConnection) url.openConnection();
+ Map<String, List<String>> header = http.getHeaderFields();
+ while (isRedirected(header)) {
+ link = header.get("Location").get(0);
+ url = new URL(link);
+ http = (HttpURLConnection) url.openConnection();
+ header = http.getHeaderFields();
+ }
+ InputStream input = http.getInputStream();
+ String fileContents = "";
+ BufferedReader in = new BufferedReader(new InputStreamReader(input));
+ String inputLine;
+ while ((inputLine = in.readLine()) != null) {
+ fileContents = fileContents + inputLine
+ + System.getProperty("line.separator");
+ // System.out.println(inputLine);
+ }
+ in.close();
+ return fileContents;
+ }
+
+ /**
+ * @param dir
+ * @param fileName
+ * @param content
+ * @param zos
+ * @throws FileNotFoundException
+ * @throws IOException
+ */
+ public void addToCSARFile(final String dir, final String fileName,
+ final String content, final ZipOutputStream zos)
+ throws FileNotFoundException, IOException {
+ String tmpDir = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator"); //$NON-NLS-1$
+ File file = new File(tmpDir + fileName);
+ if (!file.exists()) {
+ file.createNewFile();
+ }
+ FileOutputStream fos = new FileOutputStream(file);
+ byte[] contentInBytes = content.getBytes();
+ fos.write(contentInBytes);
+ fos.flush();
+ fos.close();
+ FileInputStream fis = new FileInputStream(file);
+ // ZipEntry zipEntry = new ZipEntry( dir + "/" + fileName );
+ ZipEntry zipEntry = new ZipEntry(dir
+ + System.getProperty("file.separator") + fileName);
+ zos.putNextEntry(zipEntry);
+ byte[] bytes = new byte[1024];
+ int length;
+ while ((length = fis.read(bytes)) >= 0) {
+ zos.write(bytes, 0, length);
+ }
+ zos.closeEntry();
+ fis.close();
+ }
+
+ /**
+ * @param defFile
+ * @return Meta Content
+ */
+ public static String getMetaContent(String defFile) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("TOSCA-Meta-Version: 1.0\n"); //$NON-NLS-1$
+ sb.append("CSAR-Version: 1.0\n"); //$NON-NLS-1$
+ sb.append("Created-By: c-Eclipse\n\n"); //$NON-NLS-1$
+ sb.append("Name: Definitions" + System.getProperty("file.separator") + defFile + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ sb.append("Content-Type: application/vnd.oasis.tosca.definitions\n"); //$NON-NLS-1$
+ return sb.toString();
+ }
+
+ private MessageConsole findConsole(String name) {
+ ConsolePlugin plugin = ConsolePlugin.getDefault();
+ IConsoleManager conMan = plugin.getConsoleManager();
+ IConsole[] existing = conMan.getConsoles();
+ for (int i = 0; i < existing.length; i++)
+ if (name.equals(existing[i].getName()))
+ return (MessageConsole) existing[i];
+ // no console found, so create a new one
+ MessageConsole myConsole = new MessageConsole(name, null);
+ conMan.addConsoles(new IConsole[] { myConsole });
+ return myConsole;
+ }
+
+ private URLConnection getHttpsConnection(URL url) {
+ // Create a trust manager that does not validate certificate chains
+ TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
+
+ public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+
+ public void checkClientTrusted(X509Certificate[] certs,
+ String authType) {
+ }
+
+ public void checkServerTrusted(X509Certificate[] certs,
+ String authType) {
+ }
+ } };
+ // Install the all-trusting trust manager
+ SSLContext sc = null;
+ try {
+ sc = SSLContext.getInstance("SSL");
+ } catch (NoSuchAlgorithmException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ try {
+ sc.init(null, trustAllCerts, new java.security.SecureRandom());
+ } catch (KeyManagementException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
+ // Create all-trusting host name verifier
+ HostnameVerifier allHostsValid = new HostnameVerifier() {
+
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }
+ };
+ // Install the all-trusting host verifier
+ HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
+ URLConnection connection = null;
+ try {
+ connection = url.openConnection();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return connection;
+ }
+
+ // Call CELAR Manager to submit application description
+ private String describeApplication( String uri ) {
+ URL url = null;
+ HttpURLConnection connection = null;
+ String applicationId = null;
+ try {
+ url = new URL( uri + "/application/describe/" );
+ connection = ( HttpURLConnection )url.openConnection();
+ connection.setDoOutput( true );
+ connection.setDoInput( true );
+ connection.setRequestMethod( "POST" );
+ connection.setRequestProperty( "Content-type", "application/octet-stream" );
+ OutputStream reqStream = connection.getOutputStream();
+ FileInputStream fis = new FileInputStream( this.csar );
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ byte[] buf = new byte[ 1024 ];
+ try {
+ for( int readNum; ( readNum = fis.read( buf ) ) != -1; ) {
+ bos.write( buf, 0, readNum );
+ }
+ } catch( IOException ex ) {
+ ex.printStackTrace();
+ }
+ fis.close();
+ reqStream.write( bos.toByteArray() );
+ int responseCode = connection.getResponseCode();
+ System.out.println( "Response is: " + responseCode );
+ MessageConsole myConsole = findConsole( "MyConsole" );
+ MessageConsoleStream out = myConsole.newMessageStream();
+ out.println( "Describing application: HTTP Response is " + responseCode );
+ InputStream inputStream = connection.getInputStream();
+ // BufferedReader in = new BufferedReader(new
+ // InputStreamReader(inputStream));
+ // String inputLine;
+ // while ((inputLine = in.readLine()) != null) {
+ // System.out.println(inputLine);
+ // }
+ // in.close();
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = null;
+ try {
+ db = dbf.newDocumentBuilder();
+ } catch( ParserConfigurationException e ) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ try {
+ Document doc = db.parse( inputStream );
+ // NodeList nList = doc.getElementsByTagName( "applicationInfo" );
+ NodeList nList = doc.getElementsByTagName( "modules" );
+ for( int i = 0; i < nList.getLength(); i++ ) {
+ Node nNode = nList.item( i );
+ if( nNode.getNodeType() == Node.ELEMENT_NODE ) {
+ Element eElement = ( Element )nNode;
+ // applicationId =
+ // eElement.getElementsByTagName("unique_Id").item(0).getTextContent();
+ applicationId = eElement.getElementsByTagName( "application_Id" )
+ .item( 0 )
+ .getTextContent();
+ break;
+ }
+ }
+ } catch( SAXException e ) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ System.out.println( "Application Id is: " + applicationId );
+ connection.disconnect();
+ } catch( IOException ex ) {
+ ex.printStackTrace();
+ }
+ return applicationId;
+ }
+
+ // Call CELAR Manager to submit application description
+ private String describeApplicationHttps( String uri ) {
+ String applicationId = "";
+ URL url = null;
+ try {
+ url = new URL( uri + "/application/describe/" );
+ } catch( MalformedURLException e1 ) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ URLConnection connection = getHttpsConnection( url );
+ Writer writer = null;
+ try {
+ connection.setDoOutput( true );
+ connection.setDoInput( true );
+ connection.setRequestProperty( "Content-type", "application/octet-stream" );
+ FileInputStream fis = new FileInputStream( this.csar );
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ byte[] buf = new byte[ 1024 ];
+ try {
+ for( int readNum; ( readNum = fis.read( buf ) ) != -1; ) {
+ bos.write( buf, 0, readNum );
+ }
+ } catch( IOException ex ) {
+ ex.printStackTrace();
+ }
+ fis.close();
+ writer = new OutputStreamWriter( connection.getOutputStream() );
+ writer.write( bos.toString() );
+ writer.close();
+ // Get HTTP Response
+ InputStream inputStream = connection.getInputStream();
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = null;
+ try {
+ db = dbf.newDocumentBuilder();
+ } catch( ParserConfigurationException e ) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ try {
+ Document doc = db.parse( inputStream );
+ NodeList nList = doc.getElementsByTagName( "application" );
+ for( int i = 0; i < nList.getLength(); i++ ) {
+ Node nNode = nList.item( i );
+ if( nNode.getNodeType() == Node.ELEMENT_NODE ) {
+ Element eElement = ( Element )nNode;
+ applicationId = eElement.getElementsByTagName( "id" )
+ .item( 0 )
+ .getTextContent();
+ break;
+ }
+ }
+ System.out.println( applicationId );
+ } catch( SAXException e ) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } catch( IOException e ) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return applicationId;
+ }
+
+ // Call CELAR Manager to deploy described application
+ private String deployApplication( String uri, String applicationId ) {
+ URL url = null;
+ HttpURLConnection connection = null;
+ String deploymentId = null;
+ try {
+ url = new URL( uri + "/application/" + applicationId + "/deploy/" );
+ connection = ( HttpURLConnection )url.openConnection();
+ connection.setDoOutput( true );
+ connection.setDoInput( true );
+ connection.setRequestMethod( "POST" );
+ connection.setRequestProperty( "Content-type", "application/octet-stream" );
+ OutputStream reqStream = connection.getOutputStream();
+ FileInputStream fis = new FileInputStream( this.csar );
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ byte[] buf = new byte[ 1024 ];
+ try {
+ for( int readNum; ( readNum = fis.read( buf ) ) != -1; ) {
+ bos.write( buf, 0, readNum );
+ }
+ } catch( IOException ex ) {
+ ex.printStackTrace();
+ }
+ fis.close();
+ reqStream.write( bos.toByteArray() );
+ int responseCode = connection.getResponseCode();
+ System.out.println( "Response is: " + responseCode );
+ MessageConsole myConsole = findConsole( "MyConsole" );
+ MessageConsoleStream out = myConsole.newMessageStream();
+ out.println( "Deploying application: HTTP Response is " + responseCode );
+ InputStream inputStream = connection.getInputStream();
+ // BufferedReader in = new BufferedReader(new
+ // InputStreamReader(inputStream));
+ // String inputLine;
+ // while ((inputLine = in.readLine()) != null) {
+ // System.out.println(inputLine);
+ // }
+ // in.close();
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = null;
+ try {
+ db = dbf.newDocumentBuilder();
+ } catch( ParserConfigurationException e ) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ try {
+ Document doc = db.parse( inputStream );
+ NodeList nList = doc.getElementsByTagName( "modules" );
+ for( int i = 0; i < nList.getLength(); i++ ) {
+ Node nNode = nList.item( i );
+ if( nNode.getNodeType() == Node.ELEMENT_NODE ) {
+ Element eElement = ( Element )nNode;
+ deploymentId = eElement.getElementsByTagName( "id" )
+ .item( 0 )
+ .getTextContent();
+ break;
+ }
+ }
+ } catch( SAXException e ) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ System.out.println( "Deployment Id is: " + deploymentId );
+ connection.disconnect();
+ } catch( IOException ex ) {
+ ex.printStackTrace();
+ }
+ return deploymentId;
+ }
+
+ // Call CELAR Manager to deploy described application
+ private String deployApplicationHttps( String uri, String applicationId ) {
+ String deploymentId = null;
+ URL url = null;
+ try {
+ url = new URL( uri + "/application/" + applicationId + "/deploy/" );
+ } catch( MalformedURLException e1 ) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ URLConnection connection = getHttpsConnection( url );
+ Writer writer = null;
+ try {
+ connection.setDoOutput( true );
+ connection.setDoInput( true );
+ connection.setRequestProperty( "Content-type", "application/octet-stream" );
+ FileInputStream fis = new FileInputStream( this.csar );
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ byte[] buf = new byte[ 1024 ];
+ try {
+ for( int readNum; ( readNum = fis.read( buf ) ) != -1; ) {
+ bos.write( buf, 0, readNum );
+ }
+ } catch( IOException ex ) {
+ ex.printStackTrace();
+ }
+ fis.close();
+ writer = new OutputStreamWriter( connection.getOutputStream() );
+ writer.write( bos.toString() );
+ // Get HTTP Response
+ InputStream inputStream = connection.getInputStream();
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = null;
+ try {
+ db = dbf.newDocumentBuilder();
+ } catch( ParserConfigurationException e ) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ try {
+ Document doc = db.parse( inputStream );
+ NodeList nList = doc.getElementsByTagName( "deployment" );
+ for( int i = 0; i < nList.getLength(); i++ ) {
+ Node nNode = nList.item( i );
+ if( nNode.getNodeType() == Node.ELEMENT_NODE ) {
+ Element eElement = ( Element )nNode;
+ deploymentId = eElement.getElementsByTagName( "deploymentID" )
+ .item( 0 )
+ .getTextContent();
+ break;
+ }
+ }
+ } catch( SAXException e ) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ System.out.println( "Deployment Id is: " + deploymentId );
+ } catch( IOException ex ) {
+ ex.printStackTrace();
+ }
+ return deploymentId;
+ }
+
+ // Get deployment state
+ private boolean getDeploymentState( String uri, String deploymentId ) {
+ URL url = null;
+ HttpURLConnection connection = null;
+ try {
+ url = new URL( uri + "/deployment/" + deploymentId );
+ connection = ( HttpURLConnection )url.openConnection();
+ connection.setDoOutput( false );
+ connection.setDoInput( true );
+ connection.setRequestMethod( "GET" );
+ int responseCode = connection.getResponseCode();
+ System.out.println( "Response is: " + responseCode );
+ MessageConsole myConsole = findConsole( "MyConsole" );
+ MessageConsoleStream out = myConsole.newMessageStream();
+ out.println( "Getting deployment status: HTTP Response is "
+ + responseCode );
+ InputStream inputStream = connection.getInputStream();
+ // BufferedReader in = new BufferedReader(new
+ // InputStreamReader(inputStream));
+ // String inputLine;
+ // while ((inputLine = in.readLine()) != null) {
+ // System.out.println(inputLine);
+ // }
+ // in.close();
+ BufferedReader in = new BufferedReader( new InputStreamReader( inputStream ) );
+ String inputLine;
+ while( ( inputLine = in.readLine() ) != null ) {
+ out.println( inputLine );
+ }
+ in.close();
+ // DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ // DocumentBuilder db = null;
+ // try {
+ // db = dbf.newDocumentBuilder();
+ // } catch( ParserConfigurationException e ) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+ //
+ // try {
+ // Document doc = db.parse(inputStream);
+ // NodeList nList = doc.getElementsByTagName( "deployment" );
+ // for (int i=0; i< nList.getLength(); i++){
+ // Node nNode = nList.item(i);
+ //
+ // if (nNode.getNodeType() == Node.ELEMENT_NODE) {
+ //
+ // Element eElement = (Element) nNode;
+ //
+ // deploymentId =
+ // eElement.getElementsByTagName("deploymentID").item(0).getTextContent();
+ //
+ // break;
+ // }
+ // }
+ // } catch( SAXException e ) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+ //
+ // System.out.println("Deployment Id is: "+deploymentId);
+ connection.disconnect();
+ } catch( IOException ex ) {
+ ex.printStackTrace();
+ }
+ return true;
+ }
+
+ // Get deployment state
+ private boolean getDeploymentStateHttps( String uri, String deploymentId ) {
+ URL url = null;
+ try {
+ url = new URL( uri + "/deployment/" + deploymentId );
+ } catch( MalformedURLException e1 ) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ URLConnection connection = getHttpsConnection( url );
+ try {
+ connection.setDoOutput( false );
+ connection.setDoInput( true );
+ MessageConsole myConsole = findConsole( "MyConsole" );
+ MessageConsoleStream out = myConsole.newMessageStream();
+ out.println( "Getting deployment status: HTTP Response is " );
+ InputStream inputStream = connection.getInputStream();
+ // BufferedReader in = new BufferedReader(new
+ // InputStreamReader(inputStream));
+ // String inputLine;
+ // while ((inputLine = in.readLine()) != null) {
+ // System.out.println(inputLine);
+ // }
+ // in.close();
+ BufferedReader in = new BufferedReader( new InputStreamReader( inputStream ) );
+ String inputLine;
+ while( ( inputLine = in.readLine() ) != null ) {
+ out.println( inputLine );
+ }
+ in.close();
+ // DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ // DocumentBuilder db = null;
+ // try {
+ // db = dbf.newDocumentBuilder();
+ // } catch( ParserConfigurationException e ) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+ //
+ // try {
+ // Document doc = db.parse(inputStream);
+ // NodeList nList = doc.getElementsByTagName( "deployment" );
+ // for (int i=0; i< nList.getLength(); i++){
+ // Node nNode = nList.item(i);
+ //
+ // if (nNode.getNodeType() == Node.ELEMENT_NODE) {
+ //
+ // Element eElement = (Element) nNode;
+ //
+ // deploymentId =
+ // eElement.getElementsByTagName("deploymentID").item(0).getTextContent();
+ //
+ // break;
+ // }
+ // }
+ // } catch( SAXException e ) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+ //
+ // System.out.println("Deployment Id is: "+deploymentId);
+ } catch( IOException ex ) {
+ ex.printStackTrace();
+ }
+ return true;
+ }
+
+ // Terminate deployment
+ private boolean terminateDeployment( String uri, String deploymentId ) {
+ URL url = null;
+ HttpURLConnection connection = null;
+ try {
+ url = new URL( uri + "/deployment/" + deploymentId + "/terminate" );
+ connection = ( HttpURLConnection )url.openConnection();
+ connection.setDoOutput( false );
+ connection.setDoInput( true );
+ connection.setRequestMethod( "GET" );
+ int responseCode = connection.getResponseCode();
+ System.out.println( "Response is: " + responseCode );
+ InputStream inputStream = connection.getInputStream();
+ BufferedReader in = new BufferedReader( new InputStreamReader( inputStream ) );
+ String inputLine;
+ while( ( inputLine = in.readLine() ) != null ) {
+ System.out.println( inputLine );
+ }
+ in.close();
+ // DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ // DocumentBuilder db = null;
+ // try {
+ // db = dbf.newDocumentBuilder();
+ // } catch( ParserConfigurationException e ) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+ //
+ // try {
+ // Document doc = db.parse(inputStream);
+ // NodeList nList = doc.getElementsByTagName( "deployment" );
+ // for (int i=0; i< nList.getLength(); i++){
+ // Node nNode = nList.item(i);
+ //
+ // if (nNode.getNodeType() == Node.ELEMENT_NODE) {
+ //
+ // Element eElement = (Element) nNode;
+ //
+ // deploymentId =
+ // eElement.getElementsByTagName("deploymentID").item(0).getTextContent();
+ //
+ // break;
+ // }
+ // }
+ // } catch( SAXException e ) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+ //
+ // System.out.println("Deployment Id is: "+deploymentId);
+ connection.disconnect();
+ } catch( IOException ex ) {
+ ex.printStackTrace();
+ }
+ return true;
+ }
+
+ // Terminate deployment
+ private boolean terminateDeploymentHttps( String uri, String deploymentId ) {
+ URL url = null;
+ try {
+ url = new URL( uri + "/deployment/" + deploymentId + "/terminate" );
+ } catch( MalformedURLException e1 ) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ URLConnection connection = getHttpsConnection( url );
+ try {
+ connection.setDoOutput( false );
+ connection.setDoInput( true );
+ InputStream inputStream = connection.getInputStream();
+ BufferedReader in = new BufferedReader( new InputStreamReader( inputStream ) );
+ String inputLine;
+ while( ( inputLine = in.readLine() ) != null ) {
+ System.out.println( inputLine );
+ }
+ in.close();
+ // DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ // DocumentBuilder db = null;
+ // try {
+ // db = dbf.newDocumentBuilder();
+ // } catch( ParserConfigurationException e ) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+ //
+ // try {
+ // Document doc = db.parse(inputStream);
+ // NodeList nList = doc.getElementsByTagName( "deployment" );
+ // for (int i=0; i< nList.getLength(); i++){
+ // Node nNode = nList.item(i);
+ //
+ // if (nNode.getNodeType() == Node.ELEMENT_NODE) {
+ //
+ // Element eElement = (Element) nNode;
+ //
+ // deploymentId =
+ // eElement.getElementsByTagName("deploymentID").item(0).getTextContent();
+ //
+ // break;
+ // }
+ // }
+ // } catch( SAXException e ) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+ //
+ // System.out.println("Deployment Id is: "+deploymentId);
+ } catch( IOException ex ) {
+ ex.printStackTrace();
+ }
+ return true;
+ }
+
+ // Opens an internal browser displaying the Information System
+ private void openISbrowser() {
+ URL ISbrowser = null;
+ try {
+ ISbrowser = new URL(
+ "http://snf-354013.vm.okeanos.grnet.gr:8080/webFrontend/application/version/deployment/?deplID=9876&tab=monitoring"); //$NON-NLS-1$
+ } catch (MalformedURLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ IWebBrowser browser;
+ try {
+ browser = PlatformUI.getWorkbench().getBrowserSupport()
+ .createBrowser("id"); //$NON-NLS-1$
+ browser.openURL(ISbrowser);
+ } catch (PartInitException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.camf.connectors.celar/src/org/eclipse/camf/connectors/celar/operation/IOperation.java b/plugins/org.eclipse.camf.connectors.celar/src/org/eclipse/camf/connectors/celar/operation/IOperation.java
new file mode 100644
index 0000000..1cb7f8a
--- /dev/null
+++ b/plugins/org.eclipse.camf.connectors.celar/src/org/eclipse/camf/connectors/celar/operation/IOperation.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Laboratory for Internet Computing, University of Cyprus.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Initial development of the original code was made for the
+ * CELAR project founded by European Union
+ * project number: FP7-317790 http://www.celarcloud.eu
+ *
+ * Contributors:
+ * Stalo Sofokleous - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.camf.connectors.celar.operation;
+
+
+public interface IOperation extends Runnable {
+
+ /**
+ * Returns the result of the operation executed in the {@link Runnable#run()}
+ * method of this {@link IOperation}.
+ *
+ * @return the result of the operation or <code>null</code> if an error
+ * occurred
+ */
+ public Object getResult();
+
+ /**
+ * Returns any exception which came up during the execution of the
+ * {@link Runnable#run()} method.
+ *
+ * @return the exception which might have come up or <code>null</code> if no
+ * error occurred
+ */
+ public Exception getException();
+}
diff --git a/plugins/org.eclipse.camf.infosystem.mockup/src/org/eclipse/camf/infosystem/mockup/info/CelarizedFetch.java b/plugins/org.eclipse.camf.infosystem.mockup/src/org/eclipse/camf/infosystem/mockup/info/CelarizedFetch.java
index c817f15..d328be3 100644
--- a/plugins/org.eclipse.camf.infosystem.mockup/src/org/eclipse/camf/infosystem/mockup/info/CelarizedFetch.java
+++ b/plugins/org.eclipse.camf.infosystem.mockup/src/org/eclipse/camf/infosystem/mockup/info/CelarizedFetch.java
@@ -12,6 +12,7 @@
*
* Contributors:
* Stalo Sofokleous - initial API and implementation
+ * Nicholas Loulloudes - initial API and implementation
*******************************************************************************/
import java.io.BufferedReader;
import java.io.IOException;
@@ -68,12 +69,11 @@
public class CelarizedFetch extends Job {
+
private Connection con = null;
private static CelarizedFetch instance = null;
-
- private ArrayList<ICloudProvider> selectedProviders = new ArrayList<ICloudProvider>();
-
+
private ArrayList<VirtualMachineImage> base_images = new ArrayList<VirtualMachineImage>();
private ArrayList<MonitoringProbe> monitor_probes = new ArrayList<MonitoringProbe>();
private ArrayList<ResizingAction> resize_actions = new ArrayList<ResizingAction>();
@@ -498,7 +498,8 @@
}
- }
+
+}
diff --git a/plugins/org.eclipse.camf.infosystem.mockup/src/org/eclipse/camf/infosystem/mockup/info/FetchJob.java b/plugins/org.eclipse.camf.infosystem.mockup/src/org/eclipse/camf/infosystem/mockup/info/FetchJob.java
deleted file mode 100644
index fd6cc75..0000000
--- a/plugins/org.eclipse.camf.infosystem.mockup/src/org/eclipse/camf/infosystem/mockup/info/FetchJob.java
+++ /dev/null
@@ -1,611 +0,0 @@
-package org.eclipse.camf.infosystem.mockup.info;
-/*******************************************************************************
- * Copyright (c) 2014 Laboratory for Internet Computing, University of Cyprus.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial development of the original code was made for the
- * CELAR project founded by European Union
- * project number: FP7-317790 http://www.celarcloud.eu
- *
- * Contributors:
- * Nicholas Loulloudes - initial API and implementation
- *******************************************************************************/
-
-
-
-
-
-//package org.eclipse.camf.infosystem.mockup.info;
-//
-//import java.io.BufferedReader;
-//import java.io.IOException;
-//import java.io.InputStreamReader;
-//import java.net.HttpURLConnection;
-//import java.net.MalformedURLException;
-//import java.net.URL;
-//import java.sql.Connection;
-//import java.sql.DriverManager;
-//import java.sql.ResultSet;
-//import java.sql.SQLException;
-//import java.sql.Statement;
-//import java.util.ArrayList;
-//import java.util.HashMap;
-//import java.util.Iterator;
-//import java.util.Map;
-//import java.util.Set;
-//
-//import org.eclipse.core.runtime.IProgressMonitor;
-//import org.eclipse.core.runtime.IStatus;
-//import org.eclipse.core.runtime.NullProgressMonitor;
-//import org.eclipse.core.runtime.Status;
-//import org.eclipse.core.runtime.SubProgressMonitor;
-//import org.eclipse.core.runtime.jobs.Job;
-//import org.eclipse.ui.console.ConsolePlugin;
-//import org.eclipse.ui.console.IConsole;
-//import org.eclipse.ui.console.IConsoleManager;
-//import org.eclipse.ui.console.MessageConsole;
-//
-//import org.eclipse.camf.infosystem.model.base.InfoSystemFactory;
-//import org.eclipse.camf.infosystem.model.base.MonitoringProbe;
-//import org.eclipse.camf.infosystem.model.base.ResizingAction;
-//import org.eclipse.camf.infosystem.model.base.SoftwareDependency;
-//import org.eclipse.camf.infosystem.model.base.UserApplication;
-//import org.eclipse.camf.infosystem.model.base.VirtualMachineImage;
-//import org.eclipse.camf.infosystem.model.base.VirtualMachineImageFlavor;
-//import org.eclipse.camf.infosystem.model.base.VirtualMachineImageType;
-//
-//
-///**
-// * @authors Nicholas Loulloudes, Stalo Sofokleous
-// *
-// */
-//public class FetchJob extends Job {
-//
-// private Connection con = null;
-//
-// private static FetchJob instance = null;
-//
-// private ArrayList<VirtualMachineImage> base_images = new ArrayList<VirtualMachineImage>();
-// private ArrayList<MonitoringProbe> monitor_probes = new ArrayList<MonitoringProbe>();
-// private ArrayList<ResizingAction> resize_actions = new ArrayList<ResizingAction>();
-// private ArrayList<VirtualMachineImageFlavor> vm_flavors = new ArrayList<VirtualMachineImageFlavor>();
-//
-// /**
-// * @param name
-// */
-// private FetchJob( final String name ) {
-// super( name );
-// }
-//
-// /**
-// * Get a singleton instance of FetchJob
-// * @param name the name that will be displayed in the progress view
-// * @return a FetchJob
-// */
-// public static FetchJob getInstance (final String name) {
-// if (instance == null) {
-// instance = new FetchJob( name );
-// }
-// return instance;
-// }
-//
-// @Override
-// protected IStatus run( final IProgressMonitor monitor ) {
-//
-// IProgressMonitor localMonitor
-// = ( monitor != null )
-// ? monitor
-// : new NullProgressMonitor();
-//
-// localMonitor.beginTask( "Retrieving information", 6 * 10 ); //$NON-NLS-1$
-//
-// //createStaticCelarDB();
-//
-// try {
-// try {
-// fetchBaseMachineImages( localMonitor );
-// fetchMonitorProbes( localMonitor );
-// fetchResizingActions (localMonitor );
-// fetchFlavors ( localMonitor );
-// } catch( JSONException e ) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-//
-// } catch( SQLException e ) {
-// e.printStackTrace();
-// } finally {
-// if (this.con != null) {
-// try {
-// this.con.close();
-// } catch( SQLException e ) {
-// e.printStackTrace();
-// }
-// }
-// }
-//
-//
-// localMonitor.done();
-// Status status = new Status( IStatus.OK,
-// "org.eclipse.camf.infosystem", //$NON-NLS-1$
-// "Information data fetched successfully." ); //$NON-NLS-1$
-// return status;
-// }
-//
-//
-//
-// private void fetchBaseMachineImages (final IProgressMonitor monitor) throws SQLException, JSONException {
-//
-//
-// //CELAR Manager call : Get VM Images
-// String celarManagerURL = "http://83.212.107.38:8080/resources/";
-// URL url = null;
-// HttpURLConnection connection = null;
-// BufferedReader in = null;
-// String inputLine = null;
-//
-// String images = "";
-// try {
-// url = new URL (celarManagerURL + "images/");
-//
-// connection = (HttpURLConnection) url.openConnection();
-// connection.setDoInput( true );
-// connection.setRequestProperty("Accept", "application/json");
-// connection.setRequestMethod( "GET" );
-//
-// in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
-// while ((inputLine = in.readLine()) != null) {
-// images = images + inputLine;
-// }
-// in.close();
-// System.out.println(images);
-//
-// connection.disconnect();
-// } catch( MalformedURLException e ) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// } catch( IOException e ) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-//
-// //Okeanos Images
-// images = "[{\"id\":\"5ed5a29b-292c-4fe0-b32c-2e2b65628635\",\"name\":\"Ubuntu 12.04.1 LTS\"},{\"id\":\"b4713f20-3a41-4eaf-81ae-88698c18b3e8\",\"name\":\"Archlinux base install 2012.12.01\"},{\"id\":\"5583fed1-5273-4c64-9e32-3fbe476bd7b7\",\"name\":\"Ubuntu 12.04.2 LTS\"},{\"id\":\"917ee618-c03a-4473-9024-9448e12890c1\",\"name\":\"Ubuntu 10.04.4 LTS\"},{\"id\":\"e5a74e94-890b-44cc-8951-0786eeef7140\",\"name\":\"BackTrack5R3 w/ SSH & Correct Locale\"},{\"id\":\"c9e811fa-39a9-4d13-8a6f-9102105801cb\",\"name\":\"Kali Linux 1.0 - Former BackTrack5R3 (with update option)\"},{\"id\":\"90554939-41c9-42e6-b654-1e167743c950\",\"name\":\"Ubuntu 12.10\"},{\"id\":\"505dcadb-d978-4f2b-ba68-02fc69fb50a8\",\"name\":\"Ubuntu 12.10\"},{\"id\":\"9f82e379-b111-4f72-8fbf-4fb37aa5ccc9\",\"name\":\"Backtrack 5 R3 Gnome i386\"},{\"id\":\"c9f3980d-6a82-4121-b24e-d7b5f29a4a00\",\"name\":\"03/10/2013\"},{\"id\":\"0f12a5e0-5369-4bed-abd6-5b03d87cc5da\",\"name\":\"Ubuntu 12.04.3 LTS\"},{\"id\":\"545d36df-53da-46bd-86ed-759ac3eb1995\",\"name\":\"Ubuntu server 13.04\"},{\"id\":\"e9ec7d24-96a1-412d-8e05-569bac5744a4\",\"name\":\"Scientific Linux SL release 5.5 (Boron)\"},{\"id\":\"01a4b2f1-2acd-4031-8801-3d94ebe3f4d4\",\"name\":\"Ubuntu 13.04\"},{\"id\":\"8ff7d98a-9beb-46d2-8977-39b29443a7b2\",\"name\":\"Ubuntu 13.04\"},{\"id\":\"b26866dd-4626-4c12-85e3-9435048dd8a7\",\"name\":\"Ubuntu 13.04\"},{\"id\":\"493e78e9-f469-4a71-abea-4d50db71f535\",\"name\":\"Ubuntu 13.04\"},{\"id\":\"0e399015-8723-4c78-8198-75bdf693cdde\",\"name\":\"CKAN 2.1 base installation on a debian 7.1 system\"},{\"id\":\"4a65772b-98fd-43b3-b3b9-cd083849e63b\",\"name\":\"unknown\"},{\"id\":\"83c4c2d5-50b4-4400-b95d-3d10a760e8d6\",\"name\":\"Ubuntu 12.04.3 Base install no Gui\"},{\"id\":\"d0ae1af2-eac0-453e-bb2e-720b10a2e2d4\",\"name\":\"Ubuntu 12.04.3 LTS no gui\"},{\"id\":\"890d0d9c-f9f6-4643-bc9d-f6eb387573a1\",\"name\":\"Openfiler 2.99\"},{\"id\":\"ca446474-a846-45ab-b8b9-7bcd41e7c905\",\"name\":\"Mageia 3\"},{\"id\":\"2953ee6f-7dac-4173-9c13-19a0b87162f9\",\"name\":\"Xubuntu 13.10\"},{\"id\":\"09ff8272-3018-422f-a91f-386615ef0fb2\",\"name\":\"Windows Server 2012 Datacenter\"},{\"id\":\"f00b0d29-62f4-46db-a78e-370d596fc553\",\"name\":\"okeanos-is-on-centos\"},{\"id\":\"726090b4-00d2-4f44-bb32-83429181bee3\",\"name\":\"Mininet on Ubuntu 13.04\"},{\"id\":\"f0ebd2e4-1a27-450e-8c83-e8d350c0dc24\",\"name\":\"Mininet on Ubuntu 13.04\"},{\"id\":\"88e185c5-fd22-452a-943d-de230d4a3be9\",\"name\":\"Mininet 2.1.0 for NetMan 2014 lab\"},{\"id\":\"2da09920-20c1-4f48-ac04-e5e18029ca0c\",\"name\":\"FreeBSD 9.2-RELEASE (GENERIC)\"},{\"id\":\"749b641d-46cc-4abe-9ff2-76d745b9214d\",\"name\":\"Ubuntu 13.04\"},{\"id\":\"0099593e-4f6d-48bf-8f03-0cec7fabb05b\",\"name\":\"Master clone\"},{\"id\":\"69e7c17c-a9c9-48aa-809a-9cb5d477abda\",\"name\":\"Windows Server 2008 R2 Datacenter\"},{\"id\":\"91302edf-5d32-4048-9982-475a466ce37e\",\"name\":\"Oracle Linux Server release 6.5\"},{\"id\":\"78e96a57-2436-45c8-96b5-5eda9eb69be9\",\"name\":\"Debian 7.4 (Wheezy) Base System\"},{\"id\":\"da7a80e3-1b5a-4052-8e34-50dab2e8c9df\",\"name\":\"Debian 6.0.9 (Squeeze) Base System\"},{\"id\":\"5bffb7a0-c362-4d45-b5db-56082749ca29\",\"name\":\"Debian 7.4 (Wheezy) Desktop\"},{\"id\":\"48644f1e-4faa-45d9-9ae7-be6b0f51c063\",\"name\":\"Fedora release 20 (Heisenbug)\"},{\"id\":\"bb9cca86-1a97-4323-aa7d-bcaf792aea14\",\"name\":\"openSUSE 13.1 (x86_64)\"},{\"id\":\"cbba7cad-9945-4af3-9f5a-3a2f83067422\",\"name\":\"NetBSD 6.1.4 (GENERIC)\"},{\"id\":\"f6db8d72-1ddc-4272-889b-a51ab1d0b5a2\",\"name\":\"Ubuntu 12.04 with collection of software needed by HMMY courses\"},{\"id\":\"3ea05769-7ec3-4795-bf18-67a2cbd6a07f\",\"name\":\"user@gmail.com\"},{\"id\":\"87de7f36-a22d-4249-9fba-aff4ed95fecd\",\"name\":\"20140505\"},{\"id\":\"fc1ed744-ae05-469a-a5b9-e561428ec0e0\",\"name\":\"Ubuntu 14.04 LTS\"},{\"id\":\"2e3ca7b7-eee6-40bc-a363-14ac4b3d5231\",\"name\":\"Ubuntu 12.04.4 LTS\"},{\"id\":\"bbcb5050-11ef-4a9d-8035-7afc9cb88a69\",\"name\":\"Ubuntu 14.04 LTS with MATE\"},{\"id\":\"1890becc-f706-48b3-9dbb-9a8941f737d4\",\"name\":\"Ubuntu 12.04.4 LTS\"},{\"id\":\"cfaece0c-d886-491e-b2a1-e35e5df277b5\",\"name\":\"Kubuntu 12.04.4 LTS\"},{\"id\":\"f4f4d102-ec25-4d67-90f3-1d2754f9bdec\",\"name\":\"Kubuntu 14.04 LTS\"},{\"id\":\"2e16ea31-e7f4-48f1-87f7-b3e15cc2d701\",\"name\":\"OpenBSD 5.5 (GENERIC)\"},{\"id\":\"5a235e31-8e3c-4ea6-bb11-3e73d3fdd79e\",\"name\":\"Windows Server 2012 R2 Datacenter\"},{\"id\":\"1966f2b4-be70-4d69-874f-bb76e9aa0313\",\"name\":\"Contains all the software for AristeiaUoM\"},{\"id\":\"64a65ad6-c4ef-4052-bc19-67480815219e\",\"name\":\"Ubuntu 12.04.4 LTS\"},{\"id\":\"5042d1cb-3f0a-436c-be71-beafda1d86f3\",\"name\":\"Lubuntu 14.04 LTS\"},{\"id\":\"34da7d52-ea8b-441c-bea1-cc0a684e1cd8\",\"name\":\"ArchLinux 2014.06.21 w/ openssh and iptables setup - Accepting only PubKeyAuth\"},{\"id\":\"b5340ff7-9eb2-4fb4-aa92-d33aecfca6f8\",\"name\":\"Oracle Linux 5.10\"},{\"id\":\"430c24b4-5c75-4d38-88a9-eb95cebe27f8\",\"name\":\"7.3\"},{\"id\":\"433b0442-4314-4f6f-8893-0e29b1ca0d75\",\"name\":\"Ubuntu 14.04 LTS Mate, with preinstall software, xrdp connection and web server configured\"}]";
-//
-// if ( images.equals( "" ) == false ) {
-//
-// images = "{\"images\":" + images + "}";
-// String output_json = images;
-// JSONObject obj = new JSONObject( output_json );
-// JSONArray images_array = obj.getJSONArray( "images" ); //$NON-NLS-1$
-//
-// if ( images_array != null ){
-// for (int i=0; i < images_array.length(); i++){
-// VirtualMachineImage vmi = InfoSystemFactory.eINSTANCE.createVirtualMachineImage();
-// /*
-// * get the necessary vmi fields
-// */
-//
-// vmi.setDescription( "h" );
-// vmi.setURL( "h" );
-//
-// vmi.setUID( images_array.getJSONObject( i ).getString( "name" ) );
-// vmi.setName( images_array.getJSONObject( i ).getString( "name" )); //$NON-NLS-1$ );
-//
-// vmi.setType( VirtualMachineImageType.BASE_IMAGE );
-//
-// //add new vmi to images list
-// instance.base_images.add( vmi );
-// }
-// }
-// }
-// }
-//
-//
-// //fetch JCatascopiaProbes
-// private void fetchMonitorProbes (final IProgressMonitor monitor) throws SQLException, JSONException {
-//
-// //JCatascopia metrics
-// String probes = "{\"probes\":[{\"metricID\":\"286cc7eff6df400f8121f3b16a8dd884:bytesSent\",\"name\":\"avgResponseTime\",\"units\":\"ms\",\"type\":\"LONG\",\"group\":\"HAProxy\"}, {\"metricID\":\"286cc7eff6df400f8121f3b16a8dd884:bytesSent\",\"name\":\"bytesSent\",\"units\":\"Bytes\",\"type\":\"LONG\",\"group\":\"Tomcat\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:memFree\",\"name\":\"memFree\",\"units\":\"KB\",\"type\":\"INTEGER\",\"group\":\"Memory\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:arch\",\"name\":\"arch\",\"units\":\"\",\"type\":\"STRING\",\"group\":\"StaticInfo\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:memTotal\",\"name\":\"memTotal\",\"units\":\"KB\",\"type\":\"INTEGER\",\"group\":\"Memory\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:cpuTotal\",\"name\":\"cpuTotal\",\"units\":\"%\",\"type\":\"DOUBLE\",\"group\":\"CPU\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:memCache\",\"name\":\"memCache\",\"units\":\"KB\",\"type\":\"INTEGER\",\"group\":\"Memory\"},{\"metricID\":\"286cc7eff6df400f8121f3b16a8dd884:requestThroughput\",\"name\":\"requestThroughput\",\"units\":\"req/s\",\"type\":\"DOUBLE\",\"group\":\"Tomcat\"},{\"metricID\":\"286cc7eff6df400f8121f3b16a8dd884:maxThreads\",\"name\":\"maxThreads\",\"units\":\"\",\"type\":\"LONG\",\"group\":\"Tomcat\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:netPacketsOut\",\"name\":\"netPacketsOut\",\"units\":\"packets/s\",\"type\":\"DOUBLE\",\"group\":\"Network\"},{\"metricID\":\"286cc7eff6df400f8121f3b16a8dd884:errorCount\",\"name\":\"errorCount\",\"units\":\"\",\"type\":\"LONG\",\"group\":\"Tomcat\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:netBytesIN\",\"name\":\"netBytesIN\",\"units\":\"bytes/s\",\"type\":\"DOUBLE\",\"group\":\"Network\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:diskUsed\",\"name\":\"diskUsed\",\"units\":\"%\",\"type\":\"DOUBLE\",\"group\":\"Disk\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:cpuIdle\",\"name\":\"cpuIdle\",\"units\":\"%\",\"type\":\"DOUBLE\",\"group\":\"CPU\"},{\"metricID\":\"b9ba52a9826e4c48b1976fdecdc592ab:currentSessions\",\"name\":\"currentSessions\",\"units\":\"\",\"type\":\"INTEGER\",\"group\":\"HAProxy\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:cpuIOwait\",\"name\":\"cpuIOwait\",\"units\":\"%\",\"type\":\"DOUBLE\",\"group\":\"CPU\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:memSwapFree\",\"name\":\"memSwapFree\",\"units\":\"KB\",\"type\":\"INTEGER\",\"group\":\"Memory\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:cpuUser\",\"name\":\"cpuUser\",\"units\":\"%\",\"type\":\"DOUBLE\",\"group\":\"CPU\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:diskTotal\",\"name\":\"diskTotal\",\"units\":\"MB\",\"type\":\"LONG\",\"group\":\"Disk\"},{\"metricID\":\"b9ba52a9826e4c48b1976fdecdc592ab:servers\",\"name\":\"servers\",\"units\":\"\",\"type\":\"INTEGER\",\"group\":\"HAProxy\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:iotime\",\"name\":\"iotime\",\"units\":\"%\",\"type\":\"DOUBLE\",\"group\":\"DiskStats\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:memUsed\",\"name\":\"memUsed\",\"units\":\"KB\",\"type\":\"INTEGER\",\"group\":\"Memory\"},{\"metricID\":\"286cc7eff6df400f8121f3b16a8dd884:requestCount\",\"name\":\"requestCount\",\"units\":\"\",\"type\":\"LONG\",\"group\":\"Tomcat\"},{\"metricID\":\"286cc7eff6df400f8121f3b16a8dd884:currentThreadCount\",\"name\":\"currentThreadCount\",\"units\":\"\",\"type\":\"LONG\",\"group\":\"Tomcat\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:memUsedPercent\",\"name\":\"memUsedPercent\",\"units\":\"%\",\"type\":\"DOUBLE\",\"group\":\"Memory\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:os\",\"name\":\"os\",\"units\":\"\",\"type\":\"STRING\",\"group\":\"StaticInfo\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:netPacketsIN\",\"name\":\"netPacketsIN\",\"units\":\"packets/s\",\"type\":\"DOUBLE\",\"group\":\"Network\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:cpuNum\",\"name\":\"cpuNum\",\"units\":\"\",\"type\":\"STRING\",\"group\":\"StaticInfo\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:cpuSystem\",\"name\":\"cpuSystem\",\"units\":\"%\",\"type\":\"DOUBLE\",\"group\":\"CPU\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:btime\",\"name\":\"btime\",\"units\":\"\",\"type\":\"STRING\",\"group\":\"StaticInfo\"},{\"metricID\":\"286cc7eff6df400f8121f3b16a8dd884:processingTime\",\"name\":\"processingTime\",\"units\":\"\",\"type\":\"LONG\",\"group\":\"Tomcat\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:memSwapTotal\",\"name\":\"memSwapTotal\",\"units\":\"KB\",\"type\":\"INTEGER\",\"group\":\"Memory\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:readkbps\",\"name\":\"readkbps\",\"units\":\"KB/s\",\"type\":\"DOUBLE\",\"group\":\"DiskStats\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:diskFree\",\"name\":\"diskFree\",\"units\":\"MB\",\"type\":\"LONG\",\"group\":\"Disk\"},{\"metricID\":\"286cc7eff6df400f8121f3b16a8dd884:currentThreadsBusy\",\"name\":\"currentThreadsBusy\",\"units\":\"\",\"type\":\"LONG\",\"group\":\"Tomcat\"},{\"metricID\":\"286cc7eff6df400f8121f3b16a8dd884:bytesReceived\",\"name\":\"bytesReceived\",\"units\":\"Bytes\",\"type\":\"LONG\",\"group\":\"Tomcat\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:writekbps\",\"name\":\"writekbps\",\"units\":\"KB/s\",\"type\":\"DOUBLE\",\"group\":\"DiskStats\"},{\"metricID\":\"912a98a72d0f47bc8768779a182ece60:netBytesOUT\",\"name\":\"netBytesOUT\",\"units\":\"bytes/s\",\"type\":\"DOUBLE\",\"group\":\"Network\"}]}";
-// String output_json = probes;
-// JSONObject obj = new JSONObject( output_json );
-// JSONArray probes_array = obj.getJSONArray( "probes" ); //$NON-NLS-1$
-//
-// String probeGroup = null;
-// String metricName;
-// HashMap<String, String> hm = new HashMap<String, String>();
-//
-// for (int i=0; i < probes_array.length(); i++){
-// probeGroup = probes_array.getJSONObject( i ).getString( "group" );
-// metricName = probes_array.getJSONObject(i).getString( "name" );
-//
-// String value = hm.get( probeGroup );
-//
-// if (value != null)
-// metricName = value + ", \"" + metricName + "\"";
-// else
-// metricName = "\"" + metricName + "\"";
-//
-// hm.put( probeGroup, metricName );
-// }
-//
-// // Get a set of the entries
-// Set set = hm.entrySet();
-// // Get an iterator
-// Iterator i = set.iterator();
-// // Display elements
-// while(i.hasNext()) {
-// Map.Entry me = (Map.Entry)i.next();
-// String key = me.getKey().toString();
-// String value = me.getValue().toString().replace( "\"null,", "" );
-//
-// hm.put( key, value );
-// System.out.print(me.getKey() + ": ");
-// System.out.println(me.getValue());
-// }
-//
-// // Get a set of the entries
-// set = hm.entrySet();
-// // Get an iterator
-// i = set.iterator();
-// // Display elements
-// while(i.hasNext()) {
-// Map.Entry me = (Map.Entry)i.next();
-// String key = me.getKey().toString();
-// String value = me.getValue().toString();
-//
-// MonitoringProbe mp = InfoSystemFactory.eINSTANCE.createMonitoringProbe();
-//
-// mp.setName( key ); //$NON-NLS-1$ );
-// mp.setDescription( "[" + value + "]" );
-//
-//
-// //add new monitor probe to probes list
-// instance.monitor_probes.add( mp );
-// }
-//
-// MonitoringProbe mp = InfoSystemFactory.eINSTANCE.createMonitoringProbe();
-//
-// mp.setName( "QueueLength" ); //$NON-NLS-1$ );
-// mp.setDescription( "[ \"q1Length\" , \"q2Length\", \"q3Length\", \"q4Length\" , \"q5Length\" , \"q6Length\", \"q7Length\", \"q8Length\"]" );
-//
-//
-// //add new monitor probe to probes list
-// instance.monitor_probes.add( mp );
-//
-// MonitoringProbe mpWR = InfoSystemFactory.eINSTANCE.createMonitoringProbe();
-//
-// mpWR.setName( "WorkRate" ); //$NON-NLS-1$ );
-// mpWR.setDescription( "[ \"w1Rate\" , \"w2Rate\", \"w3Rate\", \"w4Rate\" , \"w5Rate\" , \"w6Rate\", \"w7Rate\", \"w8Rate\"]" );
-//
-//
-// //add new monitor probe to probes list
-// instance.monitor_probes.add( mpWR );
-//
-//
-//
-// }
-//
-//
-// private void fetchFlavors (final IProgressMonitor monitor) throws SQLException, JSONException {
-//
-//
-// //CELAR Manager call : Get VM Images
-// String celarManagerURL = "http://83.212.107.38:8080/resources/";
-// URL url = null;
-// HttpURLConnection connection = null;
-// BufferedReader in = null;
-// String inputLine = null;
-//
-// String flavors = "";
-// try {
-// url = new URL (celarManagerURL + "flavors/");
-//
-// connection = (HttpURLConnection) url.openConnection();
-// connection.setDoInput( true );
-// connection.setRequestProperty("Accept", "application/json");
-// connection.setRequestMethod( "GET" );
-//
-// in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
-// while ((inputLine = in.readLine()) != null) {
-// flavors = flavors + inputLine;
-// }
-// in.close();
-// System.out.println(flavors);
-//
-// connection.disconnect();
-// } catch( MalformedURLException e ) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// } catch( IOException e ) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-//
-// //Okeanos Flavors
-// flavors = "[{\"id\":\"1\",\"name\":\"C1R1024D20drbd\"},{\"id\":\"3\",\"name\":\"C1R1024D40drbd\"},{\"id\":\"4\",\"name\":\"C1R2048D20drbd\"},{\"id\":\"6\",\"name\":\"C1R2048D40drbd\"},{\"id\":\"7\",\"name\":\"C1R4096D20drbd\"},{\"id\":\"9\",\"name\":\"C1R4096D40drbd\"},{\"id\":\"10\",\"name\":\"C2R1024D20drbd\"},{\"id\":\"12\",\"name\":\"C2R1024D40drbd\"},{\"id\":\"13\",\"name\":\"C2R2048D20drbd\"},{\"id\":\"15\",\"name\":\"C2R2048D40drbd\"},{\"id\":\"16\",\"name\":\"C2R4096D20drbd\"},{\"id\":\"18\",\"name\":\"C2R4096D40drbd\"},{\"id\":\"19\",\"name\":\"C4R1024D20drbd\"},{\"id\":\"21\",\"name\":\"C4R1024D40drbd\"},{\"id\":\"22\",\"name\":\"C4R2048D20drbd\"},{\"id\":\"24\",\"name\":\"C4R2048D40drbd\"},{\"id\":\"25\",\"name\":\"C4R4096D20drbd\"},{\"id\":\"27\",\"name\":\"C4R4096D40drbd\"},{\"id\":\"28\",\"name\":\"C1R1024D5drbd\"},{\"id\":\"29\",\"name\":\"C1R1024D10drbd\"},{\"id\":\"30\",\"name\":\"C1R2048D5drbd\"},{\"id\":\"31\",\"name\":\"C1R2048D10drbd\"},{\"id\":\"32\",\"name\":\"C1R4096D5drbd\"},{\"id\":\"33\",\"name\":\"C1R4096D10drbd\"},{\"id\":\"34\",\"name\":\"C2R1024D5drbd\"},{\"id\":\"35\",\"name\":\"C2R1024D10drbd\"},{\"id\":\"36\",\"name\":\"C2R2048D5drbd\"},{\"id\":\"37\",\"name\":\"C2R2048D10drbd\"},{\"id\":\"38\",\"name\":\"C2R4096D5drbd\"},{\"id\":\"39\",\"name\":\"C2R4096D10drbd\"},{\"id\":\"40\",\"name\":\"C4R1024D5drbd\"},{\"id\":\"41\",\"name\":\"C4R1024D10drbd\"},{\"id\":\"42\",\"name\":\"C4R2048D5drbd\"},{\"id\":\"43\",\"name\":\"C4R2048D10drbd\"},{\"id\":\"44\",\"name\":\"C4R4096D5drbd\"},{\"id\":\"45\",\"name\":\"C4R4096D10drbd\"},{\"id\":\"46\",\"name\":\"C1R512D5drbd\"},{\"id\":\"47\",\"name\":\"C1R512D10drbd\"},{\"id\":\"48\",\"name\":\"C1R512D20drbd\"},{\"id\":\"49\",\"name\":\"C1R512D40drbd\"},{\"id\":\"50\",\"name\":\"C1R512D60drbd\"},{\"id\":\"51\",\"name\":\"C1R512D80drbd\"},{\"id\":\"52\",\"name\":\"C1R512D100drbd\"},{\"id\":\"53\",\"name\":\"C1R1024D60drbd\"},{\"id\":\"54\",\"name\":\"C1R1024D80drbd\"},{\"id\":\"55\",\"name\":\"C1R1024D100drbd\"},{\"id\":\"56\",\"name\":\"C1R2048D60drbd\"},{\"id\":\"57\",\"name\":\"C1R2048D80drbd\"},{\"id\":\"58\",\"name\":\"C1R2048D100drbd\"},{\"id\":\"59\",\"name\":\"C1R4096D60drbd\"},{\"id\":\"60\",\"name\":\"C1R4096D80drbd\"},{\"id\":\"61\",\"name\":\"C1R4096D100drbd\"},{\"id\":\"62\",\"name\":\"C1R8192D5drbd\"},{\"id\":\"63\",\"name\":\"C1R8192D10drbd\"},{\"id\":\"64\",\"name\":\"C1R8192D20drbd\"},{\"id\":\"65\",\"name\":\"C1R8192D40drbd\"},{\"id\":\"66\",\"name\":\"C1R8192D60drbd\"},{\"id\":\"67\",\"name\":\"C1R8192D80drbd\"},{\"id\":\"68\",\"name\":\"C1R8192D100drbd\"},{\"id\":\"69\",\"name\":\"C2R512D5drbd\"},{\"id\":\"70\",\"name\":\"C2R512D10drbd\"},{\"id\":\"71\",\"name\":\"C2R512D20drbd\"},{\"id\":\"72\",\"name\":\"C2R512D40drbd\"},{\"id\":\"73\",\"name\":\"C2R512D60drbd\"},{\"id\":\"74\",\"name\":\"C2R512D80drbd\"},{\"id\":\"75\",\"name\":\"C2R512D100drbd\"},{\"id\":\"76\",\"name\":\"C2R1024D60drbd\"},{\"id\":\"77\",\"name\":\"C2R1024D80drbd\"},{\"id\":\"78\",\"name\":\"C2R1024D100drbd\"},{\"id\":\"79\",\"name\":\"C2R2048D60drbd\"},{\"id\":\"80\",\"name\":\"C2R2048D80drbd\"},{\"id\":\"81\",\"name\":\"C2R2048D100drbd\"},{\"id\":\"82\",\"name\":\"C2R4096D60drbd\"},{\"id\":\"83\",\"name\":\"C2R4096D80drbd\"},{\"id\":\"84\",\"name\":\"C2R4096D100drbd\"},{\"id\":\"85\",\"name\":\"C2R8192D5drbd\"},{\"id\":\"86\",\"name\":\"C2R8192D10drbd\"},{\"id\":\"87\",\"name\":\"C2R8192D20drbd\"},{\"id\":\"88\",\"name\":\"C2R8192D40drbd\"},{\"id\":\"89\",\"name\":\"C2R8192D60drbd\"},{\"id\":\"90\",\"name\":\"C2R8192D80drbd\"},{\"id\":\"91\",\"name\":\"C2R8192D100drbd\"},{\"id\":\"92\",\"name\":\"C4R512D5drbd\"},{\"id\":\"93\",\"name\":\"C4R512D10drbd\"},{\"id\":\"94\",\"name\":\"C4R512D20drbd\"},{\"id\":\"95\",\"name\":\"C4R512D40drbd\"},{\"id\":\"96\",\"name\":\"C4R512D60drbd\"},{\"id\":\"97\",\"name\":\"C4R512D80drbd\"},{\"id\":\"98\",\"name\":\"C4R512D100drbd\"},{\"id\":\"99\",\"name\":\"C4R1024D60drbd\"},{\"id\":\"100\",\"name\":\"C4R1024D80drbd\"},{\"id\":\"101\",\"name\":\"C4R1024D100drbd\"},{\"id\":\"102\",\"name\":\"C4R2048D60drbd\"},{\"id\":\"103\",\"name\":\"C4R2048D80drbd\"},{\"id\":\"104\",\"name\":\"C4R2048D100drbd\"},{\"id\":\"105\",\"name\":\"C4R4096D60drbd\"},{\"id\":\"106\",\"name\":\"C4R4096D80drbd\"},{\"id\":\"107\",\"name\":\"C4R4096D100drbd\"},{\"id\":\"108\",\"name\":\"C4R8192D5drbd\"},{\"id\":\"109\",\"name\":\"C4R8192D10drbd\"},{\"id\":\"110\",\"name\":\"C4R8192D20drbd\"},{\"id\":\"111\",\"name\":\"C4R8192D40drbd\"},{\"id\":\"112\",\"name\":\"C4R8192D60drbd\"},{\"id\":\"113\",\"name\":\"C4R8192D80drbd\"},{\"id\":\"114\",\"name\":\"C4R8192D100drbd\"},{\"id\":\"115\",\"name\":\"C8R512D5drbd\"},{\"id\":\"116\",\"name\":\"C8R512D10drbd\"},{\"id\":\"117\",\"name\":\"C8R512D20drbd\"},{\"id\":\"118\",\"name\":\"C8R512D40drbd\"},{\"id\":\"119\",\"name\":\"C8R512D60drbd\"},{\"id\":\"120\",\"name\":\"C8R512D80drbd\"},{\"id\":\"121\",\"name\":\"C8R512D100drbd\"},{\"id\":\"122\",\"name\":\"C8R1024D5drbd\"},{\"id\":\"123\",\"name\":\"C8R1024D10drbd\"},{\"id\":\"124\",\"name\":\"C8R1024D20drbd\"},{\"id\":\"125\",\"name\":\"C8R1024D40drbd\"},{\"id\":\"126\",\"name\":\"C8R1024D60drbd\"},{\"id\":\"127\",\"name\":\"C8R1024D80drbd\"},{\"id\":\"128\",\"name\":\"C8R1024D100drbd\"},{\"id\":\"129\",\"name\":\"C8R2048D5drbd\"},{\"id\":\"130\",\"name\":\"C8R2048D10drbd\"},{\"id\":\"131\",\"name\":\"C8R2048D20drbd\"},{\"id\":\"132\",\"name\":\"C8R2048D40drbd\"},{\"id\":\"133\",\"name\":\"C8R2048D60drbd\"},{\"id\":\"134\",\"name\":\"C8R2048D80drbd\"},{\"id\":\"135\",\"name\":\"C8R2048D100drbd\"},{\"id\":\"136\",\"name\":\"C8R4096D5drbd\"},{\"id\":\"137\",\"name\":\"C8R4096D10drbd\"},{\"id\":\"138\",\"name\":\"C8R4096D20drbd\"},{\"id\":\"139\",\"name\":\"C8R4096D40drbd\"},{\"id\":\"140\",\"name\":\"C8R4096D60drbd\"},{\"id\":\"141\",\"name\":\"C8R4096D80drbd\"},{\"id\":\"142\",\"name\":\"C8R4096D100drbd\"},{\"id\":\"143\",\"name\":\"C8R8192D5drbd\"},{\"id\":\"144\",\"name\":\"C8R8192D10drbd\"},{\"id\":\"145\",\"name\":\"C8R8192D20drbd\"},{\"id\":\"146\",\"name\":\"C8R8192D40drbd\"},{\"id\":\"147\",\"name\":\"C8R8192D60drbd\"},{\"id\":\"148\",\"name\":\"C8R8192D80drbd\"},{\"id\":\"149\",\"name\":\"C8R8192D100drbd\"},{\"id\":\"150\",\"name\":\"C1R512D5ext_vlmc\"},{\"id\":\"151\",\"name\":\"C1R512D10ext_vlmc\"},{\"id\":\"152\",\"name\":\"C1R512D20ext_vlmc\"},{\"id\":\"153\",\"name\":\"C1R512D40ext_vlmc\"},{\"id\":\"154\",\"name\":\"C1R512D60ext_vlmc\"},{\"id\":\"155\",\"name\":\"C1R512D80ext_vlmc\"},{\"id\":\"156\",\"name\":\"C1R512D100ext_vlmc\"},{\"id\":\"157\",\"name\":\"C1R1024D5ext_vlmc\"},{\"id\":\"158\",\"name\":\"C1R1024D10ext_vlmc\"},{\"id\":\"159\",\"name\":\"C1R1024D20ext_vlmc\"},{\"id\":\"160\",\"name\":\"C1R1024D40ext_vlmc\"},{\"id\":\"161\",\"name\":\"C1R1024D60ext_vlmc\"},{\"id\":\"162\",\"name\":\"C1R1024D80ext_vlmc\"},{\"id\":\"163\",\"name\":\"C1R1024D100ext_vlmc\"},{\"id\":\"164\",\"name\":\"C1R2048D5ext_vlmc\"},{\"id\":\"165\",\"name\":\"C1R2048D10ext_vlmc\"},{\"id\":\"166\",\"name\":\"C1R2048D20ext_vlmc\"},{\"id\":\"167\",\"name\":\"C1R2048D40ext_vlmc\"},{\"id\":\"168\",\"name\":\"C1R2048D60ext_vlmc\"},{\"id\":\"169\",\"name\":\"C1R2048D80ext_vlmc\"},{\"id\":\"170\",\"name\":\"C1R2048D100ext_vlmc\"},{\"id\":\"171\",\"name\":\"C1R4096D5ext_vlmc\"},{\"id\":\"172\",\"name\":\"C1R4096D10ext_vlmc\"},{\"id\":\"173\",\"name\":\"C1R4096D20ext_vlmc\"},{\"id\":\"174\",\"name\":\"C1R4096D40ext_vlmc\"},{\"id\":\"175\",\"name\":\"C1R4096D60ext_vlmc\"},{\"id\":\"176\",\"name\":\"C1R4096D80ext_vlmc\"},{\"id\":\"177\",\"name\":\"C1R4096D100ext_vlmc\"},{\"id\":\"178\",\"name\":\"C1R8192D5ext_vlmc\"},{\"id\":\"179\",\"name\":\"C1R8192D10ext_vlmc\"},{\"id\":\"180\",\"name\":\"C1R8192D20ext_vlmc\"},{\"id\":\"181\",\"name\":\"C1R8192D40ext_vlmc\"},{\"id\":\"182\",\"name\":\"C1R8192D60ext_vlmc\"},{\"id\":\"183\",\"name\":\"C1R8192D80ext_vlmc\"},{\"id\":\"184\",\"name\":\"C1R8192D100ext_vlmc\"},{\"id\":\"185\",\"name\":\"C2R512D5ext_vlmc\"},{\"id\":\"186\",\"name\":\"C2R512D10ext_vlmc\"},{\"id\":\"187\",\"name\":\"C2R512D20ext_vlmc\"},{\"id\":\"188\",\"name\":\"C2R512D40ext_vlmc\"},{\"id\":\"189\",\"name\":\"C2R512D60ext_vlmc\"},{\"id\":\"190\",\"name\":\"C2R512D80ext_vlmc\"},{\"id\":\"191\",\"name\":\"C2R512D100ext_vlmc\"},{\"id\":\"192\",\"name\":\"C2R1024D5ext_vlmc\"},{\"id\":\"193\",\"name\":\"C2R1024D10ext_vlmc\"},{\"id\":\"194\",\"name\":\"C2R1024D20ext_vlmc\"},{\"id\":\"195\",\"name\":\"C2R1024D40ext_vlmc\"},{\"id\":\"196\",\"name\":\"C2R1024D60ext_vlmc\"},{\"id\":\"197\",\"name\":\"C2R1024D80ext_vlmc\"},{\"id\":\"198\",\"name\":\"C2R1024D100ext_vlmc\"},{\"id\":\"199\",\"name\":\"C2R2048D5ext_vlmc\"},{\"id\":\"200\",\"name\":\"C2R2048D10ext_vlmc\"},{\"id\":\"201\",\"name\":\"C2R2048D20ext_vlmc\"},{\"id\":\"202\",\"name\":\"C2R2048D40ext_vlmc\"},{\"id\":\"203\",\"name\":\"C2R2048D60ext_vlmc\"},{\"id\":\"204\",\"name\":\"C2R2048D80ext_vlmc\"},{\"id\":\"205\",\"name\":\"C2R2048D100ext_vlmc\"},{\"id\":\"206\",\"name\":\"C2R4096D5ext_vlmc\"},{\"id\":\"207\",\"name\":\"C2R4096D10ext_vlmc\"},{\"id\":\"208\",\"name\":\"C2R4096D20ext_vlmc\"},{\"id\":\"209\",\"name\":\"C2R4096D40ext_vlmc\"},{\"id\":\"210\",\"name\":\"C2R4096D60ext_vlmc\"},{\"id\":\"211\",\"name\":\"C2R4096D80ext_vlmc\"},{\"id\":\"212\",\"name\":\"C2R4096D100ext_vlmc\"},{\"id\":\"213\",\"name\":\"C2R8192D5ext_vlmc\"},{\"id\":\"214\",\"name\":\"C2R8192D10ext_vlmc\"},{\"id\":\"215\",\"name\":\"C2R8192D20ext_vlmc\"},{\"id\":\"216\",\"name\":\"C2R8192D40ext_vlmc\"},{\"id\":\"217\",\"name\":\"C2R8192D60ext_vlmc\"},{\"id\":\"218\",\"name\":\"C2R8192D80ext_vlmc\"},{\"id\":\"219\",\"name\":\"C2R8192D100ext_vlmc\"},{\"id\":\"220\",\"name\":\"C4R512D5ext_vlmc\"},{\"id\":\"221\",\"name\":\"C4R512D10ext_vlmc\"},{\"id\":\"222\",\"name\":\"C4R512D20ext_vlmc\"},{\"id\":\"223\",\"name\":\"C4R512D40ext_vlmc\"},{\"id\":\"224\",\"name\":\"C4R512D60ext_vlmc\"},{\"id\":\"225\",\"name\":\"C4R512D80ext_vlmc\"},{\"id\":\"226\",\"name\":\"C4R512D100ext_vlmc\"},{\"id\":\"227\",\"name\":\"C4R1024D5ext_vlmc\"},{\"id\":\"228\",\"name\":\"C4R1024D10ext_vlmc\"},{\"id\":\"229\",\"name\":\"C4R1024D20ext_vlmc\"},{\"id\":\"230\",\"name\":\"C4R1024D40ext_vlmc\"},{\"id\":\"231\",\"name\":\"C4R1024D60ext_vlmc\"},{\"id\":\"232\",\"name\":\"C4R1024D80ext_vlmc\"},{\"id\":\"233\",\"name\":\"C4R1024D100ext_vlmc\"},{\"id\":\"234\",\"name\":\"C4R2048D5ext_vlmc\"},{\"id\":\"235\",\"name\":\"C4R2048D10ext_vlmc\"},{\"id\":\"236\",\"name\":\"C4R2048D20ext_vlmc\"},{\"id\":\"237\",\"name\":\"C4R2048D40ext_vlmc\"},{\"id\":\"238\",\"name\":\"C4R2048D60ext_vlmc\"},{\"id\":\"239\",\"name\":\"C4R2048D80ext_vlmc\"},{\"id\":\"240\",\"name\":\"C4R2048D100ext_vlmc\"},{\"id\":\"241\",\"name\":\"C4R4096D5ext_vlmc\"},{\"id\":\"242\",\"name\":\"C4R4096D10ext_vlmc\"},{\"id\":\"243\",\"name\":\"C4R4096D20ext_vlmc\"},{\"id\":\"244\",\"name\":\"C4R4096D40ext_vlmc\"},{\"id\":\"245\",\"name\":\"C4R4096D60ext_vlmc\"},{\"id\":\"246\",\"name\":\"C4R4096D80ext_vlmc\"},{\"id\":\"247\",\"name\":\"C4R4096D100ext_vlmc\"},{\"id\":\"248\",\"name\":\"C4R8192D5ext_vlmc\"},{\"id\":\"249\",\"name\":\"C4R8192D10ext_vlmc\"},{\"id\":\"250\",\"name\":\"C4R8192D20ext_vlmc\"},{\"id\":\"251\",\"name\":\"C4R8192D40ext_vlmc\"},{\"id\":\"252\",\"name\":\"C4R8192D60ext_vlmc\"},{\"id\":\"253\",\"name\":\"C4R8192D80ext_vlmc\"},{\"id\":\"254\",\"name\":\"C4R8192D100ext_vlmc\"},{\"id\":\"255\",\"name\":\"C8R512D5ext_vlmc\"},{\"id\":\"256\",\"name\":\"C8R512D10ext_vlmc\"},{\"id\":\"257\",\"name\":\"C8R512D20ext_vlmc\"},{\"id\":\"258\",\"name\":\"C8R512D40ext_vlmc\"},{\"id\":\"259\",\"name\":\"C8R512D60ext_vlmc\"},{\"id\":\"260\",\"name\":\"C8R512D80ext_vlmc\"},{\"id\":\"261\",\"name\":\"C8R512D100ext_vlmc\"},{\"id\":\"262\",\"name\":\"C8R1024D5ext_vlmc\"},{\"id\":\"263\",\"name\":\"C8R1024D10ext_vlmc\"},{\"id\":\"264\",\"name\":\"C8R1024D20ext_vlmc\"},{\"id\":\"265\",\"name\":\"C8R1024D40ext_vlmc\"},{\"id\":\"266\",\"name\":\"C8R1024D60ext_vlmc\"},{\"id\":\"267\",\"name\":\"C8R1024D80ext_vlmc\"},{\"id\":\"268\",\"name\":\"C8R1024D100ext_vlmc\"},{\"id\":\"269\",\"name\":\"C8R2048D5ext_vlmc\"},{\"id\":\"270\",\"name\":\"C8R2048D10ext_vlmc\"},{\"id\":\"271\",\"name\":\"C8R2048D20ext_vlmc\"},{\"id\":\"272\",\"name\":\"C8R2048D40ext_vlmc\"},{\"id\":\"273\",\"name\":\"C8R2048D60ext_vlmc\"},{\"id\":\"274\",\"name\":\"C8R2048D80ext_vlmc\"},{\"id\":\"275\",\"name\":\"C8R2048D100ext_vlmc\"},{\"id\":\"276\",\"name\":\"C8R4096D5ext_vlmc\"},{\"id\":\"277\",\"name\":\"C8R4096D10ext_vlmc\"},{\"id\":\"278\",\"name\":\"C8R4096D20ext_vlmc\"},{\"id\":\"279\",\"name\":\"C8R4096D40ext_vlmc\"},{\"id\":\"280\",\"name\":\"C8R4096D60ext_vlmc\"},{\"id\":\"281\",\"name\":\"C8R4096D80ext_vlmc\"},{\"id\":\"282\",\"name\":\"C8R4096D100ext_vlmc\"},{\"id\":\"283\",\"name\":\"C8R8192D5ext_vlmc\"},{\"id\":\"284\",\"name\":\"C8R8192D10ext_vlmc\"},{\"id\":\"285\",\"name\":\"C8R8192D20ext_vlmc\"},{\"id\":\"286\",\"name\":\"C8R8192D40ext_vlmc\"},{\"id\":\"287\",\"name\":\"C8R8192D60ext_vlmc\"},{\"id\":\"288\",\"name\":\"C8R8192D80ext_vlmc\"},{\"id\":\"289\",\"name\":\"C8R8192D100ext_vlmc\"},{\"id\":\"290\",\"name\":\"C1R6144D100drbd\"},{\"id\":\"291\",\"name\":\"C1R6144D100ext_vlmc\"},{\"id\":\"292\",\"name\":\"C2R6144D100ext_vlmc\"},{\"id\":\"293\",\"name\":\"C2R6144D100drbd\"},{\"id\":\"294\",\"name\":\"C2R6144D80drbd\"},{\"id\":\"295\",\"name\":\"C2R6144D60drbd\"},{\"id\":\"296\",\"name\":\"C2R6144D40drbd\"},{\"id\":\"297\",\"name\":\"C2R6144D40ext_vlmc\"},{\"id\":\"298\",\"name\":\"C2R6144D60ext_vlmc\"},{\"id\":\"299\",\"name\":\"C2R6144D80ext_vlmc\"},{\"id\":\"300\",\"name\":\"C1R6144D5ext_vlmc\"},{\"id\":\"301\",\"name\":\"C1R6144D10ext_vlmc\"},{\"id\":\"302\",\"name\":\"C1R6144D20ext_vlmc\"},{\"id\":\"303\",\"name\":\"C1R6144D40ext_vlmc\"},{\"id\":\"304\",\"name\":\"C1R6144D60ext_vlmc\"},{\"id\":\"305\",\"name\":\"C1R6144D80ext_vlmc\"},{\"id\":\"306\",\"name\":\"C1R6144D5drbd\"},{\"id\":\"307\",\"name\":\"C1R6144D10drbd\"},{\"id\":\"308\",\"name\":\"C1R6144D20drbd\"},{\"id\":\"309\",\"name\":\"C1R6144D40drbd\"},{\"id\":\"310\",\"name\":\"C1R6144D60drbd\"},{\"id\":\"311\",\"name\":\"C1R6144D80drbd\"},{\"id\":\"312\",\"name\":\"C2R6144D5ext_vlmc\"},{\"id\":\"313\",\"name\":\"C2R6144D10ext_vlmc\"},{\"id\":\"314\",\"name\":\"C2R6144D20ext_vlmc\"},{\"id\":\"315\",\"name\":\"C2R6144D5drbd\"},{\"id\":\"316\",\"name\":\"C2R6144D10drbd\"},{\"id\":\"317\",\"name\":\"C2R6144D20drbd\"},{\"id\":\"318\",\"name\":\"C4R6144D5ext_vlmc\"},{\"id\":\"319\",\"name\":\"C4R6144D10ext_vlmc\"},{\"id\":\"320\",\"name\":\"C4R6144D20ext_vlmc\"},{\"id\":\"321\",\"name\":\"C4R6144D40ext_vlmc\"},{\"id\":\"322\",\"name\":\"C4R6144D60ext_vlmc\"},{\"id\":\"323\",\"name\":\"C4R6144D80ext_vlmc\"},{\"id\":\"324\",\"name\":\"C4R6144D100ext_vlmc\"},{\"id\":\"325\",\"name\":\"C4R6144D5drbd\"},{\"id\":\"326\",\"name\":\"C4R6144D10drbd\"},{\"id\":\"327\",\"name\":\"C4R6144D20drbd\"},{\"id\":\"328\",\"name\":\"C4R6144D40drbd\"},{\"id\":\"329\",\"name\":\"C4R6144D60drbd\"},{\"id\":\"330\",\"name\":\"C4R6144D80drbd\"},{\"id\":\"331\",\"name\":\"C4R6144D100drbd\"},{\"id\":\"332\",\"name\":\"C8R6144D5ext_vlmc\"},{\"id\":\"333\",\"name\":\"C8R6144D10ext_vlmc\"},{\"id\":\"334\",\"name\":\"C8R6144D20ext_vlmc\"},{\"id\":\"335\",\"name\":\"C8R6144D40ext_vlmc\"},{\"id\":\"336\",\"name\":\"C8R6144D60ext_vlmc\"},{\"id\":\"337\",\"name\":\"C8R6144D80ext_vlmc\"},{\"id\":\"338\",\"name\":\"C8R6144D100ext_vlmc\"},{\"id\":\"339\",\"name\":\"C8R6144D5drbd\"},{\"id\":\"340\",\"name\":\"C8R6144D10drbd\"},{\"id\":\"341\",\"name\":\"C8R6144D20drbd\"},{\"id\":\"342\",\"name\":\"C8R6144D40drbd\"},{\"id\":\"343\",\"name\":\"C8R6144D60drbd\"},{\"id\":\"344\",\"name\":\"C8R6144D80drbd\"},{\"id\":\"345\",\"name\":\"C8R6144D100drbd\"},{\"id\":\"fa34e0a0-b474-464b-a563-9aea1bc3e9b5\",\"name\":\"CELAR_Jenkins_snapshot_111213\"},{\"id\":\"8258fe3d-3b6d-49c7-88aa-bc28cc44d609\",\"name\":\"CELAR_Nexus_snapshot_111213\"},{\"id\":\"df6dcbbf-4fe2-4550-8bfd-f65b57dc45eb\",\"name\":\"CentOS\"},{\"id\":\"8258fe3d-3b6d-49c7-88aa-bc28cc44d609\",\"name\":\"CELAR_Nexus_snapshot_111213\"},{\"id\":\"df6dcbbf-4fe2-4550-8bfd-f65b57dc45eb\",\"name\":\"CentOS\"},{\"id\":\"fa34e0a0-b474-464b-a563-9aea1bc3e9b5\",\"name\":\"CELAR_Jenkins_snapshot_111213\"}]";
-//
-// if ( flavors.equals( "" ) == false ) {
-//
-// flavors = "{\"flavors\":" + flavors + "}";
-// String output_json = flavors;
-// JSONObject obj = new JSONObject( output_json );
-// JSONArray images_array = obj.getJSONArray( "flavors" ); //$NON-NLS-1$
-//
-// if ( images_array != null ){
-// for (int i=0; i < images_array.length(); i++){
-// VirtualMachineImageFlavor vmif = InfoSystemFactory.eINSTANCE.createVirtualMachineImageFlavor();
-// /*
-// * get the necessary vmif fields
-// */
-//
-// vmif.setUID( images_array.getJSONObject( i ).getString( "id" ) );
-// vmif.setName( images_array.getJSONObject( i ).getString( "name" )); //$NON-NLS-1$ );
-// System.out.println(vmif.getName()+" "+vmif.getUID());
-// //add new vmi to images list
-// instance.vm_flavors.add( vmif );
-// }
-// }
-// }
-// }
-//
-//
-//
-//
-//
-//
-// //fetch probes from CELAR DB
-//// private void fetchMonitorProbes (final IProgressMonitor monitor) throws SQLException, JSONException {
-////
-//// //CELAR Manager call : Get Monitoring Probes
-//// String celarManagerURL = "http://83.212.107.38:8080/resources/";
-//// URL url = null;
-//// HttpURLConnection connection = null;
-//// BufferedReader in = null;
-//// String inputLine = null;
-////
-//// String probes = "";
-//// try {
-//// url = new URL (celarManagerURL + "probes/");
-////
-//// connection = (HttpURLConnection) url.openConnection();
-//// connection.setDoInput( true );
-//// connection.setRequestProperty("Accept", "application/json");
-//// connection.setRequestMethod( "GET" );
-////
-//// in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
-//// while ((inputLine = in.readLine()) != null) {
-//// probes = probes + inputLine;
-//// }
-////
-//// probes = probes.substring( 0, probes.length()-1 );
-//// probes = probes + ",{\"name\":\"Queue Length probe\",\"metrics\":[\"Q1 length\",\"Q2 length\",\"Q3 length\", \"Q4 length\",\"Q5 length\",\"Q6 length\",\"Q7 length\", \"Q8 length\" ]}]" ;
-////
-//// in.close();
-//// System.out.println(probes);
-////
-//// connection.disconnect();
-//// } catch( MalformedURLException e ) {
-//// // TODO Auto-generated catch block
-//// e.printStackTrace();
-//// } catch( IOException e ) {
-//// // TODO Auto-generated catch block
-//// e.printStackTrace();
-//// }
-//// if ( probes.equals( "" ) == false ) {
-////
-//// probes = "{\"probes\":" + probes + "}";
-//// String output_json = probes;
-//// JSONObject obj = new JSONObject( output_json );
-//// JSONArray probes_array = obj.getJSONArray( "probes" ); //$NON-NLS-1$
-////
-//// if ( probes_array != null ){
-//// for (int i=0; i < probes_array.length(); i++){
-//// MonitoringProbe mp = InfoSystemFactory.eINSTANCE.createMonitoringProbe();
-//// /*
-//// * get the necessary mp fields
-//// */
-//// mp.setName( probes_array.getJSONObject( i ).getString( "name" )); //$NON-NLS-1$ );
-//// mp.setDescription( probes_array.getJSONObject( i ).getString( "metrics" ) );
-////
-//// System.out.println(mp.getName());
-//// System.out.println(mp.getDescription());
-////
-//// //add new monitor probe to probes list
-//// instance.monitor_probes.add( mp );
-//// }
-////
-//// }
-//// }
-//// }
-////
-// private void fetchResizingActions (final IProgressMonitor monitor) throws SQLException, JSONException {
-//
-// //CELAR Manager call : Get Resizing Actions
-// String celarManagerURL = "http://83.212.107.38:8080/resources/";
-// URL url = null;
-// HttpURLConnection connection = null;
-// BufferedReader in = null;
-// String inputLine = null;
-//
-// String actions = "";
-// try {
-// url = new URL (celarManagerURL + "actions/");
-//
-// connection = (HttpURLConnection) url.openConnection();
-// connection.setDoInput( true );
-// connection.setRequestProperty("Accept", "application/json");
-// connection.setRequestMethod( "GET" );
-//
-// in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
-// while ((inputLine = in.readLine()) != null) {
-// actions = actions + inputLine;
-// }
-// in.close();
-// System.out.println(actions);
-//
-// connection.disconnect();
-// } catch( MalformedURLException e ) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// } catch( IOException e ) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-// if ( actions.equals( "" ) == false ) {
-//
-// actions = "{\"actions\":" + actions + "}";
-// String output_json = actions;
-// JSONObject obj = new JSONObject( output_json );
-// JSONArray actions_array = obj.getJSONArray( "actions" ); //$NON-NLS-1$
-//
-// if ( actions_array != null ){
-// for (int i=0; i < actions_array.length(); i++){
-// ResizingAction ra = InfoSystemFactory.eINSTANCE.createResizingAction();
-// /*
-// * get the necessary ra fields
-// */
-// ra.setName( actions_array.getJSONObject( i ).getString( "name" )); //$NON-NLS-1$ );
-//
-// //add new ra to resizing_actions list
-// instance.resize_actions.add( ra );
-// }
-// }
-// }
-// }
-//
-//// private void fetchFlavors (final IProgressMonitor monitor) throws SQLException, JSONException {
-////
-//// //CELAR Manager call : Get Flavors
-//// String celarManagerURL = "http://83.212.107.38:8080/resources/";
-//// URL url = null;
-//// HttpURLConnection connection = null;
-//// BufferedReader in = null;
-//// String inputLine = null;
-////
-//// String flavors = "";
-//// try {
-//// url = new URL (celarManagerURL + "flavors/");
-////
-//// connection = (HttpURLConnection) url.openConnection();
-//// connection.setDoInput( true );
-//// connection.setRequestProperty("Accept", "application/json");
-//// connection.setRequestMethod( "GET" );
-////
-//// in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
-//// while ((inputLine = in.readLine()) != null) {
-//// flavors = flavors + inputLine;
-//// }
-//// in.close();
-//// System.out.println("Flavors: " + flavors);
-////
-//// connection.disconnect();
-//// } catch( MalformedURLException e ) {
-//// // TODO Auto-generated catch block
-//// e.printStackTrace();
-//// } catch( IOException e ) {
-//// // TODO Auto-generated catch block
-//// e.printStackTrace();
-//// }
-//// if ( flavors.equals( "" ) == false ) {
-////
-//// flavors = "{\"flavors\":" + flavors + "}";
-//// String output_json = flavors;
-//// JSONObject obj = new JSONObject( output_json );
-//// JSONArray flavors_array = obj.getJSONArray( "flavors" ); //$NON-NLS-1$
-////
-////// if ( flavors_array != null ){
-////// for (int i=0; i < flavors_array.length(); i++){
-////// VirtualMachineImageType vmf = InfoSystemFactory.eINSTANCE.createVirtualMachineImageType();
-////// /*
-////// * get the necessary ra fields
-////// */
-////// vmf.setName( flavors_array.getJSONObject( i ).getString( "name" )); //$NON-NLS-1$ );
-//////
-////// //add new ra to resizing_actions list
-////// instance.vm_flavors.add( vmf );
-////// }
-////// }
-//// }
-//// }
-// /**
-// * @return A list with the available Base Machine Images
-// */
-// public ArrayList<VirtualMachineImage> getBaseMachineImages () {
-// return instance.base_images;
-// }
-//
-// /**
-// * @return A list with available Monitoring Probes
-// */
-// public ArrayList<MonitoringProbe> getMonitoringProbes () {
-// return instance.monitor_probes;
-// }
-//
-// /**
-// * @return A list with available Resizing Actions
-// */
-// public ArrayList<ResizingAction> getResizingActions () {
-// return instance.resize_actions;
-// }
-//
-//
-//
-// private MessageConsole findConsole(String name) {
-// ConsolePlugin plugin = ConsolePlugin.getDefault();
-// IConsoleManager conMan = plugin.getConsoleManager();
-// IConsole[] existing = conMan.getConsoles();
-// for (int i = 0; i < existing.length; i++)
-// if (name.equals(existing[i].getName()))
-// return (MessageConsole) existing[i];
-// //no console found, so create a new one
-// MessageConsole myConsole = new MessageConsole(name, null);
-// conMan.addConsoles(new IConsole[]{myConsole});
-// return myConsole;
-// }
-//
-// private void createStaticCelarDB() {
-// VirtualMachineImage vmi = InfoSystemFactory.eINSTANCE.createVirtualMachineImage();
-// vmi.setUID( "1" );
-// vmi.setName( "Ubuntu-12.04.3-64bit" );
-// vmi.setDescription( "h" );
-// vmi.setURL( "h" );
-// vmi.setType( VirtualMachineImageType.BASE_IMAGE );
-// instance.base_images.add( vmi );
-//
-// vmi = InfoSystemFactory.eINSTANCE.createVirtualMachineImage();
-// vmi.setUID( "1" );
-// vmi.setName( "Ubuntu-12.04-32bit" );
-// vmi.setDescription( "h" );
-// vmi.setURL( "h" );
-// vmi.setType( VirtualMachineImageType.BASE_IMAGE );
-// instance.base_images.add( vmi );
-//
-// MonitoringProbe mp = InfoSystemFactory.eINSTANCE.createMonitoringProbe();
-// mp.setUID( "" );
-// mp.setName( "CPU Usage" );
-// mp.setDescription( "" );
-// instance.monitor_probes.add( mp );
-//
-// mp = InfoSystemFactory.eINSTANCE.createMonitoringProbe();
-// mp.setUID( "" );
-// mp.setName( "Memory Usage" );
-// mp.setDescription( "" );
-// instance.monitor_probes.add( mp );
-//
-// ResizingAction ra = InfoSystemFactory.eINSTANCE.createResizingAction();
-// ra.setUID( "" );
-// ra.setName( "Add VM" );
-// ra.setDescription( "" );
-// instance.resize_actions.add( ra );
-//
-// ra = InfoSystemFactory.eINSTANCE.createResizingAction();
-// ra.setUID( "" );
-// ra.setName( "Remove VM" );
-// ra.setDescription( "" );
-// instance.resize_actions.add( ra );
-// }
-//}
diff --git a/plugins/org.eclipse.camf.tosca.editor/plugin.xml b/plugins/org.eclipse.camf.tosca.editor/plugin.xml
index 84ec741..f57b667 100644
--- a/plugins/org.eclipse.camf.tosca.editor/plugin.xml
+++ b/plugins/org.eclipse.camf.tosca.editor/plugin.xml
@@ -51,7 +51,7 @@
Defines a property sheet tab for the Eclipse tabbed property sheet for EReferences.
-->
<propertyTab
- afterTab="graphiti.main.tab"
+ afterTab="graphiti.component.smart.tab"
category="CELAR"
id="graphiti.component.elasticity.tab"
label="Elasticity">
@@ -137,6 +137,12 @@
id="graphiti.component.deployment.script.tab"
label="Deployment">
</propertyTab>
+ <propertyTab
+ afterTab="graphiti.main.tab"
+ category="CELAR"
+ id="graphiti.component.smart.tab"
+ label="Smart">
+ </propertyTab>
</propertyTabs>
</extension>
@@ -244,6 +250,12 @@
id="graphiti.advanced.tab.deployment.script"
tab="graphiti.component.deployment.script.tab">
</propertySection>
+ <propertySection
+ class="org.eclipse.camf.tosca.editor.property.ApplicationComponentSmartSection"
+ filter="org.eclipse.camf.tosca.editor.property.ApplicationComponentFilter"
+ id="graphiti.advanced.tab.smart.deployment"
+ tab="graphiti.component.smart.tab">
+ </propertySection>
</propertySections>
</extension>
diff --git a/plugins/org.eclipse.camf.tosca.editor/src/org/eclipse/camf/tosca/editor/diagram/ToscaToolBehaviorProvider.java b/plugins/org.eclipse.camf.tosca.editor/src/org/eclipse/camf/tosca/editor/diagram/ToscaToolBehaviorProvider.java
index 7527c5a..10f0845 100644
--- a/plugins/org.eclipse.camf.tosca.editor/src/org/eclipse/camf/tosca/editor/diagram/ToscaToolBehaviorProvider.java
+++ b/plugins/org.eclipse.camf.tosca.editor/src/org/eclipse/camf/tosca/editor/diagram/ToscaToolBehaviorProvider.java
@@ -683,31 +683,31 @@
// Add custom probes from project explorer
- IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
- IProject monitoringProbesProject = workspaceRoot.getProject( "MonitoringProbe" );
-
- if( monitoringProbesProject.exists() ) {
- IFolder srcFolder = monitoringProbesProject.getFolder( "src" );
- IResource[] artifactsResource = null;
- try {
- artifactsResource = srcFolder.members();
- } catch( CoreException e ) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- if ( artifactsResource != null ){
- for( IResource tempResource : artifactsResource ) {
- if( tempResource instanceof IFile ) {
- MonitoringProbe mp = InfoSystemFactory.eINSTANCE.createMonitoringProbe();
- mp.setUID( tempResource.getName().replaceFirst( ".java", "" ));
- mp.setName( tempResource.getName().replaceFirst( ".java", "" ));
- mp.setDescription( "" );
- // add new probe to monitoring list
- mpsCopy.add( 0, mp );
- }
- }
- }
- }
+// IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+// IProject monitoringProbesProject = workspaceRoot.getProject( "MonitoringProbe" );
+//
+// if( monitoringProbesProject.exists() ) {
+// IFolder srcFolder = monitoringProbesProject.getFolder( "src" );
+// IResource[] artifactsResource = null;
+// try {
+// artifactsResource = srcFolder.members();
+// } catch( CoreException e ) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+// if ( artifactsResource != null ){
+// for( IResource tempResource : artifactsResource ) {
+// if( tempResource instanceof IFile ) {
+// MonitoringProbe mp = InfoSystemFactory.eINSTANCE.createMonitoringProbe();
+// mp.setUID( tempResource.getName().replaceFirst( ".java", "" ));
+// mp.setName( tempResource.getName().replaceFirst( ".java", "" ));
+// mp.setDescription( "" );
+// // add new probe to monitoring list
+// mpsCopy.add( 0, mp );
+// }
+// }
+// }
+// }
// add new compartment at the end of the existing compartments
PaletteCompartmentEntry compartmentEntry = new PaletteCompartmentEntry( "Monitor Probes", null ); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.camf.tosca.editor/src/org/eclipse/camf/tosca/editor/property/ApplicationComponentNameSection.java b/plugins/org.eclipse.camf.tosca.editor/src/org/eclipse/camf/tosca/editor/property/ApplicationComponentNameSection.java
index 344e374..ac64cd1 100644
--- a/plugins/org.eclipse.camf.tosca.editor/src/org/eclipse/camf/tosca/editor/property/ApplicationComponentNameSection.java
+++ b/plugins/org.eclipse.camf.tosca.editor/src/org/eclipse/camf/tosca/editor/property/ApplicationComponentNameSection.java
@@ -26,14 +26,11 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigInteger;
-import java.util.ArrayList;
import javax.xml.namespace.QName;
import org.eclipse.camf.core.model.CloudModel;
import org.eclipse.camf.core.reporting.ProblemException;
-import org.eclipse.camf.infosystem.mockup.info.MockUpInfoSystem;
-import org.eclipse.camf.infosystem.model.base.VirtualMachineImageFlavor;
import org.eclipse.camf.tosca.PropertiesType;
import org.eclipse.camf.tosca.TDeploymentArtifact;
import org.eclipse.camf.tosca.TDeploymentArtifacts;
@@ -92,669 +89,948 @@
implements ITabbedPropertyConstants, ModifyListener, SelectionListener
{
- private Text nameText;
- private Text descrText;
- private Text imageText;
- private Text keypairText;
- private Text initialInstancesText;
- private Text minInstancesText;
- private Text maxInstancesText;
- private CCombo cmbImageSize;
- private Button uploadImage;
- private Button keypairSelect;
+ private Text nameText;
+ private Text imageText;
+ private Text keypairText;
+ private Text minInstancesText;
+ private Text maxInstancesText;
+ private CCombo cmbImageSize;
+ private Button uploadImage;
+ private Button keypairSelect;
- private String typesPrefix = Tosca_Elasticity_ExtensionsPackage.eINSTANCE.getNsPrefix();
+ private String typesPrefix = Tosca_Elasticity_ExtensionsPackage.eINSTANCE.getNsPrefix();
+
+ private String typesNamespace = Tosca_Elasticity_ExtensionsPackage.eINSTANCE.getNsURI();
+
+ private String imageType = Tosca_Elasticity_ExtensionsPackage.eINSTANCE.getImageArtifactPropertiesType().getName();
+
+ @Override
+ public void createControls( final Composite parent,
+ TabbedPropertySheetPage tabbedPropertySheetPage )
+ {
+ super.createControls( parent, tabbedPropertySheetPage );
+ TabbedPropertySheetWidgetFactory factory = getWidgetFactory();
+ FormToolkit toolkit = new FormToolkit( parent.getDisplay() );
+ // Application Component Properties Section\
+ // Application Name label
+ Section section = toolkit.createSection( parent, Section.TITLE_BAR );
+ section.setText( "Application Component Properties" ); //$NON-NLS-1$
+ Composite client = toolkit.createComposite( section, SWT.WRAP );
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ layout.marginTop = 15;
+ layout.verticalSpacing = 15;
+ layout.marginWidth = 2;
+ layout.marginHeight = 2;
+ client.setLayout( layout );
+ GridData gd;
+ CLabel valueLabel = factory.createCLabel( client, "Name:" ); //$NON-NLS-1$
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
+ gd.widthHint = 80;
+ // gd.widthHint=STANDARD_LABEL_WIDTH;
+ valueLabel.setLayoutData( gd );
+ // Application Name text
+ this.nameText = factory.createText( client, "" ); //$NON-NLS-1$
+ this.nameText.setEditable( true );
+ gd = new GridData();
+ gd.horizontalSpan = 2;
+ gd.widthHint = 160;
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
+ this.nameText.setLayoutData( gd );
+ // Application VM label
+ CLabel imageLabel = factory.createCLabel( client, "VM Image:" ); //$NON-NLS-1$
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
+ gd.widthHint = 80;
+ // gd.widthHint=STANDARD_LABEL_WIDTH;
+ imageLabel.setLayoutData( gd );
+ this.imageText = factory.createText( client, "" ); //$NON-NLS-1$
+ this.imageText.setEditable( true );
+ gd = new GridData();
+ gd.widthHint = 160;
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
+ // Application VM text
+ this.imageText.setLayoutData( gd );
+ this.imageText.addModifyListener( this );
+ // VM Upload Image Button
+ this.uploadImage = new Button( client, SWT.PUSH );
+ this.uploadImage.setText( " Add Image... " ); //$NON-NLS-1$
+ gd = new GridData();
+ gd.widthHint = 80;
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ this.uploadImage.setLayoutData( gd );
+ // Listener for Add button
+ this.uploadImage.addSelectionListener( new SelectionListener() {
- private String typesNamespace = Tosca_Elasticity_ExtensionsPackage.eINSTANCE.getNsURI();
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ FileDialog dialog = new FileDialog( parent.getShell(), SWT.OPEN );
+ dialog.setText( "Select Image File" ); //$NON-NLS-1$
+ // dialog.setFilterExtensions(new String [] {"*.html"});
+ // dialog.setFilterPath("c:\\temp");
+ String result = dialog.open();
+ if( result != null ) {
+ // Add uploaded image to Project Artifacts folder
+ IWorkbenchPage activePage = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow()
+ .getActivePage();
+ IEditorInput input = activePage.getActiveEditor().getEditorInput();
+ IFile file = null;
+ if( input instanceof ToscaDiagramEditorInput ) {
+ file = ( ( ToscaDiagramEditorInput )input ).getToscaFile();
+ }
+ IProject project = file.getProject();
- private String imageType = Tosca_Elasticity_ExtensionsPackage.eINSTANCE.getImageArtifactPropertiesType().getName();
+ String targetPath = Platform.getLocation()
+ + System.getProperty( "file.separator" ) + project.getName() + System.getProperty( "file.separator" ) + "Artifacts"+ System.getProperty( "file.separator" ) + "Virtual Machine Images" + System.getProperty( "file.separator" ) + dialog.getFileName(); //$NON-NLS-1$ //$NON-NLS-2$
+ File tmp = new File( targetPath );
+ try {
+ tmp.createNewFile();
+ } catch( IOException e1 ) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ // Get image Id
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader( new FileReader (new File(result)));
+ } catch( FileNotFoundException e3 ) {
+ // TODO Auto-generated catch block
+ e3.printStackTrace();
+ }
+ String line = null;
+ StringBuilder stringBuilder = new StringBuilder();
- @Override
- public void createControls( final Composite parent,
- TabbedPropertySheetPage tabbedPropertySheetPage )
- {
- super.createControls( parent, tabbedPropertySheetPage );
- TabbedPropertySheetWidgetFactory factory = getWidgetFactory();
- FormToolkit toolkit = new FormToolkit( parent.getDisplay() );
- // Application Component Properties Section\
- // Application Name label
- Section section = toolkit.createSection( parent, Section.TITLE_BAR );
- section.setText( "Application Component Properties" ); //$NON-NLS-1$
- Composite client = toolkit.createComposite( section, SWT.WRAP );
- GridLayout layout = new GridLayout();
- layout.numColumns = 3;
- layout.marginTop = 15;
- layout.verticalSpacing = 15;
- layout.marginWidth = 2;
- layout.marginHeight = 2;
- client.setLayout( layout );
- GridData gd;
- CLabel valueLabel = factory.createCLabel( client, "Name:" ); //$NON-NLS-1$
- gd = new GridData();
- gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
- gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
- gd.widthHint = 80;
- // gd.widthHint=STANDARD_LABEL_WIDTH;
- valueLabel.setLayoutData( gd );
- // Application Name text
- this.nameText = factory.createText( client, "" ); //$NON-NLS-1$
- this.nameText.setEditable( true );
- gd = new GridData();
- gd.horizontalSpan = 2;
- gd.widthHint = 160;
- gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
- gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
- this.nameText.setLayoutData( gd );
- // Application VM label
- CLabel imageLabel = factory.createCLabel( client, "VM Image:" ); //$NON-NLS-1$
- gd = new GridData();
- gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
- gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
- gd.widthHint = 80;
- // gd.widthHint=STANDARD_LABEL_WIDTH;
- imageLabel.setLayoutData( gd );
- this.imageText = factory.createText( client, "" ); //$NON-NLS-1$
- this.imageText.setEditable( true );
- gd = new GridData();
- gd.widthHint = 160;
- gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
- gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
- // Application VM text
- this.imageText.setLayoutData( gd );
- this.imageText.addModifyListener( this );
- // VM Upload Image Button
- this.uploadImage = new Button( client, SWT.PUSH );
- this.uploadImage.setText( " Add Image... " ); //$NON-NLS-1$
- gd = new GridData();
- gd.widthHint = 80;
- gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
- this.uploadImage.setLayoutData( gd );
- // Listener for Add button
- this.uploadImage.addSelectionListener( new SelectionListener() {
+ try {
+ while( ( line = reader.readLine() ) != null ) {
+ stringBuilder.append( line );
+ }
+ } catch( IOException e1 ) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
- @Override
- public void widgetSelected( SelectionEvent e ) {
- FileDialog dialog = new FileDialog( parent.getShell(), SWT.OPEN );
- dialog.setText( "Select Image File" ); //$NON-NLS-1$
- // dialog.setFilterExtensions(new String [] {"*.html"});
- // dialog.setFilterPath("c:\\temp");
- String result = dialog.open();
- if( result != null ) {
- // Add uploaded image to Project Artifacts folder
- IWorkbenchPage activePage = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow()
- .getActivePage();
- IEditorInput input = activePage.getActiveEditor().getEditorInput();
- IFile file = null;
- if( input instanceof ToscaDiagramEditorInput ) {
- file = ( ( ToscaDiagramEditorInput )input ).getToscaFile();
- }
- IProject project = file.getProject();
+ String imageId = stringBuilder.toString();
+
+ copySelectedFileToCloudProject( new File(result), tmp );
+
+ IProgressMonitor monitor = null;
+ try {
+ CloudModel.getRoot().refresh( monitor );
+ } catch( ProblemException e2 ) {
+ e2.printStackTrace();
+ }
+// // Refresh Palette Compartments
+// getDiagramTypeProvider().getFeatureProvider()
+// .getDiagramTypeProvider()
+// .getDiagramBehavior()
+// .refreshPalette();
+
+
+ CreateVMIFeature createImageFeature = new CreateVMIFeature( new ToscaFeatureProvider( getDiagramTypeProvider() ) );
+ TDeploymentArtifact deploymentArtifact = ToscaFactory.eINSTANCE.createTDeploymentArtifact();
+ deploymentArtifact.setName( dialog.getFileName());
+ deploymentArtifact.setArtifactRef( new QName (imageId) );
+ deploymentArtifact.setArtifactType( new QName( typesNamespace, imageType, typesPrefix ) ); //$NON-NLS-1$
+ createImageFeature.setContextObject( deploymentArtifact );
+ CreateContext createContext = new CreateContext();
+ createContext.setTargetContainer( ( ContainerShape )getSelectedPictogramElement() );
+ if( createImageFeature.canCreate( createContext ) )
+ createImageFeature.create( createContext );
+ refresh();
- String targetPath = Platform.getLocation()
- + System.getProperty( "file.separator" ) + project.getName() + System.getProperty( "file.separator" ) + "Artifacts"+ System.getProperty( "file.separator" ) + "Virtual Machine Images" + System.getProperty( "file.separator" ) + dialog.getFileName(); //$NON-NLS-1$ //$NON-NLS-2$
- File tmp = new File( targetPath );
- try {
- tmp.createNewFile();
- } catch( IOException e1 ) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
+ }
+ }
- // Get image Id
- BufferedReader reader = null;
- try {
- reader = new BufferedReader( new FileReader (new File(result)));
- } catch( FileNotFoundException e3 ) {
- // TODO Auto-generated catch block
- e3.printStackTrace();
- }
- String line = null;
- StringBuilder stringBuilder = new StringBuilder();
+ @Override
+ public void widgetDefaultSelected( final SelectionEvent e ) {
+ // TODO Auto-generated method stub
+ }
+ } );
- try {
- while( ( line = reader.readLine() ) != null ) {
- stringBuilder.append( line );
- }
- } catch( IOException e1 ) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
+ // VM Image Flavor label
+ CLabel vmImageLabel = factory.createCLabel( client, "VM Type:" ); //$NON-NLS-1$
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
+ gd.widthHint = 80;
+ vmImageLabel.setLayoutData( gd );
+ // Combo - VM Image Flavor
+ this.cmbImageSize = new CCombo( client, SWT.BORDER );
+ this.cmbImageSize.setEnabled( true );
- String imageId = stringBuilder.toString();
+// ArrayList<VirtualMachineImageFlavor> instanceTypes =
+// MockUpInfoSystem.getInstance().getInstanceTypes();
+// for (VirtualMachineImageFlavor type : instanceTypes )
+// this.cmbImageSize.add(type.getName());
+ ///////////////////////////////////////////////////////
+ this.cmbImageSize.add( "vcpus:1 ram:1024 disk:20" );
+ this.cmbImageSize.add( "vcpus:1 ram:1024 disk:40" );
+ this.cmbImageSize.add( "vcpus:1 ram:2048 disk:20" );
+ this.cmbImageSize.add( "vcpus:1 ram:2048 disk:40" );
+ this.cmbImageSize.add( "vcpus:1 ram:4096 disk:20" );
+ this.cmbImageSize.add( "vcpus:1 ram:4096 disk:40" );
+ this.cmbImageSize.add( "vcpus:2 ram:1024 disk:20" );
+ this.cmbImageSize.add( "vcpus:2 ram:1024 disk:40" );
+ this.cmbImageSize.add( "vcpus:2 ram:2048 disk:20" );
+ this.cmbImageSize.add( "vcpus:2 ram:2048 disk:40" );
+ this.cmbImageSize.add( "vcpus:2 ram:4096 disk:20" );
+ this.cmbImageSize.add( "vcpus:2 ram:4096 disk:40" );
+ this.cmbImageSize.add( "vcpus:4 ram:1024 disk:20" );
+ this.cmbImageSize.add( "vcpus:4 ram:1024 disk:40" );
+ this.cmbImageSize.add( "vcpus:4 ram:2048 disk:20" );
+ this.cmbImageSize.add( "vcpus:4 ram:2048 disk:40" );
+ this.cmbImageSize.add( "vcpus:4 ram:4096 disk:20" );
+ this.cmbImageSize.add( "vcpus:4 ram:4096 disk:40" );
+ this.cmbImageSize.add( "vcpus:1 ram:1024 disk:5" );
+ this.cmbImageSize.add( "vcpus:1 ram:1024 disk:10" );
+ this.cmbImageSize.add( "vcpus:1 ram:2048 disk:5" );
+ this.cmbImageSize.add( "vcpus:1 ram:2048 disk:10" );
+ this.cmbImageSize.add( "vcpus:1 ram:4096 disk:5" );
+ this.cmbImageSize.add( "vcpus:1 ram:4096 disk:10" );
+ this.cmbImageSize.add( "vcpus:2 ram:1024 disk:5" );
+ this.cmbImageSize.add( "vcpus:2 ram:1024 disk:10" );
+ this.cmbImageSize.add( "vcpus:2 ram:2048 disk:5" );
+ this.cmbImageSize.add( "vcpus:2 ram:2048 disk:10" );
+ this.cmbImageSize.add( "vcpus:2 ram:4096 disk:5" );
+ this.cmbImageSize.add( "vcpus:2 ram:4096 disk:10" );
+ this.cmbImageSize.add( "vcpus:4 ram:1024 disk:5" );
+ this.cmbImageSize.add( "vcpus:4 ram:1024 disk:10" );
+ this.cmbImageSize.add( "vcpus:4 ram:2048 disk:5" );
+ this.cmbImageSize.add( "vcpus:4 ram:2048 disk:10" );
+ this.cmbImageSize.add( "vcpus:4 ram:4096 disk:5" );
+ this.cmbImageSize.add( "vcpus:4 ram:4096 disk:10" );
+ this.cmbImageSize.add( "vcpus:1 ram:512 disk:5" );
+ this.cmbImageSize.add( "vcpus:1 ram:512 disk:10" );
+ this.cmbImageSize.add( "vcpus:1 ram:512 disk:20" );
+ this.cmbImageSize.add( "vcpus:1 ram:512 disk:40" );
+ this.cmbImageSize.add( "vcpus:1 ram:512 disk:60" );
+ this.cmbImageSize.add( "vcpus:1 ram:512 disk:80" );
+ this.cmbImageSize.add( "vcpus:1 ram:512 disk:100" );
+ this.cmbImageSize.add( "vcpus:1 ram:1024 disk:60" );
+ this.cmbImageSize.add( "vcpus:1 ram:1024 disk:80" );
+ this.cmbImageSize.add( "vcpus:1 ram:1024 disk:100" );
+ this.cmbImageSize.add( "vcpus:1 ram:2048 disk:60" );
+ this.cmbImageSize.add( "vcpus:1 ram:2048 disk:80" );
+ this.cmbImageSize.add( "vcpus:1 ram:2048 disk:100" );
+ this.cmbImageSize.add( "vcpus:1 ram:4096 disk:60" );
+ this.cmbImageSize.add( "vcpus:1 ram:4096 disk:80" );
+ this.cmbImageSize.add( "vcpus:1 ram:4096 disk:100" );
+ this.cmbImageSize.add( "vcpus:1 ram:8192 disk:5" );
+ this.cmbImageSize.add( "vcpus:1 ram:8192 disk:10" );
+ this.cmbImageSize.add( "vcpus:1 ram:8192 disk:20" );
+ this.cmbImageSize.add( "vcpus:1 ram:8192 disk:40" );
+ this.cmbImageSize.add( "vcpus:1 ram:8192 disk:60" );
+ this.cmbImageSize.add( "vcpus:1 ram:8192 disk:80" );
+ this.cmbImageSize.add( "vcpus:1 ram:8192 disk:100" );
+ this.cmbImageSize.add( "vcpus:2 ram:512 disk:5" );
+ this.cmbImageSize.add( "vcpus:2 ram:512 disk:10" );
+ this.cmbImageSize.add( "vcpus:2 ram:512 disk:20" );
+ this.cmbImageSize.add( "vcpus:2 ram:512 disk:40" );
+ this.cmbImageSize.add( "vcpus:2 ram:512 disk:60" );
+ this.cmbImageSize.add( "vcpus:2 ram:512 disk:80" );
+ this.cmbImageSize.add( "vcpus:2 ram:512 disk:100" );
+ this.cmbImageSize.add( "vcpus:2 ram:1024 disk:60" );
+ this.cmbImageSize.add( "vcpus:2 ram:1024 disk:80" );
+ this.cmbImageSize.add( "vcpus:2 ram:1024 disk:100" );
+ this.cmbImageSize.add( "vcpus:2 ram:2048 disk:60" );
+ this.cmbImageSize.add( "vcpus:2 ram:2048 disk:80" );
+ this.cmbImageSize.add( "vcpus:2 ram:2048 disk:100" );
+ this.cmbImageSize.add( "vcpus:2 ram:4096 disk:60" );
+ this.cmbImageSize.add( "vcpus:2 ram:4096 disk:80" );
+ this.cmbImageSize.add( "vcpus:2 ram:4096 disk:100" );
+ this.cmbImageSize.add( "vcpus:2 ram:8192 disk:5" );
+ this.cmbImageSize.add( "vcpus:2 ram:8192 disk:10" );
+ this.cmbImageSize.add( "vcpus:2 ram:8192 disk:20" );
+ this.cmbImageSize.add( "vcpus:2 ram:8192 disk:40" );
+ this.cmbImageSize.add( "vcpus:2 ram:8192 disk:60" );
+ this.cmbImageSize.add( "vcpus:2 ram:8192 disk:80" );
+ this.cmbImageSize.add( "vcpus:2 ram:8192 disk:100" );
+ this.cmbImageSize.add( "vcpus:4 ram:512 disk:5" );
+ this.cmbImageSize.add( "vcpus:4 ram:512 disk:10" );
+ this.cmbImageSize.add( "vcpus:4 ram:512 disk:20" );
+ this.cmbImageSize.add( "vcpus:4 ram:512 disk:40" );
+ this.cmbImageSize.add( "vcpus:4 ram:512 disk:60" );
+ this.cmbImageSize.add( "vcpus:4 ram:512 disk:80" );
+ this.cmbImageSize.add( "vcpus:4 ram:512 disk:100" );
+ this.cmbImageSize.add( "vcpus:4 ram:1024 disk:60" );
+ this.cmbImageSize.add( "vcpus:4 ram:1024 disk:80" );
+ this.cmbImageSize.add( "vcpus:4 ram:1024 disk:100" );
+ this.cmbImageSize.add( "vcpus:4 ram:2048 disk:60" );
+ this.cmbImageSize.add( "vcpus:4 ram:2048 disk:80" );
+ this.cmbImageSize.add( "vcpus:4 ram:2048 disk:100" );
+ this.cmbImageSize.add( "vcpus:4 ram:4096 disk:60" );
+ this.cmbImageSize.add( "vcpus:4 ram:4096 disk:80" );
+ this.cmbImageSize.add( "vcpus:4 ram:4096 disk:100" );
+ this.cmbImageSize.add( "vcpus:4 ram:8192 disk:5" );
+ this.cmbImageSize.add( "vcpus:4 ram:8192 disk:10" );
+ this.cmbImageSize.add( "vcpus:4 ram:8192 disk:20" );
+ this.cmbImageSize.add( "vcpus:4 ram:8192 disk:40" );
+ this.cmbImageSize.add( "vcpus:4 ram:8192 disk:60" );
+ this.cmbImageSize.add( "vcpus:4 ram:8192 disk:80" );
+ this.cmbImageSize.add( "vcpus:4 ram:8192 disk:100" );
+ this.cmbImageSize.add( "vcpus:8 ram:512 disk:5" );
+ this.cmbImageSize.add( "vcpus:8 ram:512 disk:10" );
+ this.cmbImageSize.add( "vcpus:8 ram:512 disk:20" );
+ this.cmbImageSize.add( "vcpus:8 ram:512 disk:40" );
+ this.cmbImageSize.add( "vcpus:8 ram:512 disk:60" );
+ this.cmbImageSize.add( "vcpus:8 ram:512 disk:80" );
+ this.cmbImageSize.add( "vcpus:8 ram:512 disk:100" );
+ this.cmbImageSize.add( "vcpus:8 ram:1024 disk:5" );
+ this.cmbImageSize.add( "vcpus:8 ram:1024 disk:10" );
+ this.cmbImageSize.add( "vcpus:8 ram:1024 disk:20" );
+ this.cmbImageSize.add( "vcpus:8 ram:1024 disk:40" );
+ this.cmbImageSize.add( "vcpus:8 ram:1024 disk:60" );
+ this.cmbImageSize.add( "vcpus:8 ram:1024 disk:80" );
+ this.cmbImageSize.add( "vcpus:8 ram:1024 disk:100" );
+ this.cmbImageSize.add( "vcpus:8 ram:2048 disk:5" );
+ this.cmbImageSize.add( "vcpus:8 ram:2048 disk:10" );
+ this.cmbImageSize.add( "vcpus:8 ram:2048 disk:20" );
+ this.cmbImageSize.add( "vcpus:8 ram:2048 disk:40" );
+ this.cmbImageSize.add( "vcpus:8 ram:2048 disk:60" );
+ this.cmbImageSize.add( "vcpus:8 ram:2048 disk:80" );
+ this.cmbImageSize.add( "vcpus:8 ram:2048 disk:100" );
+ this.cmbImageSize.add( "vcpus:8 ram:4096 disk:5" );
+ this.cmbImageSize.add( "vcpus:8 ram:4096 disk:10" );
+ this.cmbImageSize.add( "vcpus:8 ram:4096 disk:20" );
+ this.cmbImageSize.add( "vcpus:8 ram:4096 disk:40" );
+ this.cmbImageSize.add( "vcpus:8 ram:4096 disk:60" );
+ this.cmbImageSize.add( "vcpus:8 ram:4096 disk:80" );
+ this.cmbImageSize.add( "vcpus:8 ram:4096 disk:100" );
+ this.cmbImageSize.add( "vcpus:8 ram:8192 disk:5" );
+ this.cmbImageSize.add( "vcpus:8 ram:8192 disk:10" );
+ this.cmbImageSize.add( "vcpus:8 ram:8192 disk:20" );
+ this.cmbImageSize.add( "vcpus:8 ram:8192 disk:40" );
+ this.cmbImageSize.add( "vcpus:8 ram:8192 disk:60" );
+ this.cmbImageSize.add( "vcpus:8 ram:8192 disk:80" );
+ this.cmbImageSize.add( "vcpus:8 ram:8192 disk:100" );
+ this.cmbImageSize.add( "vcpus:1 ram:512 disk:5" );
+ this.cmbImageSize.add( "vcpus:1 ram:512 disk:10" );
+ this.cmbImageSize.add( "vcpus:1 ram:512 disk:20" );
+ this.cmbImageSize.add( "vcpus:1 ram:512 disk:40" );
+ this.cmbImageSize.add( "vcpus:1 ram:512 disk:60" );
+ this.cmbImageSize.add( "vcpus:1 ram:512 disk:80" );
+ this.cmbImageSize.add( "vcpus:1 ram:512 disk:100" );
+ this.cmbImageSize.add( "vcpus:1 ram:1024 disk:5" );
+ this.cmbImageSize.add( "vcpus:1 ram:1024 disk:10" );
+ this.cmbImageSize.add( "vcpus:1 ram:1024 disk:20" );
+ this.cmbImageSize.add( "vcpus:1 ram:1024 disk:40" );
+ this.cmbImageSize.add( "vcpus:1 ram:1024 disk:60" );
+ this.cmbImageSize.add( "vcpus:1 ram:1024 disk:80" );
+ this.cmbImageSize.add( "vcpus:1 ram:1024 disk:100" );
+ this.cmbImageSize.add( "vcpus:1 ram:2048 disk:5" );
+ this.cmbImageSize.add( "vcpus:1 ram:2048 disk:10" );
+ this.cmbImageSize.add( "vcpus:1 ram:2048 disk:20" );
+ this.cmbImageSize.add( "vcpus:1 ram:2048 disk:40" );
+ this.cmbImageSize.add( "vcpus:1 ram:2048 disk:60" );
+ this.cmbImageSize.add( "vcpus:1 ram:2048 disk:80" );
+ this.cmbImageSize.add( "vcpus:1 ram:2048 disk:100" );
+ this.cmbImageSize.add( "vcpus:1 ram:4096 disk:5" );
+ this.cmbImageSize.add( "vcpus:1 ram:4096 disk:10" );
+ this.cmbImageSize.add( "vcpus:1 ram:4096 disk:20" );
+ this.cmbImageSize.add( "vcpus:1 ram:4096 disk:40" );
+ this.cmbImageSize.add( "vcpus:1 ram:4096 disk:60" );
+ this.cmbImageSize.add( "vcpus:1 ram:4096 disk:80" );
+ this.cmbImageSize.add( "vcpus:1 ram:4096 disk:100" );
+ this.cmbImageSize.add( "vcpus:1 ram:8192 disk:5" );
+ this.cmbImageSize.add( "vcpus:1 ram:8192 disk:10" );
+ this.cmbImageSize.add( "vcpus:1 ram:8192 disk:20" );
+ this.cmbImageSize.add( "vcpus:1 ram:8192 disk:40" );
+ this.cmbImageSize.add( "vcpus:1 ram:8192 disk:60" );
+ this.cmbImageSize.add( "vcpus:1 ram:8192 disk:80" );
+ this.cmbImageSize.add( "vcpus:1 ram:8192 disk:100" );
+ this.cmbImageSize.add( "vcpus:2 ram:512 disk:5" );
+ this.cmbImageSize.add( "vcpus:2 ram:512 disk:10" );
+ this.cmbImageSize.add( "vcpus:2 ram:512 disk:20" );
+ this.cmbImageSize.add( "vcpus:2 ram:512 disk:40" );
+ this.cmbImageSize.add( "vcpus:2 ram:512 disk:60" );
+ this.cmbImageSize.add( "vcpus:2 ram:512 disk:80" );
+ this.cmbImageSize.add( "vcpus:2 ram:512 disk:100" );
+ this.cmbImageSize.add( "vcpus:2 ram:1024 disk:5" );
+ this.cmbImageSize.add( "vcpus:2 ram:1024 disk:10" );
+ this.cmbImageSize.add( "vcpus:2 ram:1024 disk:20" );
+ this.cmbImageSize.add( "vcpus:2 ram:1024 disk:40" );
+ this.cmbImageSize.add( "vcpus:2 ram:1024 disk:60" );
+ this.cmbImageSize.add( "vcpus:2 ram:1024 disk:80" );
+ this.cmbImageSize.add( "vcpus:2 ram:1024 disk:100" );
+ this.cmbImageSize.add( "vcpus:2 ram:2048 disk:5" );
+ this.cmbImageSize.add( "vcpus:2 ram:2048 disk:10" );
+ this.cmbImageSize.add( "vcpus:2 ram:2048 disk:20" );
+ this.cmbImageSize.add( "vcpus:2 ram:2048 disk:40" );
+ this.cmbImageSize.add( "vcpus:2 ram:2048 disk:60" );
+ this.cmbImageSize.add( "vcpus:2 ram:2048 disk:80" );
+ this.cmbImageSize.add( "vcpus:2 ram:2048 disk:100" );
+ this.cmbImageSize.add( "vcpus:2 ram:4096 disk:5" );
+ this.cmbImageSize.add( "vcpus:2 ram:4096 disk:10" );
+ this.cmbImageSize.add( "vcpus:2 ram:4096 disk:20" );
+ this.cmbImageSize.add( "vcpus:2 ram:4096 disk:40" );
+ this.cmbImageSize.add( "vcpus:2 ram:4096 disk:60" );
+ this.cmbImageSize.add( "vcpus:2 ram:4096 disk:80" );
+ this.cmbImageSize.add( "vcpus:2 ram:4096 disk:100" );
+ this.cmbImageSize.add( "vcpus:2 ram:8192 disk:5" );
+ this.cmbImageSize.add( "vcpus:2 ram:8192 disk:10" );
+ this.cmbImageSize.add( "vcpus:2 ram:8192 disk:20" );
+ this.cmbImageSize.add( "vcpus:2 ram:8192 disk:40" );
+ this.cmbImageSize.add( "vcpus:2 ram:8192 disk:60" );
+ this.cmbImageSize.add( "vcpus:2 ram:8192 disk:80" );
+ this.cmbImageSize.add( "vcpus:2 ram:8192 disk:100" );
+ this.cmbImageSize.add( "vcpus:4 ram:512 disk:5" );
+ this.cmbImageSize.add( "vcpus:4 ram:512 disk:10" );
+ this.cmbImageSize.add( "vcpus:4 ram:512 disk:20" );
+ this.cmbImageSize.add( "vcpus:4 ram:512 disk:40" );
+ this.cmbImageSize.add( "vcpus:4 ram:512 disk:60" );
+ this.cmbImageSize.add( "vcpus:4 ram:512 disk:80" );
+ this.cmbImageSize.add( "vcpus:4 ram:512 disk:100" );
+ this.cmbImageSize.add( "vcpus:4 ram:1024 disk:5" );
+ this.cmbImageSize.add( "vcpus:4 ram:1024 disk:10" );
+ this.cmbImageSize.add( "vcpus:4 ram:1024 disk:20" );
+ this.cmbImageSize.add( "vcpus:4 ram:1024 disk:40" );
+ this.cmbImageSize.add( "vcpus:4 ram:1024 disk:60" );
+ this.cmbImageSize.add( "vcpus:4 ram:1024 disk:80" );
+ this.cmbImageSize.add( "vcpus:4 ram:1024 disk:100" );
+ this.cmbImageSize.add( "vcpus:4 ram:2048 disk:5" );
+ this.cmbImageSize.add( "vcpus:4 ram:2048 disk:10" );
+ this.cmbImageSize.add( "vcpus:4 ram:2048 disk:20" );
+ this.cmbImageSize.add( "vcpus:4 ram:2048 disk:40" );
+ this.cmbImageSize.add( "vcpus:4 ram:2048 disk:60" );
+ this.cmbImageSize.add( "vcpus:4 ram:2048 disk:80" );
+ this.cmbImageSize.add( "vcpus:4 ram:2048 disk:100" );
+ this.cmbImageSize.add( "vcpus:4 ram:4096 disk:5" );
+ this.cmbImageSize.add( "vcpus:4 ram:4096 disk:10" );
+ this.cmbImageSize.add( "vcpus:4 ram:4096 disk:20" );
+ this.cmbImageSize.add( "vcpus:4 ram:4096 disk:40" );
+ this.cmbImageSize.add( "vcpus:4 ram:4096 disk:60" );
+ this.cmbImageSize.add( "vcpus:4 ram:4096 disk:80" );
+ this.cmbImageSize.add( "vcpus:4 ram:4096 disk:100" );
+ this.cmbImageSize.add( "vcpus:4 ram:8192 disk:5" );
+ this.cmbImageSize.add( "vcpus:4 ram:8192 disk:10" );
+ this.cmbImageSize.add( "vcpus:4 ram:8192 disk:20" );
+ this.cmbImageSize.add( "vcpus:4 ram:8192 disk:40" );
+ this.cmbImageSize.add( "vcpus:4 ram:8192 disk:60" );
+ this.cmbImageSize.add( "vcpus:4 ram:8192 disk:80" );
+ this.cmbImageSize.add( "vcpus:4 ram:8192 disk:100" );
+ this.cmbImageSize.add( "vcpus:8 ram:512 disk:5" );
+ this.cmbImageSize.add( "vcpus:8 ram:512 disk:10" );
+ this.cmbImageSize.add( "vcpus:8 ram:512 disk:20" );
+ this.cmbImageSize.add( "vcpus:8 ram:512 disk:40" );
+ this.cmbImageSize.add( "vcpus:8 ram:512 disk:60" );
+ this.cmbImageSize.add( "vcpus:8 ram:512 disk:80" );
+ this.cmbImageSize.add( "vcpus:8 ram:512 disk:100" );
+ this.cmbImageSize.add( "vcpus:8 ram:1024 disk:5" );
+ this.cmbImageSize.add( "vcpus:8 ram:1024 disk:10" );
+ this.cmbImageSize.add( "vcpus:8 ram:1024 disk:20" );
+ this.cmbImageSize.add( "vcpus:8 ram:1024 disk:40" );
+ this.cmbImageSize.add( "vcpus:8 ram:1024 disk:60" );
+ this.cmbImageSize.add( "vcpus:8 ram:1024 disk:80" );
+ this.cmbImageSize.add( "vcpus:8 ram:1024 disk:100" );
+ this.cmbImageSize.add( "vcpus:8 ram:2048 disk:5" );
+ this.cmbImageSize.add( "vcpus:8 ram:2048 disk:10" );
+ this.cmbImageSize.add( "vcpus:8 ram:2048 disk:20" );
+ this.cmbImageSize.add( "vcpus:8 ram:2048 disk:40" );
+ this.cmbImageSize.add( "vcpus:8 ram:2048 disk:60" );
+ this.cmbImageSize.add( "vcpus:8 ram:2048 disk:80" );
+ this.cmbImageSize.add( "vcpus:8 ram:2048 disk:100" );
+ this.cmbImageSize.add( "vcpus:8 ram:4096 disk:5" );
+ this.cmbImageSize.add( "vcpus:8 ram:4096 disk:10" );
+ this.cmbImageSize.add( "vcpus:8 ram:4096 disk:20" );
+ this.cmbImageSize.add( "vcpus:8 ram:4096 disk:40" );
+ this.cmbImageSize.add( "vcpus:8 ram:4096 disk:60" );
+ this.cmbImageSize.add( "vcpus:8 ram:4096 disk:80" );
+ this.cmbImageSize.add( "vcpus:8 ram:4096 disk:100" );
+ this.cmbImageSize.add( "vcpus:8 ram:8192 disk:5" );
+ this.cmbImageSize.add( "vcpus:8 ram:8192 disk:10" );
+ this.cmbImageSize.add( "vcpus:8 ram:8192 disk:20" );
+ this.cmbImageSize.add( "vcpus:8 ram:8192 disk:40" );
+ this.cmbImageSize.add( "vcpus:8 ram:8192 disk:60" );
+ this.cmbImageSize.add( "vcpus:8 ram:8192 disk:80" );
+ this.cmbImageSize.add( "vcpus:8 ram:8192 disk:100" );
+ this.cmbImageSize.add( "vcpus:1 ram:6144 disk:100" );
+ this.cmbImageSize.add( "vcpus:1 ram:6144 disk:100" );
+ this.cmbImageSize.add( "vcpus:2 ram:6144 disk:100" );
+ this.cmbImageSize.add( "vcpus:2 ram:6144 disk:100" );
+ this.cmbImageSize.add( "vcpus:2 ram:6144 disk:80" );
+ this.cmbImageSize.add( "vcpus:2 ram:6144 disk:60" );
+ this.cmbImageSize.add( "vcpus:2 ram:6144 disk:40" );
+ this.cmbImageSize.add( "vcpus:2 ram:6144 disk:40" );
+ this.cmbImageSize.add( "vcpus:2 ram:6144 disk:60" );
+ this.cmbImageSize.add( "vcpus:2 ram:6144 disk:80" );
+ this.cmbImageSize.add( "vcpus:1 ram:6144 disk:5" );
+ this.cmbImageSize.add( "vcpus:1 ram:6144 disk:10" );
+ this.cmbImageSize.add( "vcpus:1 ram:6144 disk:20" );
+ this.cmbImageSize.add( "vcpus:1 ram:6144 disk:40" );
+ this.cmbImageSize.add( "vcpus:1 ram:6144 disk:60" );
+ this.cmbImageSize.add( "vcpus:1 ram:6144 disk:80" );
+ this.cmbImageSize.add( "vcpus:1 ram:6144 disk:5" );
+ this.cmbImageSize.add( "vcpus:1 ram:6144 disk:10" );
+ this.cmbImageSize.add( "vcpus:1 ram:6144 disk:20" );
+ this.cmbImageSize.add( "vcpus:1 ram:6144 disk:40" );
+ this.cmbImageSize.add( "vcpus:1 ram:6144 disk:60" );
+ this.cmbImageSize.add( "vcpus:1 ram:6144 disk:80" );
+ this.cmbImageSize.add( "vcpus:2 ram:6144 disk:5" );
+ this.cmbImageSize.add( "vcpus:2 ram:6144 disk:10" );
+ this.cmbImageSize.add( "vcpus:2 ram:6144 disk:20" );
+ this.cmbImageSize.add( "vcpus:2 ram:6144 disk:5" );
+ this.cmbImageSize.add( "vcpus:2 ram:6144 disk:10" );
+ this.cmbImageSize.add( "vcpus:2 ram:6144 disk:20" );
+ this.cmbImageSize.add( "vcpus:4 ram:6144 disk:5" );
+ this.cmbImageSize.add( "vcpus:4 ram:6144 disk:10" );
+ this.cmbImageSize.add( "vcpus:4 ram:6144 disk:20" );
+ this.cmbImageSize.add( "vcpus:4 ram:6144 disk:40" );
+ this.cmbImageSize.add( "vcpus:4 ram:6144 disk:60" );
+ this.cmbImageSize.add( "vcpus:4 ram:6144 disk:80" );
+ this.cmbImageSize.add( "vcpus:4 ram:6144 disk:100" );
+ this.cmbImageSize.add( "vcpus:4 ram:6144 disk:5" );
+ this.cmbImageSize.add( "vcpus:4 ram:6144 disk:10" );
+ this.cmbImageSize.add( "vcpus:4 ram:6144 disk:20" );
+ this.cmbImageSize.add( "vcpus:4 ram:6144 disk:40" );
+ this.cmbImageSize.add( "vcpus:4 ram:6144 disk:60" );
+ this.cmbImageSize.add( "vcpus:4 ram:6144 disk:80" );
+ this.cmbImageSize.add( "vcpus:4 ram:6144 disk:100" );
+ this.cmbImageSize.add( "vcpus:8 ram:6144 disk:5" );
+ this.cmbImageSize.add( "vcpus:8 ram:6144 disk:10" );
+ this.cmbImageSize.add( "vcpus:8 ram:6144 disk:20" );
+ this.cmbImageSize.add( "vcpus:8 ram:6144 disk:40" );
+ this.cmbImageSize.add( "vcpus:8 ram:6144 disk:60" );
+ this.cmbImageSize.add( "vcpus:8 ram:6144 disk:80" );
+ this.cmbImageSize.add( "vcpus:8 ram:6144 disk:100" );
+ this.cmbImageSize.add( "vcpus:8 ram:6144 disk:5" );
+ this.cmbImageSize.add( "vcpus:8 ram:6144 disk:10" );
+ this.cmbImageSize.add( "vcpus:8 ram:6144 disk:20" );
+ this.cmbImageSize.add( "vcpus:8 ram:6144 disk:40" );
+ this.cmbImageSize.add( "vcpus:8 ram:6144 disk:60" );
+ this.cmbImageSize.add( "vcpus:8 ram:6144 disk:80" );
+ this.cmbImageSize.add( "vcpus:8 ram:6144 disk:100" );
+ this.cmbImageSize.add( "vcpus:8 ram:6144 disk:diskdump" );
+ this.cmbImageSize.add( "vcpus:8 ram:6144 disk:diskdump" );
+ this.cmbImageSize.add( "vcpus:8 ram:6144 disk:diskdump" );
+ this.cmbImageSize.add( "vcpus:8 ram:6144 disk:diskdump" );
+ this.cmbImageSize.add( "vcpus:8 ram:6144 disk:diskdump" );
+ this.cmbImageSize.add( "vcpus:8 ram:6144 disk:diskdump" );
+ ///////////////////////////////////////////////////////
+ this.cmbImageSize.setEditable( false );
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
+ gd.horizontalSpan = 2;
+ gd.widthHint = 200;
+ this.cmbImageSize.setLayoutData( gd );
+ // Listener for Flavor
+ this.cmbImageSize.addSelectionListener( new SelectionListener() {
- copySelectedFileToCloudProject( new File(result), tmp );
+ @Override
+ public void widgetSelected( final SelectionEvent e ) {
+ createNodeFlavorProperties( ApplicationComponentNameSection.this.cmbImageSize.getText() );
+ }
- IProgressMonitor monitor = null;
- try {
- CloudModel.getRoot().refresh( monitor );
- } catch( ProblemException e2 ) {
- e2.printStackTrace();
- }
- // Refresh Palette Compartments
- getDiagramTypeProvider().getFeatureProvider()
- .getDiagramTypeProvider()
- .getDiagramBehavior()
- .refreshPalette();
+ @Override
+ public void widgetDefaultSelected( final SelectionEvent e ) {
+ // TODO Auto-generated method stub
+ }
+ } );
+ // KeyPair Label
+ CLabel keypairLabel = factory.createCLabel( client, "Keypair:" ); //$NON-NLS-1$
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
+ gd.widthHint = 80;
+ keypairLabel.setLayoutData( gd );
+ // KeyPair text
+ this.keypairText = factory.createText( client, "" ); //$NON-NLS-1$
+ this.keypairText.setEditable( true );
+ gd = new GridData();
+ gd.widthHint = 160;
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
+ this.keypairText.setLayoutData( gd );
+ this.keypairText.addModifyListener( this );
+ // Select KeyPair Button
+ this.keypairSelect = new Button( client, SWT.PUSH );
+ this.keypairSelect.setText( " Select... " ); //$NON-NLS-1$
+ gd = new GridData();
+ gd.widthHint = 80;
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ this.keypairSelect.setLayoutData( gd );
+ // Listener for Add button
+ this.keypairSelect.addSelectionListener( new SelectionListener() {
+ @Override
+ public void widgetSelected( final SelectionEvent e ) {
+ FileDialog dialog = new FileDialog( parent.getShell(), SWT.OPEN );
+ dialog.setText( "Select Keypair " ); //$NON-NLS-1$
+ dialog.setFilterExtensions( new String[]{
+ "*.pub"} ); // filter only pub keys //$NON-NLS-1$
+ // dialog.setFilterPath("c:\\temp");
+ String result = dialog.open();
+ if( result != null ) {
+ CreateVMIFeature createImageFeature = new CreateVMIFeature( new ToscaFeatureProvider( getDiagramTypeProvider() ) );
+ TDeploymentArtifact deploymentArtifact = ToscaFactory.eINSTANCE.createTDeploymentArtifact();
+ deploymentArtifact.setName( dialog.getFileName() );
+ deploymentArtifact.setArtifactType( new QName( "KeyPair" ) ); //$NON-NLS-1$
+ createImageFeature.setContextObject( deploymentArtifact );
+ CreateContext createContext = new CreateContext();
+ createContext.setTargetContainer( ( ContainerShape )getSelectedPictogramElement() );
+ if( createImageFeature.canCreate( createContext ) )
+ createImageFeature.create( createContext );
+ refresh();
+ // Add uploaded image to Project Artifacts folder
+ IWorkbenchPage activePage = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow()
+ .getActivePage();
+ IEditorInput input = activePage.getActiveEditor().getEditorInput();
+ IFile file = null;
+ if( input instanceof ToscaDiagramEditorInput ) {
+ file = ( ( ToscaDiagramEditorInput )input ).getToscaFile();
+ }
+ IProject project = file.getProject();
+ String target = Platform.getLocation()
+ + System.getProperty( "file.separator" ) + project.getName() + System.getProperty( "file.separator" ) + "Artifacts" +System.getProperty( "file.separator" )+"Deployment Scripts"+System.getProperty( "file.separator" ) + dialog.getFileName(); //$NON-NLS-1$ //$NON-NLS-2$
+ String source = dialog.getFilterPath()
+ + System.getProperty( "file.separator" ) + dialog.getFileName(); //$NON-NLS-1$
+ File targetFile = new File( target );
+ if( !targetFile.exists() ) {
+ try {
+ new LocalFile( new File( source ) ).copy( new LocalFile( new File( target ) ),
+ EFS.NONE,
+ null );
+ } catch( CoreException e1 ) {
+ e1.printStackTrace();
+ }
+ }
+ // File tmp = new File( targetPath );
+ // try {
+ // tmp.createNewFile();
+ // tmp.
+ // } catch( IOException e1 ) {
+ // // TODO Auto-generated catch block
+ // e1.printStackTrace();
+ // }
+ IProgressMonitor monitor = null;
+ try {
+ CloudModel.getRoot().refresh( monitor );
+ } catch( ProblemException e2 ) {
+ e2.printStackTrace();
+ }
+// // Refresh Palette Compartments
+// getDiagramTypeProvider().getFeatureProvider()
+// .getDiagramTypeProvider()
+// .getDiagramBehavior()
+// .refreshPalette();
+ ApplicationComponentNameSection.this.keypairText.setText( dialog.getFileName() );
+ }
+ }
- CreateVMIFeature createImageFeature = new CreateVMIFeature( new ToscaFeatureProvider( getDiagramTypeProvider() ) );
- TDeploymentArtifact deploymentArtifact = ToscaFactory.eINSTANCE.createTDeploymentArtifact();
- deploymentArtifact.setName( dialog.getFileName());
- deploymentArtifact.setArtifactRef( new QName (imageId) );
- deploymentArtifact.setArtifactType( new QName( typesNamespace, imageType, typesPrefix ) ); //$NON-NLS-1$
- //deploymentArtifact.setArtifactType( new QName( "VMI" ) ); //$NON-NLS-1$
- createImageFeature.setContextObject( deploymentArtifact );
- CreateContext createContext = new CreateContext();
- createContext.setTargetContainer( ( ContainerShape )getSelectedPictogramElement() );
- if( createImageFeature.canCreate( createContext ) )
- createImageFeature.create( createContext );
- refresh();
+ @Override
+ public void widgetDefaultSelected( final SelectionEvent e ) {
+ // TODO Auto-generated method stub
+ }
+ } );
+ // Add section components to the toolkit
+ toolkit.adapt( vmImageLabel, true, true );
+ toolkit.adapt( this.cmbImageSize, true, true );
+ toolkit.adapt( valueLabel, true, true );
+ toolkit.adapt( this.nameText, true, true );
+ toolkit.adapt( imageLabel, true, true );
+ toolkit.adapt( this.imageText, true, true );
+ toolkit.adapt( keypairLabel, true, true );
+ toolkit.adapt( this.keypairText, true, true );
+// toolkit.adapt( vmDecsrLabel, true, true );
+// toolkit.adapt( this.descrText, true, true);
+ section.setClient( client );
+ // Application Component Instances Section
+ Section sectionInstances = toolkit.createSection( parent, Section.TITLE_BAR );
+ sectionInstances.setText( "Number of Instances" ); //$NON-NLS-1$
+ Composite clientInstances = toolkit.createComposite( sectionInstances,
+ SWT.WRAP );
+ GridLayout layoutInstances = new GridLayout();
+ layoutInstances.numColumns = 2;
+ layoutInstances.marginTop = 15;
+ layoutInstances.verticalSpacing = 15;
+ layoutInstances.marginWidth = 2;
+ layoutInstances.marginHeight = 2;
+ clientInstances.setLayout( layoutInstances );
+ GridData gdInstances;
- }
- }
+ CLabel minInstancesLabel = factory.createCLabel( clientInstances, "Min:" ); //$NON-NLS-1$
+ gdInstances = new GridData();
+ gdInstances.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gdInstances.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
+ // gd.widthHint=STANDARD_LABEL_WIDTH;
+ minInstancesLabel.setLayoutData( gdInstances );
+ this.minInstancesText = factory.createText( clientInstances, "" ); //$NON-NLS-1$
+ this.minInstancesText.setEditable( true );
+ gdInstances = new GridData();
+ gdInstances.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gdInstances.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
+ gdInstances.widthHint = 160;
+ this.minInstancesText.setLayoutData( gdInstances );
+ this.minInstancesText.addModifyListener( this );
+ CLabel maxInstancesLabel = factory.createCLabel( clientInstances, "Max:" ); //$NON-NLS-1$
+ gdInstances = new GridData();
+ gdInstances.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gdInstances.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
+ // gd.widthHint=STANDARD_LABEL_WIDTH;
+ maxInstancesLabel.setLayoutData( gdInstances );
+ this.maxInstancesText = factory.createText( clientInstances, "" ); //$NON-NLS-1$
+ this.maxInstancesText.setEditable( true );
+ gdInstances = new GridData();
+ gdInstances.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gdInstances.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
+ gdInstances.widthHint = 160;
+ this.maxInstancesText.setLayoutData( gdInstances );
+ this.maxInstancesText.addModifyListener( this );
+ // Add section components to the toolkit
+ toolkit.adapt( valueLabel, true, true );
+ toolkit.adapt( this.nameText, true, true );
+ toolkit.adapt( imageLabel, true, true );
+ toolkit.adapt( this.imageText, true, true );
+ section.setClient( client );
+ toolkit.adapt( minInstancesLabel, true, true );
+ toolkit.adapt( maxInstancesLabel, true, true );
+ toolkit.adapt( this.minInstancesText, true, true );
+ toolkit.adapt( this.maxInstancesText, true, true );
+ sectionInstances.setClient( clientInstances );
+ }
- @Override
- public void widgetDefaultSelected( final SelectionEvent e ) {
- // TODO Auto-generated method stub
- }
- } );
+ /*
+ * Refresh values of max and min instances
+ */
+ void refreshInstances() {
+ PictogramElement pe = getSelectedPictogramElement();
+ if( pe != null ) {
+ Object bo = Graphiti.getLinkService()
+ .getBusinessObjectForLinkedPictogramElement( pe );
+ if( bo == null )
+ return;
+ TNodeTemplateExtension appComponent;
+ if( bo instanceof TDeploymentArtifact ) {
+ PictogramElement parentPE = Graphiti.getPeService()
+ .getPictogramElementParent( pe );
+ appComponent = ( TNodeTemplateExtension )Graphiti.getLinkService()
+ .getBusinessObjectForLinkedPictogramElement( parentPE );
+ } else { // bo instanceof TNodeTemplate
+ appComponent = ( TNodeTemplateExtension )bo;
+ }
- //VM Description Label
- CLabel vmDecsrLabel = factory.createCLabel( client, "VM Description:" ); //$NON-NLS-1$
- gd = new GridData();
- gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
- gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
- gd.widthHint = 80;
- // gd.widthHint=STANDARD_LABEL_WIDTH;
- // VM Description text
- vmDecsrLabel.setLayoutData( gd );
- this.descrText = factory.createText( client, "" ); //$NON-NLS-1$
- this.descrText.setEditable( false );
- gd = new GridData();
- gd.horizontalSpan = 2;
- gd.widthHint = 160;
- gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
- gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
- this.descrText.setLayoutData( gd );
- // VM Image Flavor label
- CLabel vmImageLabel = factory.createCLabel( client, "VM Type:" ); //$NON-NLS-1$
- gd = new GridData();
- gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
- gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
- gd.widthHint = 80;
- vmImageLabel.setLayoutData( gd );
- // Combo - VM Image Flavor
- this.cmbImageSize = new CCombo( client, SWT.BORDER );
- this.cmbImageSize.setEnabled( true );
+ String minInstances = Integer.toString( appComponent.getMinInstances() );
+ String maxInstances = ( ( BigInteger )appComponent.getMaxInstances() ).toString();
+ if( minInstances.compareTo( "-1" ) == 0 ) //$NON-NLS-1$
+ minInstances = ""; //$NON-NLS-1$
+ if( maxInstances.compareTo( "-1" ) == 0 ) //$NON-NLS-1$
+ maxInstances = ""; //$NON-NLS-1$
+ this.minInstancesText.setText( minInstances );
+ this.maxInstancesText.setText( maxInstances );
+ }
+ }
- // TODO - nickl For now use Amazon Flavors - get them from IS
- ArrayList<VirtualMachineImageFlavor> flavors = MockUpInfoSystem
- .getInstance().getFlavors();
+ // Refresh Tab
+ @Override
+ public void refresh() {
+ PictogramElement pe = getSelectedPictogramElement();
+ if( pe != null ) {
+ final Object bo = Graphiti.getLinkService()
+ .getBusinessObjectForLinkedPictogramElement( pe );
+ if( bo == null )
+ return;
+ TNodeTemplate appComponent;
+ if( bo instanceof TDeploymentArtifact ) {
+ PictogramElement parentPE = Graphiti.getPeService()
+ .getPictogramElementParent( pe );
+ appComponent = ( TNodeTemplate )Graphiti.getLinkService()
+ .getBusinessObjectForLinkedPictogramElement( parentPE );
+ } else { // bo instanceof TNodeTemplate
+ appComponent = ( TNodeTemplate )bo;
+ }
+ String name = appComponent.getName();
+ this.nameText.setText( name == null
+ ? "" : name ); //$NON-NLS-1$
+ // set Image Artifact
+ String imageName = null;
+ TDeploymentArtifacts deploymentArtifacts = appComponent.getDeploymentArtifacts();
+ if( deploymentArtifacts != null ) {
+ for( TDeploymentArtifact artifact : deploymentArtifacts.getDeploymentArtifact() )
+ {
+ if( artifact.getArtifactType().getLocalPart().equals( imageType ) ) { //$NON-NLS-1$
+ imageName = artifact.getName();
+ break;
+ }
+ }
+ }
+ this.imageText.setText( imageName == null
+ ? "" : imageName ); //$NON-NLS-1$
+
+ // set VM Flavor
+ if ( appComponent.getProperties() != null ){
+ NodePropertiesType nodeProperties = (NodePropertiesType) appComponent.getProperties().getAny().get( 0 ).getValue();
+ String flavor = nodeProperties.getFlavor();
+ this.cmbImageSize.setText( flavor == null
+ ? "" : flavor ); //$NON-NLS-1$
+ }
+ else{
+ this.cmbImageSize.setText( "" );
+ }
+
+ if( !( bo instanceof TDeploymentArtifact ) )
+ refreshInstances();
+ }
+ }
- for (VirtualMachineImageFlavor f : flavors) {
- this.cmbImageSize.add(f.getName());
- }
+ // Updates Application name or number of instances according the triggered
+ // listener
+ @Override
+ public void modifyText( final ModifyEvent e ) {
+ PictogramElement pe = getSelectedPictogramElement();
+ if( pe != null ) {
+ final Object bo = Graphiti.getLinkService()
+ .getBusinessObjectForLinkedPictogramElement( pe );
+ // the filter assured, that it is a TNodeTemplate
+ if( bo == null )
+ return;
+ final TNodeTemplateExtension nodeTemplate;
+ if( bo instanceof TDeploymentArtifact ) {
+ PictogramElement parentPE = Graphiti.getPeService()
+ .getPictogramElementParent( pe );
+ nodeTemplate = ( TNodeTemplateExtension )Graphiti.getLinkService()
+ .getBusinessObjectForLinkedPictogramElement( parentPE );
+ } else { // bo instanceof TNodeTemplate
+ nodeTemplate = ( TNodeTemplateExtension )bo;
+ }
+ // nameText Listener
+ if( e.widget == this.nameText ) {
+ TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain( bo );
+ editingDomain.getCommandStack()
+ .execute( new RecordingCommand( editingDomain ) {
- this.cmbImageSize.setEditable( false );
- gd = new GridData();
- gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
- gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
- gd.horizontalSpan = 2;
- gd.widthHint = 200;
- this.cmbImageSize.setLayoutData( gd );
- // Listener for Flavor
- this.cmbImageSize.addSelectionListener( new SelectionListener() {
+ protected void doExecute() {
+ nodeTemplate.setName( ApplicationComponentNameSection.this.nameText.getText() );
+ }
+ } );
+ }
+ // minInstancesText Listener
+ else if( e.widget == this.minInstancesText ) {
+ TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain( bo );
+ editingDomain.getCommandStack()
+ .execute( new RecordingCommand( editingDomain ) {
- @Override
- public void widgetSelected( final SelectionEvent e ) {
- createNodeFlavorProperties( ApplicationComponentNameSection.this.cmbImageSize.getText() );
- }
+ protected void doExecute() {
+ if( nodeTemplate != null ) {
+ if( ApplicationComponentNameSection.this.minInstancesText.getText()
+ .equals( "" ) ) { //$NON-NLS-1$
+ // nodeTemplate.setMinInstances( -1 );
+ } else
+ nodeTemplate.setMinInstances( Integer.parseInt( ApplicationComponentNameSection.this.minInstancesText.getText() ) );
+ }
+ }
+ } );
+ }
+ // maxInstancesText Listener
+ else if( e.widget == this.maxInstancesText ) {
+ TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain( bo );
+ editingDomain.getCommandStack()
+ .execute( new RecordingCommand( editingDomain ) {
- @Override
- public void widgetDefaultSelected( final SelectionEvent e ) {
- // TODO Auto-generated method stub
- }
- } );
- // KeyPair Label
- CLabel keypairLabel = factory.createCLabel( client, "Keypair:" ); //$NON-NLS-1$
- gd = new GridData();
- gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
- gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
- gd.widthHint = 80;
- keypairLabel.setLayoutData( gd );
- // KeyPair text
- this.keypairText = factory.createText( client, "" ); //$NON-NLS-1$
- this.keypairText.setEditable( true );
- gd = new GridData();
- gd.widthHint = 160;
- gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
- gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
- this.keypairText.setLayoutData( gd );
- this.keypairText.addModifyListener( this );
- // Select KeyPair Button
- this.keypairSelect = new Button( client, SWT.PUSH );
- this.keypairSelect.setText( " Select... " ); //$NON-NLS-1$
- gd = new GridData();
- gd.widthHint = 80;
- gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
- this.keypairSelect.setLayoutData( gd );
- // Listener for Add button
- this.keypairSelect.addSelectionListener( new SelectionListener() {
+ protected void doExecute() {
+ if( ApplicationComponentNameSection.this.maxInstancesText.getText()
+ .compareTo( "" ) == 0 ) { //$NON-NLS-1$
+ // nodeTemplate.setMaxInstances( ( BigInteger
+ // )BigInteger.valueOf(-1) );
+ } else
+ nodeTemplate.setMaxInstances( ( BigInteger )BigInteger.valueOf( Integer.parseInt( ApplicationComponentNameSection.this.maxInstancesText.getText() ) ) );
+ }
+ } );
+ }
+ }
+ }
- @Override
- public void widgetSelected( final SelectionEvent e ) {
- FileDialog dialog = new FileDialog( parent.getShell(), SWT.OPEN );
- dialog.setText( "Select Keypair " ); //$NON-NLS-1$
- dialog.setFilterExtensions( new String[]{
- "*.pub"} ); // filter only pub keys //$NON-NLS-1$
- // dialog.setFilterPath("c:\\temp");
- String result = dialog.open();
- if( result != null ) {
- CreateVMIFeature createImageFeature = new CreateVMIFeature( new ToscaFeatureProvider( getDiagramTypeProvider() ) );
- TDeploymentArtifact deploymentArtifact = ToscaFactory.eINSTANCE.createTDeploymentArtifact();
- deploymentArtifact.setName( dialog.getFileName() );
- deploymentArtifact.setArtifactType( new QName( "KeyPair" ) ); //$NON-NLS-1$
- createImageFeature.setContextObject( deploymentArtifact );
- CreateContext createContext = new CreateContext();
- createContext.setTargetContainer( ( ContainerShape )getSelectedPictogramElement() );
- if( createImageFeature.canCreate( createContext ) )
- createImageFeature.create( createContext );
- refresh();
- // Add uploaded image to Project Artifacts folder
- IWorkbenchPage activePage = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow()
- .getActivePage();
- IEditorInput input = activePage.getActiveEditor().getEditorInput();
- IFile file = null;
- if( input instanceof ToscaDiagramEditorInput ) {
- file = ( ( ToscaDiagramEditorInput )input ).getToscaFile();
- }
- IProject project = file.getProject();
- String target = Platform.getLocation()
- + System.getProperty( "file.separator" ) + project.getName() + System.getProperty( "file.separator" ) + "Artifacts" +System.getProperty( "file.separator" )+"Deployment Scripts"+System.getProperty( "file.separator" ) + dialog.getFileName(); //$NON-NLS-1$ //$NON-NLS-2$
- String source = dialog.getFilterPath()
- + System.getProperty( "file.separator" ) + dialog.getFileName(); //$NON-NLS-1$
- File targetFile = new File( target );
- if( !targetFile.exists() ) {
- try {
- new LocalFile( new File( source ) ).copy( new LocalFile( new File( target ) ),
- EFS.NONE,
- null );
- } catch( CoreException e1 ) {
- e1.printStackTrace();
- }
- }
- // File tmp = new File( targetPath );
- // try {
- // tmp.createNewFile();
- // tmp.
- // } catch( IOException e1 ) {
- // // TODO Auto-generated catch block
- // e1.printStackTrace();
- // }
- IProgressMonitor monitor = null;
- try {
- CloudModel.getRoot().refresh( monitor );
- } catch( ProblemException e2 ) {
- e2.printStackTrace();
- }
- // Refresh Palette Compartments
- getDiagramTypeProvider().getFeatureProvider()
- .getDiagramTypeProvider()
- .getDiagramBehavior()
- .refreshPalette();
- ApplicationComponentNameSection.this.keypairText.setText( dialog.getFileName() );
- }
- }
+ private void createNodeFlavorProperties( String flavor ) {
+ PictogramElement pe = getSelectedPictogramElement();
+ final TNodeTemplateExtension appComponent;
+ Object bo = Graphiti.getLinkService()
+ .getBusinessObjectForLinkedPictogramElement( pe );
+ if( bo == null )
+ return;
+ if( bo instanceof TDeploymentArtifact ) {
+ PictogramElement parentPE = Graphiti.getPeService()
+ .getPictogramElementParent( pe );
+ appComponent = ( TNodeTemplateExtension )Graphiti.getLinkService()
+ .getBusinessObjectForLinkedPictogramElement( parentPE );
+ } else { // bo instanceof TNodeTemplate
+ appComponent = ( TNodeTemplateExtension )bo;
+ }
+ // Create Flavor Properties
+ NodePropertiesType nodeProperties = Tosca_Elasticity_ExtensionsFactory.eINSTANCE.createNodePropertiesType();
+ nodeProperties.setFlavor( flavor );
+ // Set the Properties of the Policy Template
+ final PropertiesType properties = ToscaFactory.eINSTANCE.createPropertiesType();
+ // Add the SYBL Policy to the FeatureMap of the Policy's Properties element
+ Entry e = FeatureMapUtil.createEntry( Tosca_Elasticity_ExtensionsPackage.eINSTANCE.getDocumentRoot_NodeProperties(),
+ nodeProperties );
+ properties.getAny().add( e );
+ TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain( appComponent );
+ editingDomain.getCommandStack()
+ .execute( new RecordingCommand( editingDomain ) {
- @Override
- public void widgetDefaultSelected( final SelectionEvent e ) {
- // TODO Auto-generated method stub
- }
- } );
- // Add section components to the toolkit
- toolkit.adapt( vmImageLabel, true, true );
- toolkit.adapt( this.cmbImageSize, true, true );
- toolkit.adapt( valueLabel, true, true );
- toolkit.adapt( this.nameText, true, true );
- toolkit.adapt( imageLabel, true, true );
- toolkit.adapt( this.imageText, true, true );
- toolkit.adapt( keypairLabel, true, true );
- toolkit.adapt( this.keypairText, true, true );
- toolkit.adapt( vmDecsrLabel, true, true );
- toolkit.adapt( this.descrText, true, true);
- section.setClient( client );
- // Application Component Instances Section
- Section sectionInstances = toolkit.createSection( parent, Section.TITLE_BAR );
- sectionInstances.setText( "Number of Instances" ); //$NON-NLS-1$
- Composite clientInstances = toolkit.createComposite( sectionInstances,
- SWT.WRAP );
- GridLayout layoutInstances = new GridLayout();
- layoutInstances.numColumns = 2;
- layoutInstances.marginTop = 15;
- layoutInstances.verticalSpacing = 15;
- layoutInstances.marginWidth = 2;
- layoutInstances.marginHeight = 2;
- clientInstances.setLayout( layoutInstances );
- GridData gdInstances;
- CLabel initialInstancesLabel = factory.createCLabel( clientInstances, "Initial:" ); //$NON-NLS-1$
- gdInstances = new GridData();
- gdInstances.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
- gdInstances.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
- // gd.widthHint=STANDARD_LABEL_WIDTH;
- initialInstancesLabel.setLayoutData( gdInstances );
- this.initialInstancesText = factory.createText( clientInstances, "1" ); //$NON-NLS-1$
- this.initialInstancesText.setEditable( true );
- gdInstances = new GridData();
- gdInstances.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
- gdInstances.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
- gdInstances.widthHint = 160;
- this.initialInstancesText.setLayoutData( gdInstances );
- this.initialInstancesText.addModifyListener( this );
- CLabel minInstancesLabel = factory.createCLabel( clientInstances, "Min:" ); //$NON-NLS-1$
- gdInstances = new GridData();
- gdInstances.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
- gdInstances.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
- // gd.widthHint=STANDARD_LABEL_WIDTH;
- minInstancesLabel.setLayoutData( gdInstances );
- this.minInstancesText = factory.createText( clientInstances, "" ); //$NON-NLS-1$
- this.minInstancesText.setEditable( true );
- gdInstances = new GridData();
- gdInstances.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
- gdInstances.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
- gdInstances.widthHint = 160;
- this.minInstancesText.setLayoutData( gdInstances );
- this.minInstancesText.addModifyListener( this );
- CLabel maxInstancesLabel = factory.createCLabel( clientInstances, "Max:" ); //$NON-NLS-1$
- gdInstances = new GridData();
- gdInstances.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
- gdInstances.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
- // gd.widthHint=STANDARD_LABEL_WIDTH;
- maxInstancesLabel.setLayoutData( gdInstances );
- this.maxInstancesText = factory.createText( clientInstances, "" ); //$NON-NLS-1$
- this.maxInstancesText.setEditable( true );
- gdInstances = new GridData();
- gdInstances.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
- gdInstances.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
- gdInstances.widthHint = 160;
- this.maxInstancesText.setLayoutData( gdInstances );
- this.maxInstancesText.addModifyListener( this );
- // Add section components to the toolkit
- toolkit.adapt( valueLabel, true, true );
- toolkit.adapt( this.nameText, true, true );
- toolkit.adapt( imageLabel, true, true );
- toolkit.adapt( this.imageText, true, true );
- section.setClient( client );
- toolkit.adapt( minInstancesLabel, true, true );
- toolkit.adapt( maxInstancesLabel, true, true );
- toolkit.adapt( this.minInstancesText, true, true );
- toolkit.adapt( this.maxInstancesText, true, true );
- sectionInstances.setClient( clientInstances );
- }
+ @Override
+ protected void doExecute() {
+ appComponent.setProperties( properties );
+ }
+ } );
+ }
- /*
- * Refresh values of max and min instances
- */
- void refreshInstances() {
- PictogramElement pe = getSelectedPictogramElement();
- if( pe != null ) {
- Object bo = Graphiti.getLinkService()
- .getBusinessObjectForLinkedPictogramElement( pe );
- if( bo == null )
- return;
- TNodeTemplateExtension appComponent;
- if( bo instanceof TDeploymentArtifact ) {
- PictogramElement parentPE = Graphiti.getPeService()
- .getPictogramElementParent( pe );
- appComponent = ( TNodeTemplateExtension )Graphiti.getLinkService()
- .getBusinessObjectForLinkedPictogramElement( parentPE );
- } else { // bo instanceof TNodeTemplate
- appComponent = ( TNodeTemplateExtension )bo;
- }
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ // TODO Auto-generated method stub
+
+ }
- String initInstances = Integer.toString( appComponent.getInitInstances() );
- this.initialInstancesText.setText( initInstances );
- String minInstances = Integer.toString( appComponent.getMinInstances() );
- String maxInstances = ( ( BigInteger )appComponent.getMaxInstances() ).toString();
- if( minInstances.compareTo( "-1" ) == 0 ) //$NON-NLS-1$
- minInstances = ""; //$NON-NLS-1$
- if( maxInstances.compareTo( "-1" ) == 0 ) //$NON-NLS-1$
- maxInstances = ""; //$NON-NLS-1$
- this.minInstancesText.setText( minInstances );
- this.maxInstancesText.setText( maxInstances );
- }
- }
+ @Override
+ public void widgetDefaultSelected( SelectionEvent e ) {
+ // TODO Auto-generated method stub
+
+ }
+
+ private void copySelectedFileToCloudProject(File source, File destination){
+
+ InputStream selection = null;
+ OutputStream output = null;
+ try {
+ try {
+ selection = new FileInputStream(source);
+ } catch( FileNotFoundException e ) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ try {
+ output = new FileOutputStream(destination);
+ } catch( FileNotFoundException e ) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ byte[] buf = new byte[1024];
+ int bytesRead;
+ try {
+ while ((bytesRead = selection.read(buf)) > 0) {
+ output.write(buf, 0, bytesRead);
+ }
+ } catch( IOException e ) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } finally {
+ try {
+ selection.close();
+ output.close();
+ } catch( IOException e ) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
- // Refresh Tab
- @Override
- public void refresh() {
- PictogramElement pe = getSelectedPictogramElement();
- if( pe != null ) {
- final Object bo = Graphiti.getLinkService()
- .getBusinessObjectForLinkedPictogramElement( pe );
- if( bo == null )
- return;
- TNodeTemplate appComponent;
- if( bo instanceof TDeploymentArtifact ) {
- PictogramElement parentPE = Graphiti.getPeService()
- .getPictogramElementParent( pe );
- appComponent = ( TNodeTemplate )Graphiti.getLinkService()
- .getBusinessObjectForLinkedPictogramElement( parentPE );
- } else { // bo instanceof TNodeTemplate
- appComponent = ( TNodeTemplate )bo;
- }
- String name = appComponent.getName();
- this.nameText.setText( name == null
- ? "" : name ); //$NON-NLS-1$
-
- // set Image Artifact
- String imageName = null;
- TDeploymentArtifacts deploymentArtifacts = appComponent.getDeploymentArtifacts();
- if( deploymentArtifacts != null ) {
- for( TDeploymentArtifact artifact : deploymentArtifacts.getDeploymentArtifact() )
- {
- //if( artifact.getArtifactType().toString().equals( "VMI" ) ) { //$NON-NLS-1$
- if( artifact.getArtifactType().getLocalPart().equals( imageType ) ) { //$NON-NLS-1$
- imageName = artifact.getName();
- break;
- }
- }
- }
- this.imageText.setText( imageName == null
- ? "" : imageName ); //$NON-NLS-1$
-
- // set VM Flavor
- if ( appComponent.getProperties() != null ){
- NodePropertiesType nodeProperties = (NodePropertiesType) appComponent.getProperties().getAny().get( 0 ).getValue();
- String flavor = nodeProperties.getFlavor();
- this.cmbImageSize.setText( flavor == null
- ? "" : flavor ); //$NON-NLS-1$
- }
- else{
- this.cmbImageSize.setText( "" );
- }
-
- if( !( bo instanceof TDeploymentArtifact ) )
- refreshInstances();
- }
- }
-
- // Updates Application name or number of instances according the triggered
- // listener
- @Override
- public void modifyText( final ModifyEvent e ) {
- PictogramElement pe = getSelectedPictogramElement();
- if( pe != null ) {
- final Object bo = Graphiti.getLinkService()
- .getBusinessObjectForLinkedPictogramElement( pe );
- // the filter assured, that it is a TNodeTemplate
- if( bo == null )
- return;
- final TNodeTemplateExtension nodeTemplate;
- if( bo instanceof TDeploymentArtifact ) {
- PictogramElement parentPE = Graphiti.getPeService()
- .getPictogramElementParent( pe );
- nodeTemplate = ( TNodeTemplateExtension )Graphiti.getLinkService()
- .getBusinessObjectForLinkedPictogramElement( parentPE );
- } else { // bo instanceof TNodeTemplate
- nodeTemplate = ( TNodeTemplateExtension )bo;
- }
- // nameText Listener
- if( e.widget == this.nameText ) {
- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain( bo );
- editingDomain.getCommandStack()
- .execute( new RecordingCommand( editingDomain ) {
-
- protected void doExecute() {
- nodeTemplate.setName( ApplicationComponentNameSection.this.nameText.getText() );
- }
- } );
- }
- // minInstancesText Listener
- else if( e.widget == this.minInstancesText ) {
- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain( bo );
- editingDomain.getCommandStack()
- .execute( new RecordingCommand( editingDomain ) {
-
- protected void doExecute() {
- if( nodeTemplate != null ) {
- if( ApplicationComponentNameSection.this.minInstancesText.getText()
- .equals( "" ) ) { //$NON-NLS-1$
- // nodeTemplate.setMinInstances( -1 );
- } else
- nodeTemplate.setMinInstances( Integer.parseInt( ApplicationComponentNameSection.this.minInstancesText.getText() ) );
- }
- }
- } );
- }
- // maxInstancesText Listener
- else if( e.widget == this.maxInstancesText ) {
- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain( bo );
- editingDomain.getCommandStack()
- .execute( new RecordingCommand( editingDomain ) {
-
- protected void doExecute() {
- if( ApplicationComponentNameSection.this.maxInstancesText.getText()
- .compareTo( "" ) == 0 ) { //$NON-NLS-1$
- // nodeTemplate.setMaxInstances( ( BigInteger
- // )BigInteger.valueOf(-1) );
- } else
- nodeTemplate.setMaxInstances( ( BigInteger )BigInteger.valueOf( Integer.parseInt( ApplicationComponentNameSection.this.maxInstancesText.getText() ) ) );
- }
- } );
- }
- // initialInstancesText Listener
- else if( e.widget == this.initialInstancesText ) {
- if( ApplicationComponentNameSection.this.initialInstancesText.getText()
- .compareTo( "" ) == 0 ) { //$NON-NLS-1$
- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain( bo );
- editingDomain.getCommandStack()
- .execute( new RecordingCommand( editingDomain ) {
-
- protected void doExecute() {
- nodeTemplate.setInitInstances( 1 );
- }
- } );
- } else if( nodeTemplate.getInitInstances() != Integer.parseInt( ApplicationComponentNameSection.this.initialInstancesText.getText() ) )
- {
- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain( bo );
- editingDomain.getCommandStack()
- .execute( new RecordingCommand( editingDomain ) {
-
- protected void doExecute() {
- nodeTemplate.setInitInstances( Integer.parseInt( ApplicationComponentNameSection.this.initialInstancesText.getText() ) );
- }
- } );
- }
- }
- }
- }
-
- private void createNodeFlavorProperties( String flavor ) {
- PictogramElement pe = getSelectedPictogramElement();
- final TNodeTemplateExtension appComponent;
- Object bo = Graphiti.getLinkService()
- .getBusinessObjectForLinkedPictogramElement( pe );
- if( bo == null )
- return;
- if( bo instanceof TDeploymentArtifact ) {
- PictogramElement parentPE = Graphiti.getPeService()
- .getPictogramElementParent( pe );
- appComponent = ( TNodeTemplateExtension )Graphiti.getLinkService()
- .getBusinessObjectForLinkedPictogramElement( parentPE );
- } else { // bo instanceof TNodeTemplate
- appComponent = ( TNodeTemplateExtension )bo;
- }
- // Create Flavor Properties
- NodePropertiesType nodeProperties = Tosca_Elasticity_ExtensionsFactory.eINSTANCE.createNodePropertiesType();
- nodeProperties.setFlavor( flavor );
- // Set the Properties of the Policy Template
- final PropertiesType properties = ToscaFactory.eINSTANCE.createPropertiesType();
- // Add the SYBL Policy to the FeatureMap of the Policy's Properties element
- Entry e = FeatureMapUtil.createEntry( Tosca_Elasticity_ExtensionsPackage.eINSTANCE.getDocumentRoot_NodeProperties(),
- nodeProperties );
- properties.getAny().add( e );
- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain( appComponent );
- editingDomain.getCommandStack()
- .execute( new RecordingCommand( editingDomain ) {
-
- @Override
- protected void doExecute() {
- appComponent.setProperties( properties );
- }
- } );
- }
-
- @Override
- public void widgetSelected( SelectionEvent e ) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void widgetDefaultSelected( SelectionEvent e ) {
- // TODO Auto-generated method stub
-
- }
-
- private void copySelectedFileToCloudProject(File source, File destination){
-
- InputStream selection = null;
- OutputStream output = null;
- try {
- try {
- selection = new FileInputStream(source);
- } catch( FileNotFoundException e ) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- try {
- output = new FileOutputStream(destination);
- } catch( FileNotFoundException e ) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- byte[] buf = new byte[1024];
- int bytesRead;
- try {
- while ((bytesRead = selection.read(buf)) > 0) {
- output.write(buf, 0, bytesRead);
- }
- } catch( IOException e ) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- } finally {
- try {
- selection.close();
- output.close();
- } catch( IOException e ) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- }
+ }
}
diff --git a/plugins/org.eclipse.camf.tosca.editor/src/org/eclipse/camf/tosca/editor/property/ApplicationComponentSmartSection.java b/plugins/org.eclipse.camf.tosca.editor/src/org/eclipse/camf/tosca/editor/property/ApplicationComponentSmartSection.java
new file mode 100644
index 0000000..0be6c97
--- /dev/null
+++ b/plugins/org.eclipse.camf.tosca.editor/src/org/eclipse/camf/tosca/editor/property/ApplicationComponentSmartSection.java
@@ -0,0 +1,534 @@
+/************************************************************
+ * Copyright (C), 2013 CELAR Consortium
+ * http://www.celarcloud.eu
+ *
+ * Contributors:
+ * Stalo Sofokleous - initial API and implementation
+ ************************************************************/
+package org.eclipse.camf.tosca.editor.property;
+
+import java.math.BigInteger;
+
+import org.eclipse.camf.tosca.PoliciesType;
+import org.eclipse.camf.tosca.TDeploymentArtifact;
+import org.eclipse.camf.tosca.TPolicy;
+import org.eclipse.camf.tosca.ToscaFactory;
+import org.eclipse.camf.tosca.elasticity.TNodeTemplateExtension;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.xml.type.internal.QName;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
+import org.eclipse.graphiti.services.Graphiti;
+import org.eclipse.graphiti.ui.platform.GFPropertySection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+
+/**
+ * Application Component Properties - Smart Deployment Tab
+ */
+public class ApplicationComponentSmartSection extends GFPropertySection
+ implements ITabbedPropertyConstants, ModifyListener {
+
+ Section sectionDH;
+ Section sectionLH;
+ Text minCpuText, maxCpuText, minRamText, maxRamText, minDiskText,
+ maxDiskText;
+
+ @Override
+ public void createControls(Composite parent,
+ TabbedPropertySheetPage tabbedPropertySheetPage) {
+ super.createControls(parent, tabbedPropertySheetPage);
+ TabbedPropertySheetWidgetFactory factory = getWidgetFactory();
+ FormToolkit toolkit = new FormToolkit(parent.getDisplay());
+ // Application Component Data Hints Section
+ Section section = toolkit.createSection(parent, Section.TITLE_BAR);
+ section.setText("System-Level Requirements"); //$NON-NLS-1$
+ Composite client = toolkit.createComposite(section, SWT.WRAP);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 4;
+ layout.marginTop = 15;
+ layout.verticalSpacing = 15;
+ layout.marginWidth = 2;
+ layout.marginHeight = 2;
+ client.setLayout(layout);
+
+ GridData gd;
+ gd = new GridData();
+ CLabel valueLabel1 = factory.createCLabel(client, ""); //$NON-NLS-1$
+ CLabel valueLabel2 = factory.createCLabel(client, "Min"); //$NON-NLS-1$
+ CLabel valueLabel3 = factory.createCLabel(client, "Max"); //$NON-NLS-1$
+ CLabel valueLabel4 = factory.createCLabel(client, "Unit"); //$NON-NLS-1$
+ valueLabel1.setLayoutData(gd);
+ valueLabel2.setLayoutData(gd);
+ valueLabel3.setLayoutData(gd);
+ valueLabel4.setLayoutData(gd);
+ toolkit.adapt(valueLabel1, true, true);
+ toolkit.adapt(valueLabel2, true, true);
+ toolkit.adapt(valueLabel3, true, true);
+ toolkit.adapt(valueLabel4, true, true);
+
+ CLabel cpuLabel = factory.createCLabel(client, "CPU:"); //$NON-NLS-1$
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
+ gd.widthHint = 60;
+ cpuLabel.setLayoutData(gd);
+ // Minimun num of cpus text
+ this.minCpuText = factory.createText(client, ""); //$NON-NLS-1$
+ this.minCpuText.setEditable(true);
+ this.minCpuText.addModifyListener(this);
+ gd = new GridData();
+ gd.widthHint = 120;
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
+ this.minCpuText.setLayoutData(gd);
+
+ // Maximum num of cpus text
+ this.maxCpuText = factory.createText(client, ""); //$NON-NLS-1$
+ this.maxCpuText.setEditable(true);
+ this.maxCpuText.addModifyListener(this);
+ gd = new GridData();
+ gd.widthHint = 120;
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
+ this.maxCpuText.setLayoutData(gd);
+
+ CLabel coresLabel = factory.createCLabel(client, "vCores"); //$NON-NLS-1$
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
+ gd.widthHint = 60;
+ coresLabel.setLayoutData(gd);
+
+ // Add section components to the toolkit
+ toolkit.adapt(cpuLabel, true, true);
+ toolkit.adapt(this.minCpuText, true, true);
+ toolkit.adapt(this.maxCpuText, true, true);
+ toolkit.adapt(coresLabel, true, true);
+
+ // RAM
+ CLabel ramLabel = factory.createCLabel(client, "RAM:"); //$NON-NLS-1$
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
+ gd.widthHint = 60;
+ ramLabel.setLayoutData(gd);
+ // Minimun num of RAM text
+ this.minRamText = factory.createText(client, ""); //$NON-NLS-1$
+ this.minRamText.setEditable(true);
+ this.minRamText.addModifyListener(this);
+ gd = new GridData();
+ gd.widthHint = 120;
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
+ this.minRamText.setLayoutData(gd);
+
+ // Maximum num of RAM text
+ this.maxRamText = factory.createText(client, ""); //$NON-NLS-1$
+ this.maxRamText.setEditable(true);
+ this.maxRamText.addModifyListener(this);
+ gd = new GridData();
+ gd.widthHint = 120;
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
+ this.maxRamText.setLayoutData(gd);
+
+ CLabel mbLabel = factory.createCLabel(client, "MB"); //$NON-NLS-1$
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
+ gd.widthHint = 60;
+ mbLabel.setLayoutData(gd);
+
+ // Add section components to the toolkit
+ toolkit.adapt(ramLabel, true, true);
+ toolkit.adapt(this.minRamText, true, true);
+ toolkit.adapt(this.maxRamText, true, true);
+ toolkit.adapt(mbLabel, true, true);
+
+ // DISK
+ CLabel diskLabel = factory.createCLabel(client, "DISK:"); //$NON-NLS-1$
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
+ gd.widthHint = 60;
+ diskLabel.setLayoutData(gd);
+ // Minimun num of disk text
+ this.minDiskText = factory.createText(client, ""); //$NON-NLS-1$
+ this.minDiskText.setEditable(true);
+ this.minDiskText.addModifyListener(this);
+ gd = new GridData();
+ gd.widthHint = 120;
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
+ this.minDiskText.setLayoutData(gd);
+
+ // Maximum num of disk text
+ this.maxDiskText = factory.createText(client, ""); //$NON-NLS-1$
+ this.maxDiskText.setEditable(true);
+ this.maxDiskText.addModifyListener(this);
+ gd = new GridData();
+ gd.widthHint = 120;
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
+ this.maxDiskText.setLayoutData(gd);
+
+ CLabel gbLabel = factory.createCLabel(client, "GB"); //$NON-NLS-1$
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
+ gd.widthHint = 60;
+ gbLabel.setLayoutData(gd);
+
+ // Add section components to the toolkit
+ toolkit.adapt(diskLabel, true, true);
+ toolkit.adapt(this.minDiskText, true, true);
+ toolkit.adapt(this.maxDiskText, true, true);
+ toolkit.adapt(gbLabel, true, true);
+
+ section.setClient(client);
+
+ }
+
+ /*
+ * Refresh Tab(non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh()
+ */
+ @Override
+ public void refresh() {
+ String minCpu="", maxCpu="", minRam="", maxRam="", minDisk="", maxDisk="";
+ PictogramElement pe = getSelectedPictogramElement();
+ TNodeTemplateExtension nodeTemplate = null;
+ if (pe != null) {
+ final Object bo = Graphiti.getLinkService()
+ .getBusinessObjectForLinkedPictogramElement(pe);
+ // the filter assured, that it is a TNodeTemplate
+ if (bo == null)
+ return;
+
+ if (bo instanceof TDeploymentArtifact) {
+ PictogramElement parentPE = Graphiti.getPeService()
+ .getPictogramElementParent(pe);
+ nodeTemplate = (TNodeTemplateExtension) Graphiti
+ .getLinkService()
+ .getBusinessObjectForLinkedPictogramElement(parentPE);
+ } else { // bo instanceof TNodeTemplate
+ nodeTemplate = (TNodeTemplateExtension) bo;
+ }
+ }
+ if (nodeTemplate.getPolicies()!=null && nodeTemplate.getPolicies().getPolicy()!=null){
+
+ for (final TPolicy tempPolicy : nodeTemplate.getPolicies()
+ .getPolicy()) {
+ if (tempPolicy.getName().contains("sys:cpu")) {
+ String cpuValue = tempPolicy.getName();
+ if (cpuValue.contains("-")){
+ minCpu = cpuValue.substring(cpuValue.indexOf("[")+1, cpuValue.indexOf("-"));
+ maxCpu = cpuValue.substring(cpuValue.indexOf("-")+1, cpuValue.length()-1);
+ }
+ else{
+ minCpu=cpuValue.substring(cpuValue.indexOf("=")+1, cpuValue.length());
+ }
+
+ }
+ else if (tempPolicy.getName().contains("sys:ram")) {
+ String ramValue = tempPolicy.getName();
+ if (ramValue.contains("-")){
+ minRam = ramValue.substring(ramValue.indexOf("[")+1, ramValue.indexOf("-"));
+ maxRam = ramValue.substring(ramValue.indexOf("-")+1, ramValue.length()-1);
+ }
+ else{
+ minRam=ramValue.substring(ramValue.indexOf("=")+1, ramValue.length());;
+ }
+
+ }
+ else if (tempPolicy.getName().contains("sys:disk")) {
+ String diskValue = tempPolicy.getName();
+ if (diskValue.contains("-")){
+ minDisk = diskValue.substring(diskValue.indexOf("[")+1, diskValue.indexOf("-"));
+ maxDisk = diskValue.substring(diskValue.indexOf("-")+1, diskValue.length()-1);
+ }
+ else{
+ minDisk=diskValue.substring(diskValue.indexOf("=")+1, diskValue.length());;
+ }
+
+ }
+ }
+ }
+ this.minCpuText.setText(minCpu);
+ this.maxCpuText.setText(maxCpu);
+ this.minRamText.setText(minRam);
+ this.maxRamText.setText(maxRam);
+ this.minDiskText.setText(minDisk);
+ this.maxDiskText.setText(maxDisk);
+ }
+
+ @Override
+ public void modifyText(final ModifyEvent e) {
+ PictogramElement pe = getSelectedPictogramElement();
+ if (pe != null) {
+ final Object bo = Graphiti.getLinkService()
+ .getBusinessObjectForLinkedPictogramElement(pe);
+ // the filter assured, that it is a TNodeTemplate
+ if (bo == null)
+ return;
+ final TNodeTemplateExtension nodeTemplate;
+ if (bo instanceof TDeploymentArtifact) {
+ PictogramElement parentPE = Graphiti.getPeService()
+ .getPictogramElementParent(pe);
+ nodeTemplate = (TNodeTemplateExtension) Graphiti
+ .getLinkService()
+ .getBusinessObjectForLinkedPictogramElement(parentPE);
+ } else { // bo instanceof TNodeTemplate
+ nodeTemplate = (TNodeTemplateExtension) bo;
+ }
+ // minCpuText/maxCpuText Listener
+ if (e.widget == this.minCpuText || e.widget == this.maxCpuText) {
+ if (this.minCpuText.getText()!=""){
+ String policyValue = "sys:cpu=";
+ if (this.maxCpuText.getText() != "") {
+ policyValue += "[" + this.minCpuText.getText() + "-"
+ + this.maxCpuText.getText() + "]";
+ } else {
+ policyValue += this.minCpuText.getText();
+ }
+ boolean policyExists = false;
+ if (nodeTemplate.getPolicies() == null) {
+ final PoliciesType nodePolicyList = ToscaFactory.eINSTANCE
+ .createPoliciesType();
+ TransactionalEditingDomain editingDomain = TransactionUtil
+ .getEditingDomain(bo);
+ editingDomain.getCommandStack().execute(
+ new RecordingCommand(editingDomain) {
+
+ @Override
+ protected void doExecute() {
+ nodeTemplate.setPolicies(nodePolicyList);
+ }
+ });
+ } else {
+ for (final TPolicy tempPolicy : nodeTemplate.getPolicies()
+ .getPolicy()) {
+ if (tempPolicy.getName().contains("sys:cpu")) {
+ final String newPolicyValue = policyValue;
+ TransactionalEditingDomain editingDomain = TransactionUtil
+ .getEditingDomain(bo);
+ editingDomain.getCommandStack().execute(
+ new RecordingCommand(editingDomain) {
+
+ @Override
+ protected void doExecute() {
+ tempPolicy.setName(newPolicyValue);
+ }
+ });
+
+ policyExists = true;
+ }
+ }
+ }
+ if (!policyExists) {
+ PoliciesType nodePolicyList = nodeTemplate.getPolicies();
+ final EList<TPolicy> policy = nodePolicyList.getPolicy();
+ final TPolicy newPolicy = ToscaFactory.eINSTANCE
+ .createTPolicy();
+ String type = "Requirement";
+ QName policyTypeName = new QName(
+ "http://www.example.org/SmartDeployment", type,
+ null);
+
+ newPolicy.setPolicyType(policyTypeName);
+ newPolicy.setName(type.toUpperCase() + " " + policyValue);
+
+ String id = "R"
+ + ((Integer) nodeTemplate.hashCode()).toString()
+ + nodePolicyList.getPolicy().size();
+ QName qnamePolicyTemplate = new QName(id);
+ newPolicy.setPolicyRef(qnamePolicyTemplate);
+
+ TransactionalEditingDomain editingDomain = TransactionUtil
+ .getEditingDomain(bo);
+ editingDomain.getCommandStack().execute(
+ new RecordingCommand(editingDomain) {
+
+ @Override
+ protected void doExecute() {
+ policy.add(newPolicy);
+ }
+ });
+ }
+ }
+ }
+ // minDiskText/maxDiskText Listener
+ else if (e.widget == this.minDiskText
+ || e.widget == this.maxDiskText) {
+ if (this.minDiskText.getText()!=""){
+ String policyValue = "sys:disk=";
+ if (this.maxDiskText.getText() != "") {
+ policyValue += "[" + this.minDiskText.getText() + "-"
+ + this.maxDiskText.getText() + "]";
+ } else {
+ policyValue += this.minDiskText.getText();
+ }
+ boolean policyExists = false;
+ if (nodeTemplate.getPolicies() == null) {
+ final PoliciesType nodePolicyList = ToscaFactory.eINSTANCE
+ .createPoliciesType();
+ TransactionalEditingDomain editingDomain = TransactionUtil
+ .getEditingDomain(bo);
+ editingDomain.getCommandStack().execute(
+ new RecordingCommand(editingDomain) {
+
+ @Override
+ protected void doExecute() {
+ nodeTemplate.setPolicies(nodePolicyList);
+ }
+ });
+ } else {
+ for (final TPolicy tempPolicy : nodeTemplate.getPolicies()
+ .getPolicy()) {
+ if (tempPolicy.getName().contains("sys:disk")) {
+ final String newPolicyValue = policyValue;
+ TransactionalEditingDomain editingDomain = TransactionUtil
+ .getEditingDomain(bo);
+ editingDomain.getCommandStack().execute(
+ new RecordingCommand(editingDomain) {
+
+ @Override
+ protected void doExecute() {
+ tempPolicy.setName(newPolicyValue);
+ }
+ });
+
+ policyExists = true;
+ }
+ }
+ }
+ if (!policyExists) {
+ PoliciesType nodePolicyList = nodeTemplate.getPolicies();
+ final EList<TPolicy> policy = nodePolicyList.getPolicy();
+ final TPolicy newPolicy = ToscaFactory.eINSTANCE
+ .createTPolicy();
+ String type = "Requirement";
+ QName policyTypeName = new QName(
+ "http://www.example.org/SmartDeployment", type,
+ null);
+
+ newPolicy.setPolicyType(policyTypeName);
+ newPolicy.setName(type.toUpperCase() + " " + policyValue);
+
+ String id = "R"
+ + ((Integer) nodeTemplate.hashCode()).toString()
+ + nodePolicyList.getPolicy().size();
+ QName qnamePolicyTemplate = new QName(id);
+ newPolicy.setPolicyRef(qnamePolicyTemplate);
+
+ TransactionalEditingDomain editingDomain = TransactionUtil
+ .getEditingDomain(bo);
+ editingDomain.getCommandStack().execute(
+ new RecordingCommand(editingDomain) {
+
+ @Override
+ protected void doExecute() {
+ policy.add(newPolicy);
+ }
+ });
+ }
+ }
+
+ }
+ // minRamText/maxRamText Listener
+ else if (e.widget == this.minRamText || e.widget == this.maxRamText) {
+ if (this.minRamText.getText()!=""){
+ String policyValue = "sys:ram=";
+ if (this.maxRamText.getText() != "") {
+ policyValue += "[" + this.minRamText.getText() + "-"
+ + this.maxRamText.getText() + "]";
+ } else {
+ policyValue += this.minRamText.getText();
+ }
+ boolean policyExists = false;
+ if (nodeTemplate.getPolicies() == null) {
+ final PoliciesType nodePolicyList = ToscaFactory.eINSTANCE
+ .createPoliciesType();
+ TransactionalEditingDomain editingDomain = TransactionUtil
+ .getEditingDomain(bo);
+ editingDomain.getCommandStack().execute(
+ new RecordingCommand(editingDomain) {
+
+ @Override
+ protected void doExecute() {
+ nodeTemplate.setPolicies(nodePolicyList);
+ }
+ });
+ } else {
+ for (final TPolicy tempPolicy : nodeTemplate.getPolicies()
+ .getPolicy()) {
+ if (tempPolicy.getName().contains("sys:ram")) {
+ final String newPolicyValue = policyValue;
+ TransactionalEditingDomain editingDomain = TransactionUtil
+ .getEditingDomain(bo);
+ editingDomain.getCommandStack().execute(
+ new RecordingCommand(editingDomain) {
+
+ @Override
+ protected void doExecute() {
+ tempPolicy.setName(newPolicyValue);
+ }
+ });
+
+ policyExists = true;
+ }
+ }
+ }
+ if (!policyExists) {
+ PoliciesType nodePolicyList = nodeTemplate.getPolicies();
+ final EList<TPolicy> policy = nodePolicyList.getPolicy();
+ final TPolicy newPolicy = ToscaFactory.eINSTANCE
+ .createTPolicy();
+ String type = "Requirement";
+ QName policyTypeName = new QName(
+ "http://www.example.org/SmartDeployment", type,
+ null);
+
+ newPolicy.setPolicyType(policyTypeName);
+ newPolicy.setName(type.toUpperCase() + " " + policyValue);
+
+ String id = "R"
+ + ((Integer) nodeTemplate.hashCode()).toString()
+ + nodePolicyList.getPolicy().size();
+ QName qnamePolicyTemplate = new QName(id);
+ newPolicy.setPolicyRef(qnamePolicyTemplate);
+
+ TransactionalEditingDomain editingDomain = TransactionUtil
+ .getEditingDomain(bo);
+ editingDomain.getCommandStack().execute(
+ new RecordingCommand(editingDomain) {
+
+ @Override
+ protected void doExecute() {
+ policy.add(newPolicy);
+ }
+ });
+ }
+ }
+
+ }
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.camf.tosca/META-INF/MANIFEST.MF b/plugins/org.eclipse.camf.tosca/META-INF/MANIFEST.MF
index 139f92a..dd57923 100644
--- a/plugins/org.eclipse.camf.tosca/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.camf.tosca/META-INF/MANIFEST.MF
@@ -12,6 +12,9 @@
org.eclipse.camf.tosca.elasticity,
org.eclipse.camf.tosca.elasticity.impl,
org.eclipse.camf.tosca.elasticity.util,
+ org.example.smart.deployment,
+ org.example.smart.deployment.impl,
+ org.example.smart.deployment.util,
org.eclipse.camf.tosca.impl,
org.eclipse.camf.tosca.util,
org.example.sybl,
diff --git a/plugins/org.eclipse.camf.tosca/model/NewXMLSchema.xsd b/plugins/org.eclipse.camf.tosca/model/NewXMLSchema.xsd
index 8890fff..62befda 100644
--- a/plugins/org.eclipse.camf.tosca/model/NewXMLSchema.xsd
+++ b/plugins/org.eclipse.camf.tosca/model/NewXMLSchema.xsd
@@ -1,135 +1,148 @@
<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://www.example.org/NewXMLSchema"
- elementFormDefault="qualified"
- xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:tosca="http://docs.oasis-open.org/tosca/ns/2011/12"
+ elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:tosca="http://docs.oasis-open.org/tosca/ns/2011/12"
xmlns:elasticity="http://www.example.org/NewXMLSchema"
- xmlns:sybl="http://www.example.org/SYBL">
- <!-- xmlns:hrequirement="http://www.example.org/EnvironmentRequirementProperties" -->
-
- <import schemaLocation="SYBL.xsd" namespace="http://www.example.org/SYBL"></import>
- <import schemaLocation="TOSCA-v1.0.xsd" namespace="http://docs.oasis-open.org/tosca/ns/2011/12"></import>
-
-
+ xmlns:sybl="http://www.example.org/SYBL"
+ xmlns:tns="http://www.example.org/SmartDeployment" xmlns:pref="http://www.example.org/Smart">
+ <!-- xmlns:hrequirement="http://www.example.org/EnvironmentRequirementProperties" -->
+
+ <import schemaLocation="SYBL.xsd"
+ namespace="http://www.example.org/SYBL">
+ </import>
+ <import schemaLocation="TOSCA-v1.0.xsd"
+ namespace="http://docs.oasis-open.org/tosca/ns/2011/12">
+ </import>
+
+
<!-- <import schemaLocation="EnvironmentRequirementProperties.xsd" namespace="http://www.example.org/EnvironmentRequirementProperties"></import>
-->
-
-
-
- <complexType name="TBoundaryDefinitionsExtension">
- <complexContent>
- <extension base="tosca:tBoundaryDefinitions">
- <sequence>
- <element name="monitoringProbes" type="elasticity:MonitoringProbesType1" maxOccurs="1" minOccurs="0"></element>
- </sequence>
- </extension>
- </complexContent>
- </complexType>
-
-
-
-
-
-
- <complexType name="TNodeTemplateExtension">
- <complexContent>
- <extension base="tosca:tNodeTemplate">
- <sequence></sequence>
- <attribute name="initInstances" type="int"></attribute>
- <attribute name="x" type="int"></attribute>
- <attribute name="y" type="int"></attribute>
- <attribute name="width" type="int"></attribute>
- <attribute name="height" type="int"></attribute>
- </extension>
- </complexContent>
- </complexType>
- <attributeGroup name="NewAttributeGroup"></attributeGroup>
+ <import schemaLocation="Smart.xsd" namespace="http://www.example.org/Smart"></import>
+ <complexType name="TBoundaryDefinitionsExtension">
+ <complexContent>
+ <extension base="tosca:tBoundaryDefinitions">
+ <sequence>
+ <element name="monitoringProbes"
+ type="elasticity:MonitoringProbesType1" maxOccurs="1"
+ minOccurs="0">
+ </element>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
- <complexType name="MonitoringProbesType1">
- <sequence>
- <element name="monitoringProbes" type="elasticity:TMonitoringProbe" maxOccurs="unbounded" minOccurs="1"></element>
- </sequence>
- </complexType>
-
- <complexType name="TMonitoringProbe">
- <complexContent>
- <extension base="tosca:tExtensibleElements">
- <attribute name="Name" type="string"></attribute>
- </extension>
- </complexContent>
- </complexType>
-
-
- <complexType name="TServiceTemplateExtension">
- <complexContent>
- <extension base="tosca:tServiceTemplate">
- <attribute name="x" type="int"></attribute>
- <attribute name="y" type="int"></attribute>
- <attribute name="width" type="int"></attribute>
- <attribute name="height" type="int"></attribute>
- </extension>
- </complexContent>
- </complexType>
- <complexType name="ImageArtifactPropertiesType">
- <sequence>
- <element name="Description" type="string"></element>
- <element name="Id" type="string"></element>
- </sequence>
- </complexType>
-
- <element name="ImageArtifactProperties"
- type="elasticity:ImageArtifactPropertiesType">
- </element>
+ <complexType name="TNodeTemplateExtension">
+ <complexContent>
+ <extension base="tosca:tNodeTemplate">
+ <sequence></sequence>
+ <attribute name="initInstances" type="int"></attribute>
+ <attribute name="x" type="int"></attribute>
+ <attribute name="y" type="int"></attribute>
+ <attribute name="width" type="int"></attribute>
+ <attribute name="height" type="int"></attribute>
+ </extension>
+ </complexContent>
+ </complexType>
- <complexType name="NodePropertiesType">
- <sequence>
- <element name="Flavor" type="string"></element>
- </sequence>
- </complexType>
- <element name="NodeProperties"
- type="elasticity:NodePropertiesType">
- </element>
-
- <complexType name="ScriptArtifactPropertiesType">
- <sequence>
- <element name="Language" type="string"></element>
- </sequence>
- </complexType>
-
- <element name="ScriptArtifactProperties"
- type="elasticity:ScriptArtifactPropertiesType">
- </element>
+ <attributeGroup name="NewAttributeGroup"></attributeGroup>
- <complexType name="ServicePropertiesType">
- <sequence>
- <element name="Version" type="string"></element>
- <element name="HostingEnvironment" type="string" maxOccurs="unbounded" minOccurs="1"></element>
- </sequence>
- </complexType>
- <element name="ServiceProperties"
- type="elasticity:ServicePropertiesType">
- </element>
+ <complexType name="MonitoringProbesType1">
+ <sequence>
+ <element name="monitoringProbes"
+ type="elasticity:TMonitoringProbe" maxOccurs="unbounded"
+ minOccurs="1">
+ </element>
+ </sequence>
+ </complexType>
- <complexType name="NetworkArtifactPropertiesType">
- <sequence>
- <element name="Description" type="string"></element>
- <element name="Id" type="string"></element>
- </sequence>
- </complexType>
+ <complexType name="TMonitoringProbe">
+ <complexContent>
+ <extension base="tosca:tExtensibleElements">
+ <attribute name="Name" type="string"></attribute>
+ </extension>
+ </complexContent>
+ </complexType>
- <element name="NetworkArtifactProperties"
- type="elasticity:NetworkArtifactPropertiesType">
- </element>
+
+ <complexType name="TServiceTemplateExtension">
+ <complexContent>
+ <extension base="tosca:tServiceTemplate">
+ <attribute name="x" type="int"></attribute>
+ <attribute name="y" type="int"></attribute>
+ <attribute name="width" type="int"></attribute>
+ <attribute name="height" type="int"></attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+
+
+
+ <complexType name="ImageArtifactPropertiesType">
+ <sequence>
+ <element name="Description" type="string"></element>
+ <element name="Id" type="string"></element>
+ </sequence>
+ </complexType>
+
+ <element name="ImageArtifactProperties"
+ type="elasticity:ImageArtifactPropertiesType">
+ </element>
+
+
+ <complexType name="NodePropertiesType">
+ <sequence>
+ <element name="Flavor" type="string"></element>
+ </sequence>
+ </complexType>
+
+ <element name="NodeProperties"
+ type="elasticity:NodePropertiesType">
+ </element>
+
+ <complexType name="ScriptArtifactPropertiesType">
+ <sequence>
+ <element name="Language" type="string"></element>
+ </sequence>
+ </complexType>
+
+ <element name="ScriptArtifactProperties"
+ type="elasticity:ScriptArtifactPropertiesType">
+ </element>
+
+
+ <complexType name="ServicePropertiesType">
+ <sequence>
+ <element name="Version" type="string"></element>
+ <element name="HostingEnvironment" type="string"
+ maxOccurs="unbounded" minOccurs="1">
+ </element>
+ </sequence>
+ </complexType>
+
+ <element name="ServiceProperties"
+ type="elasticity:ServicePropertiesType">
+ </element>
+
+ <complexType name="NetworkArtifactPropertiesType">
+ <sequence>
+ <element name="Description" type="string"></element>
+ <element name="Id" type="string"></element>
+ </sequence>
+ </complexType>
+
+ <element name="NetworkArtifactProperties"
+ type="elasticity:NetworkArtifactPropertiesType">
+ </element>
</schema>
\ No newline at end of file
diff --git a/plugins/org.eclipse.camf.tosca/model/Smart.xsd b/plugins/org.eclipse.camf.tosca/model/Smart.xsd
new file mode 100644
index 0000000..0aad2b8
--- /dev/null
+++ b/plugins/org.eclipse.camf.tosca/model/Smart.xsd
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema targetNamespace="http://www.example.org/Smart" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.example.org/Smart">
+
+
+
+ <simpleType name="Requirement">
+ <restriction base="string"></restriction>
+ </simpleType>
+</schema>
\ No newline at end of file
diff --git a/plugins/org.eclipse.camf.tosca/model/deployment.ecore b/plugins/org.eclipse.camf.tosca/model/deployment.ecore
new file mode 100644
index 0000000..ec706a9
--- /dev/null
+++ b/plugins/org.eclipse.camf.tosca/model/deployment.ecore
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="smart" nsURI="http://www.example.org/SmartDeployment" nsPrefix="smart">
+ <eClassifiers xsi:type="ecore:EDataType" name="Requirement" instanceClassName="java.lang.String">
+ <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
+ <details key="name" value="Requirement"/>
+ <details key="baseType" value="http://www.eclipse.org/emf/2003/XMLType#string"/>
+ </eAnnotations>
+ </eClassifiers>
+</ecore:EPackage>
diff --git a/plugins/org.eclipse.camf.tosca/plugin.xml b/plugins/org.eclipse.camf.tosca/plugin.xml
index 8c6a31b..da418c7 100644
--- a/plugins/org.eclipse.camf.tosca/plugin.xml
+++ b/plugins/org.eclipse.camf.tosca/plugin.xml
@@ -69,4 +69,5 @@
type="tosca_elasticity_extensions"
class="org.eclipse.camf.tosca.elasticity.util.Tosca_Elasticity_ExtensionsResourceFactoryImpl"/>
</extension>
+
null</plugin>
diff --git a/plugins/org.eclipse.camf.tosca/src/org/eclipse/camf/tosca/elasticity/impl/Tosca_Elasticity_ExtensionsPackageImpl.java b/plugins/org.eclipse.camf.tosca/src/org/eclipse/camf/tosca/elasticity/impl/Tosca_Elasticity_ExtensionsPackageImpl.java
index c617e5e..b075732 100644
--- a/plugins/org.eclipse.camf.tosca/src/org/eclipse/camf/tosca/elasticity/impl/Tosca_Elasticity_ExtensionsPackageImpl.java
+++ b/plugins/org.eclipse.camf.tosca/src/org/eclipse/camf/tosca/elasticity/impl/Tosca_Elasticity_ExtensionsPackageImpl.java
@@ -37,6 +37,8 @@
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.impl.EPackageImpl;
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
+import org.example.smart.deployment.DeploymentPackage;
+import org.example.smart.deployment.impl.DeploymentPackageImpl;
import org.example.sybl.SyblPackage;
import org.example.sybl.impl.SyblPackageImpl;
diff --git a/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/DeploymentFactory.java b/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/DeploymentFactory.java
new file mode 100644
index 0000000..49e186f
--- /dev/null
+++ b/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/DeploymentFactory.java
@@ -0,0 +1,33 @@
+/**
+ */
+package org.example.smart.deployment;
+
+import org.eclipse.emf.ecore.EFactory;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Factory</b> for the model.
+ * It provides a create method for each non-abstract class of the model.
+ * <!-- end-user-doc -->
+ * @see org.example.smart.deployment.DeploymentPackage
+ * @generated
+ */
+public interface DeploymentFactory extends EFactory {
+ /**
+ * The singleton instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ DeploymentFactory eINSTANCE = org.example.smart.deployment.impl.DeploymentFactoryImpl.init();
+
+ /**
+ * Returns the package supported by this factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the package supported by this factory.
+ * @generated
+ */
+ DeploymentPackage getDeploymentPackage();
+
+} //DeploymentFactory
diff --git a/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/DeploymentPackage.java b/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/DeploymentPackage.java
new file mode 100644
index 0000000..7ec15e8
--- /dev/null
+++ b/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/DeploymentPackage.java
@@ -0,0 +1,113 @@
+/**
+ */
+package org.example.smart.deployment;
+
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EPackage;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Package</b> for the model.
+ * It contains accessors for the meta objects to represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ * @see org.example.smart.deployment.DeploymentFactory
+ * @model kind="package"
+ * @generated
+ */
+public interface DeploymentPackage extends EPackage {
+ /**
+ * The package name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNAME = "deployment";
+
+ /**
+ * The package namespace URI.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNS_URI = "http://www.example.org/SmartDeployment";
+
+ /**
+ * The package namespace name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNS_PREFIX = "deployment";
+
+ /**
+ * The singleton instance of the package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ DeploymentPackage eINSTANCE = org.example.smart.deployment.impl.DeploymentPackageImpl.init();
+
+ /**
+ * The meta object id for the '<em>Requirement</em>' data type.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see java.lang.String
+ * @see org.example.smart.deployment.impl.DeploymentPackageImpl#getRequirement()
+ * @generated
+ */
+ int REQUIREMENT = 0;
+
+
+ /**
+ * Returns the meta object for data type '{@link java.lang.String <em>Requirement</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for data type '<em>Requirement</em>'.
+ * @see java.lang.String
+ * @model instanceClass="java.lang.String"
+ * extendedMetaData="name='Requirement' baseType='http://www.eclipse.org/emf/2003/XMLType#string'"
+ * @generated
+ */
+ EDataType getRequirement();
+
+ /**
+ * Returns the factory that creates the instances of the model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the factory that creates the instances of the model.
+ * @generated
+ */
+ DeploymentFactory getDeploymentFactory();
+
+ /**
+ * <!-- begin-user-doc -->
+ * Defines literals for the meta objects that represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ interface Literals {
+ /**
+ * The meta object literal for the '<em>Requirement</em>' data type.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see java.lang.String
+ * @see org.example.smart.deployment.impl.DeploymentPackageImpl#getRequirement()
+ * @generated
+ */
+ EDataType REQUIREMENT = eINSTANCE.getRequirement();
+
+ }
+
+} //DeploymentPackage
diff --git a/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/impl/DeploymentFactoryImpl.java b/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/impl/DeploymentFactoryImpl.java
new file mode 100644
index 0000000..0b137f5
--- /dev/null
+++ b/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/impl/DeploymentFactoryImpl.java
@@ -0,0 +1,136 @@
+/**
+ */
+package org.example.smart.deployment.impl;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.emf.ecore.impl.EFactoryImpl;
+
+import org.eclipse.emf.ecore.plugin.EcorePlugin;
+
+import org.eclipse.emf.ecore.xml.type.XMLTypeFactory;
+import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
+
+import org.example.smart.deployment.*;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Factory</b>.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class DeploymentFactoryImpl extends EFactoryImpl implements DeploymentFactory {
+ /**
+ * Creates the default factory implementation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static DeploymentFactory init() {
+ try {
+ DeploymentFactory theDeploymentFactory = (DeploymentFactory)EPackage.Registry.INSTANCE.getEFactory(DeploymentPackage.eNS_URI);
+ if (theDeploymentFactory != null) {
+ return theDeploymentFactory;
+ }
+ }
+ catch (Exception exception) {
+ EcorePlugin.INSTANCE.log(exception);
+ }
+ return new DeploymentFactoryImpl();
+ }
+
+ /**
+ * Creates an instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public DeploymentFactoryImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public EObject create(EClass eClass) {
+ switch (eClass.getClassifierID()) {
+ default:
+ throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object createFromString(EDataType eDataType, String initialValue) {
+ switch (eDataType.getClassifierID()) {
+ case DeploymentPackage.REQUIREMENT:
+ return createRequirementFromString(eDataType, initialValue);
+ default:
+ throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String convertToString(EDataType eDataType, Object instanceValue) {
+ switch (eDataType.getClassifierID()) {
+ case DeploymentPackage.REQUIREMENT:
+ return convertRequirementToString(eDataType, instanceValue);
+ default:
+ throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String createRequirementFromString(EDataType eDataType, String initialValue) {
+ return (String)XMLTypeFactory.eINSTANCE.createFromString(XMLTypePackage.Literals.STRING, initialValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String convertRequirementToString(EDataType eDataType, Object instanceValue) {
+ return XMLTypeFactory.eINSTANCE.convertToString(XMLTypePackage.Literals.STRING, instanceValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public DeploymentPackage getDeploymentPackage() {
+ return (DeploymentPackage)getEPackage();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @deprecated
+ * @generated
+ */
+ @Deprecated
+ public static DeploymentPackage getPackage() {
+ return DeploymentPackage.eINSTANCE;
+ }
+
+} //DeploymentFactoryImpl
diff --git a/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/impl/DeploymentPackageImpl.java b/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/impl/DeploymentPackageImpl.java
new file mode 100644
index 0000000..a723325
--- /dev/null
+++ b/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/impl/DeploymentPackageImpl.java
@@ -0,0 +1,200 @@
+/**
+ */
+package org.example.smart.deployment.impl;
+
+import org.eclipse.camf.tosca.ToscaPackage;
+
+import org.eclipse.camf.tosca.elasticity.Tosca_Elasticity_ExtensionsPackage;
+
+import org.eclipse.camf.tosca.elasticity.impl.Tosca_Elasticity_ExtensionsPackageImpl;
+
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.emf.ecore.impl.EPackageImpl;
+
+import org.example.smart.deployment.DeploymentFactory;
+import org.example.smart.deployment.DeploymentPackage;
+
+import org.example.sybl.SyblPackage;
+
+import org.example.sybl.impl.SyblPackageImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Package</b>.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class DeploymentPackageImpl extends EPackageImpl implements DeploymentPackage {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EDataType requirementEDataType = null;
+
+ /**
+ * Creates an instance of the model <b>Package</b>, registered with
+ * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
+ * package URI value.
+ * <p>Note: the correct way to create the package is via the static
+ * factory method {@link #init init()}, which also performs
+ * initialization of the package, or returns the registered package,
+ * if one already exists.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.ecore.EPackage.Registry
+ * @see org.example.smart.deployment.DeploymentPackage#eNS_URI
+ * @see #init()
+ * @generated
+ */
+ private DeploymentPackageImpl() {
+ super(eNS_URI, DeploymentFactory.eINSTANCE);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static boolean isInited = false;
+
+ /**
+ * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
+ *
+ * <p>This method is used to initialize {@link DeploymentPackage#eINSTANCE} when that field is accessed.
+ * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #eNS_URI
+ * @see #createPackageContents()
+ * @see #initializePackageContents()
+ * @generated
+ */
+ public static DeploymentPackage init() {
+ if (isInited) return (DeploymentPackage)EPackage.Registry.INSTANCE.getEPackage(DeploymentPackage.eNS_URI);
+
+ // Obtain or create and register package
+ DeploymentPackageImpl theDeploymentPackage = (DeploymentPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof DeploymentPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new DeploymentPackageImpl());
+
+ isInited = true;
+
+ // Initialize simple dependencies
+ ToscaPackage.eINSTANCE.eClass();
+
+ // Obtain or create and register interdependencies
+ SyblPackageImpl theSyblPackage = (SyblPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(SyblPackage.eNS_URI) instanceof SyblPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(SyblPackage.eNS_URI) : SyblPackage.eINSTANCE);
+ Tosca_Elasticity_ExtensionsPackageImpl theTosca_Elasticity_ExtensionsPackage = (Tosca_Elasticity_ExtensionsPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(Tosca_Elasticity_ExtensionsPackage.eNS_URI) instanceof Tosca_Elasticity_ExtensionsPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(Tosca_Elasticity_ExtensionsPackage.eNS_URI) : Tosca_Elasticity_ExtensionsPackage.eINSTANCE);
+
+ // Create package meta-data objects
+ theDeploymentPackage.createPackageContents();
+ theSyblPackage.createPackageContents();
+ theTosca_Elasticity_ExtensionsPackage.createPackageContents();
+
+ // Initialize created meta-data
+ theDeploymentPackage.initializePackageContents();
+ theSyblPackage.initializePackageContents();
+ theTosca_Elasticity_ExtensionsPackage.initializePackageContents();
+
+ // Mark meta-data to indicate it can't be changed
+ theDeploymentPackage.freeze();
+
+
+ // Update the registry and return the package
+ EPackage.Registry.INSTANCE.put(DeploymentPackage.eNS_URI, theDeploymentPackage);
+ return theDeploymentPackage;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EDataType getRequirement() {
+ return requirementEDataType;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public DeploymentFactory getDeploymentFactory() {
+ return (DeploymentFactory)getEFactoryInstance();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private boolean isCreated = false;
+
+ /**
+ * Creates the meta-model objects for the package. This method is
+ * guarded to have no affect on any invocation but its first.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void createPackageContents() {
+ if (isCreated) return;
+ isCreated = true;
+
+ // Create data types
+ requirementEDataType = createEDataType(REQUIREMENT);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private boolean isInitialized = false;
+
+ /**
+ * Complete the initialization of the package and its meta-model. This
+ * method is guarded to have no affect on any invocation but its first.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void initializePackageContents() {
+ if (isInitialized) return;
+ isInitialized = true;
+
+ // Initialize package
+ setName(eNAME);
+ setNsPrefix(eNS_PREFIX);
+ setNsURI(eNS_URI);
+
+ // Initialize data types
+ initEDataType(requirementEDataType, String.class, "Requirement", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
+
+ // Create resource
+ createResource(eNS_URI);
+
+ // Create annotations
+ // http:///org/eclipse/emf/ecore/util/ExtendedMetaData
+ createExtendedMetaDataAnnotations();
+ }
+
+ /**
+ * Initializes the annotations for <b>http:///org/eclipse/emf/ecore/util/ExtendedMetaData</b>.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void createExtendedMetaDataAnnotations() {
+ String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData";
+ addAnnotation
+ (requirementEDataType,
+ source,
+ new String[] {
+ "name", "Requirement",
+ "baseType", "http://www.eclipse.org/emf/2003/XMLType#string"
+ });
+ }
+
+} //DeploymentPackageImpl
diff --git a/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/util/DeploymentResourceFactoryImpl.java b/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/util/DeploymentResourceFactoryImpl.java
new file mode 100644
index 0000000..8bc7375
--- /dev/null
+++ b/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/util/DeploymentResourceFactoryImpl.java
@@ -0,0 +1,41 @@
+/**
+ */
+package org.example.smart.deployment.util;
+
+import org.eclipse.emf.common.util.URI;
+
+import org.eclipse.emf.ecore.resource.Resource;
+
+import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Resource Factory</b> associated with the package.
+ * <!-- end-user-doc -->
+ * @see org.example.smart.deployment.util.DeploymentResourceImpl
+ * @generated
+ */
+public class DeploymentResourceFactoryImpl extends ResourceFactoryImpl {
+ /**
+ * Creates an instance of the resource factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public DeploymentResourceFactoryImpl() {
+ super();
+ }
+
+ /**
+ * Creates an instance of the resource.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Resource createResource(URI uri) {
+ Resource result = new DeploymentResourceImpl(uri);
+ return result;
+ }
+
+} //DeploymentResourceFactoryImpl
diff --git a/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/util/DeploymentResourceImpl.java b/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/util/DeploymentResourceImpl.java
new file mode 100644
index 0000000..70661f0
--- /dev/null
+++ b/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/util/DeploymentResourceImpl.java
@@ -0,0 +1,28 @@
+/**
+ */
+package org.example.smart.deployment.util;
+
+import org.eclipse.emf.common.util.URI;
+
+import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Resource </b> associated with the package.
+ * <!-- end-user-doc -->
+ * @see org.example.smart.deployment.util.DeploymentResourceFactoryImpl
+ * @generated
+ */
+public class DeploymentResourceImpl extends XMLResourceImpl {
+ /**
+ * Creates an instance of the resource.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param uri the URI of the new resource.
+ * @generated
+ */
+ public DeploymentResourceImpl(URI uri) {
+ super(uri);
+ }
+
+} //DeploymentResourceImpl
diff --git a/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/util/DeploymentXMLProcessor.java b/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/util/DeploymentXMLProcessor.java
new file mode 100644
index 0000000..2d3c5a1
--- /dev/null
+++ b/plugins/org.eclipse.camf.tosca/src/org/example/smart/deployment/util/DeploymentXMLProcessor.java
@@ -0,0 +1,50 @@
+/**
+ */
+package org.example.smart.deployment.util;
+
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.emf.ecore.resource.Resource;
+
+import org.eclipse.emf.ecore.xmi.util.XMLProcessor;
+
+import org.example.smart.deployment.DeploymentPackage;
+
+/**
+ * This class contains helper methods to serialize and deserialize XML documents
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class DeploymentXMLProcessor extends XMLProcessor {
+
+ /**
+ * Public constructor to instantiate the helper.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public DeploymentXMLProcessor() {
+ super((EPackage.Registry.INSTANCE));
+ DeploymentPackage.eINSTANCE.eClass();
+ }
+
+ /**
+ * Register for "*" and "xml" file extensions the DeploymentResourceFactoryImpl factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected Map<String, Resource.Factory> getRegistrations() {
+ if (registrations == null) {
+ super.getRegistrations();
+ registrations.put(XML_EXTENSION, new DeploymentResourceFactoryImpl());
+ registrations.put(STAR_EXTENSION, new DeploymentResourceFactoryImpl());
+ }
+ return registrations;
+ }
+
+} //DeploymentXMLProcessor
diff --git a/plugins/org.eclipse.camf.tosca/src/org/example/sybl/impl/SyblPackageImpl.java b/plugins/org.eclipse.camf.tosca/src/org/example/sybl/impl/SyblPackageImpl.java
index a03015b..dd40c18 100644
--- a/plugins/org.eclipse.camf.tosca/src/org/example/sybl/impl/SyblPackageImpl.java
+++ b/plugins/org.eclipse.camf.tosca/src/org/example/sybl/impl/SyblPackageImpl.java
@@ -26,6 +26,8 @@
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.impl.EPackageImpl;
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
+import org.example.smart.deployment.DeploymentPackage;
+import org.example.smart.deployment.impl.DeploymentPackageImpl;
import org.example.sybl.BinaryRestriction;
import org.example.sybl.ConditionType;
import org.example.sybl.ConditionType1;
diff --git a/plugins/org.eclipse.camf.tycho.target/target-definition.target b/plugins/org.eclipse.camf.tycho.target/target-definition.target
index fab61ce..271880d 100644
--- a/plugins/org.eclipse.camf.tycho.target/target-definition.target
+++ b/plugins/org.eclipse.camf.tycho.target/target-definition.target
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?pde version="3.8"?><target name="target-definition" sequenceNumber="42">
+<?pde version="3.8"?><target name="target-definition" sequenceNumber="43">
<locations>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.graphiti.sdk.feature.feature.group" version="0.11.2.v20150204-0954"/>
<repository location="http://download.eclipse.org/releases/luna"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
-<unit id="org.eclipse.platform.sdk" version="4.4.1.M20140925-0400"/>
+<unit id="org.eclipse.platform.sdk" version="4.4.2.M20150204-1700"/>
<repository location="http://download.eclipse.org/eclipse/updates/4.4"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
diff --git a/plugins/org.eclipse.camf.ui/src/org/eclipse/camf/ui/wizards/NewDeploymentWizard.java b/plugins/org.eclipse.camf.ui/src/org/eclipse/camf/ui/wizards/NewDeploymentWizard.java
index 7b560a2..cdfe68b 100644
--- a/plugins/org.eclipse.camf.ui/src/org/eclipse/camf/ui/wizards/NewDeploymentWizard.java
+++ b/plugins/org.eclipse.camf.ui/src/org/eclipse/camf/ui/wizards/NewDeploymentWizard.java
@@ -113,20 +113,20 @@
new OperationExecuter().execOp(deployOperation);
- if (deployOperation.getActiontoDo().equals(
- ActionToDo.TERMINATE_AND_REVERT_ON_ERROR)
- && !deployOperation.failed_to_deploy.isEmpty()) {
- OpenStackOpTerminateApplication terminateOperation = new OpenStackOpTerminateApplication(
- deployOperation.deployments,
- deployOperation.depID,
- deployOperation.modules,
- deployOperation.instances);
-
- if (terminateOperation.getException() != null) {
- throw terminateOperation.getException();
- }
- new OperationExecuter().execOp(terminateOperation);
- }
+// if (deployOperation.getActiontoDo().equals(
+// ActionToDo.TERMINATE_AND_REVERT_ON_ERROR)
+// && !deployOperation.failed_to_deploy.isEmpty()) {
+// OpenStackOpTerminateApplication terminateOperation = new OpenStackOpTerminateApplication(
+// deployOperation.deployments,
+// deployOperation.depID,
+// deployOperation.modules,
+// deployOperation.instances);
+//
+// if (terminateOperation.getException() != null) {
+// throw terminateOperation.getException();
+// }
+// new OperationExecuter().execOp(terminateOperation);
+// }
} catch (Exception e) {
e.printStackTrace();