package org.cloudcoder.app.wizard.exec;


public class BootstrapStep<InfoType extends ICloudInfo, ServiceType extends ICloudService<InfoType, ServiceType>>
		extends AbstractInstallStep<InfoType, ServiceType> {
	private class EstablishSshConnectivitySubStep extends AbstractInstallSubStep<InfoType, ServiceType> {
		@Override
		public String getDescription() {
			return "Establishing ssh connectivity with ssh instance";
		}
		
		@Override
		protected void doExecute(ServiceType cloudService) throws ExecException {
			bootstrap.establishSshConnectivity();
		}
	}
	
	private class DownloadBootstrapScriptSubStep extends AbstractInstallSubStep<InfoType, ServiceType> {
		@Override
		public String getDescription() {
			return "Downloading bootstrap script on webapp instance";
		}

		@Override
		protected void doExecute(ServiceType cloudService) throws ExecException {
			bootstrap.downloadBootstrapScript();
		}
	}
	
	private class UploadBootstrapPropertiesSubStep extends AbstractInstallSubStep<InfoType, ServiceType> {
		@Override
		public String getDescription() {
			return "Upload the configuration properties to the webapp instance";
		}

		@Override
		protected void doExecute(ServiceType cloudService) throws ExecException {
			bootstrap.uploadBootstrapProperties();
		}
	}
	
	private class RunBootstrapScriptSubStep extends AbstractInstallSubStep<InfoType, ServiceType> {
		@Override
		public String getDescription() {
			return "Running the bootstrap script to install CloudCoder (takes several minutes)";
		}

		@Override
		protected void doExecute(ServiceType cloudService) throws ExecException {
			bootstrap.runBootstrapScript();
		}
	}
	
	private Bootstrap<InfoType, ServiceType> bootstrap;
	
	public BootstrapStep(ServiceType cloudService) {
		super("bootstrap");
		this.bootstrap = new Bootstrap<InfoType, ServiceType>(cloudService);
		
		// Add sub-steps
		addSubStep(new EstablishSshConnectivitySubStep());
		addSubStep(new DownloadBootstrapScriptSubStep());
		addSubStep(new UploadBootstrapPropertiesSubStep());
		addSubStep(new RunBootstrapScriptSubStep());
	}

	@Override
	public String getDescription() {
		return "Bootstrap the webapp instance by installing/configuring the CloudCoder software";
	}
}

@@ -1640,32 +1640,373 @@
 ipt();%0A%09%09%7D%0A%09%7D%0A%09%0A
+%09public class ConfigureNoIpDNSHostnameSubStep extends AbstractInstallSubStep%3CInfoType, ServiceType%3E %7B%0A%09%09@Override%0A%09%09public String getDescription() %7B%0A%09%09%09return %22Using No-IP to configure hostname%22;%0A%09%09%7D%0A%09%09%0A%09%09@Override%0A%09%09protected void doExecute(ServiceType cloudService) throws ExecException %7B%0A%09%09%09bootstrap.configureNoIpDNSHostName();%0A%09%09%7D%0A%09%7D%0A%09%0A
 %09private Bootstr
@@ -2415,16 +2415,69 @@
 tep());%0A
+%09%09addSubStep(new ConfigureNoIpDNSHostnameSubStep());%0A
 %09%7D%0A%0A%09@Ov

add sub-step to configure DNS hostname using No-IP