// Path: src/main/java/org/cloudfoundry/community/servicebroker/datalifecycle/provider/CopyProvider.java
// public interface CopyProvider {
// 
// 	/**
// 	 * Create a copy of the source instance. The implementer should inject that
// 	 * through an environment variable or other means. Upon the copy will be
// 	 * launched and accessible to clients.
// 	 * 
// 	 * @param instanceId
// 	 *            to create a copy of
// 	 * @return the id of the new copy.
// 	 * @throws ServiceBrokerException
// 	 *             on error
// 	 */
// 	String createCopy(String instanceId)
// 			throws ServiceBrokerException;
// 
// 	/**
// 	 * Remove a copy from the iaas. The expectation is that all artifacts
// 	 * associated with the copy (snapshots, ami's etc) are cleaned up
// 	 * 
// 	 * @param instance
// 	 *            to delete
// 	 * @throws ServiceBrokerException
// 	 *             on error
// 	 */
// 	void deleteCopy(final String instance)
// 			throws ServiceBrokerException;
// 
// 	/**
// 	 * Return the creds hash associated with service brokers. Should contain a
// 	 * URI, username, password or whatever makes sense for your service. Will be
// 	 * injected into your app.
// 	 */
// 	Map<String, Object> getCreds(final String instance)
// 			throws ServiceBrokerException;
// }
// 
// Path: src/main/java/org/cloudfoundry/community/servicebroker/datalifecycle/utils/HostUtils.java
// public class HostUtils {
// 	private Logger logger = Logger.getLogger(HostUtils.class);
// 
// 	public boolean waitForBoot(String ip, int port)
// 			throws ServiceBrokerException {
// 
// 		logger.info("Waiting for " + ip + " to boot.");
// 		for (int i = 8; i > 0; --i) {
// 			try {
// 				try {
// 					Thread.sleep(20000);
// 				} catch (InterruptedException e1) {
// 					throw new ServiceBrokerException(
// 							"Internal Error! Something went wrong sleeping the threads!");
// 				}
// 				logger.info("Attempting to connect to " + ip + " on port "
// 						+ port);
// 				Socket socket = new Socket();
// 				SocketAddress addr = new InetSocketAddress(
// 						Inet4Address.getByName(ip), port);
// 				socket.connect(addr, 10000);
// 				boolean connected = socket.isConnected();
// 				socket.close();
// 				if (connected) {
// 					logger.info(ip + "is responding on " + port);
// 					return true;
// 				}
// 			} catch (IOException e) {
// 				logger.error(ip + " is not responding on " + port + " " + i
// 						+ " retires remaning.");
// 			}
// 		}
// 
// 		return false;
// 	}
// }


import org.cloudfoundry.community.servicebroker.datalifecycle.aws.AWSCopyProvider;
import org.cloudfoundry.community.servicebroker.datalifecycle.aws.AWSHelper;
import org.cloudfoundry.community.servicebroker.datalifecycle.provider.CopyProvider;
import org.cloudfoundry.community.servicebroker.datalifecycle.utils.HostUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.amazonaws.services.ec2.AmazonEC2Client;
package org.cloudfoundry.community.servicebroker.datalifecycle.config;



@Configuration
class AWSCopyProviderConfig {

	@Value("#{environment.PROD_DB_USER}")
	private String username;
	@Value("#{environment.PROD_DB_PASSWORD}")
	private String password;
	@Value("#{environment.PROD_DB_URI}")
	private String uri;
	@Value("#{environment.SOURCE_INSTANCE_ID}")
	private String sourceInstance;
	@Value("#{environment.SUBNET_ID}")
	private String subnetId;
	@Autowired
	private AmazonEC2Client ec2Client;
	@Autowired
	private HostUtils hostUtils;

	@Value("#{environment.BOOT_CHECK_PORT}")
	private int bootCheckPort;

	@Bean
// Path: src/main/java/org/cloudfoundry/community/servicebroker/datalifecycle/provider/CopyProvider.java
// public interface CopyProvider {
// 
// 	/**
// 	 * Create a copy of the source instance. The implementer should inject that
// 	 * through an environment variable or other means. Upon the copy will be
// 	 * launched and accessible to clients.
// 	 * 
// 	 * @param instanceId
// 	 *            to create a copy of
// 	 * @return the id of the new copy.
// 	 * @throws ServiceBrokerException
// 	 *             on error
// 	 */
// 	String createCopy(String instanceId)
// 			throws ServiceBrokerException;
// 
// 	/**
// 	 * Remove a copy from the iaas. The expectation is that all artifacts
// 	 * associated with the copy (snapshots, ami's etc) are cleaned up
// 	 * 
// 	 * @param instance
// 	 *            to delete
// 	 * @throws ServiceBrokerException
// 	 *             on error
// 	 */
// 	void deleteCopy(final String instance)
// 			throws ServiceBrokerException;
// 
// 	/**
// 	 * Return the creds hash associated with service brokers. Should contain a
// 	 * URI, username, password or whatever makes sense for your service. Will be
// 	 * injected into your app.
// 	 */
// 	Map<String, Object> getCreds(final String instance)
// 			throws ServiceBrokerException;
// }
// 
// Path: src/main/java/org/cloudfoundry/community/servicebroker/datalifecycle/utils/HostUtils.java
// public class HostUtils {
// 	private Logger logger = Logger.getLogger(HostUtils.class);
// 
// 	public boolean waitForBoot(String ip, int port)
// 			throws ServiceBrokerException {
// 
// 		logger.info("Waiting for " + ip + " to boot.");
// 		for (int i = 8; i > 0; --i) {
// 			try {
// 				try {
// 					Thread.sleep(20000);
// 				} catch (InterruptedException e1) {
// 					throw new ServiceBrokerException(
// 							"Internal Error! Something went wrong sleeping the threads!");
// 				}
// 				logger.info("Attempting to connect to " + ip + " on port "
// 						+ port);
// 				Socket socket = new Socket();
// 				SocketAddress addr = new InetSocketAddress(
// 						Inet4Address.getByName(ip), port);
// 				socket.connect(addr, 10000);
// 				boolean connected = socket.isConnected();
// 				socket.close();
// 				if (connected) {
// 					logger.info(ip + "is responding on " + port);
// 					return true;
// 				}
// 			} catch (IOException e) {
// 				logger.error(ip + " is not responding on " + port + " " + i
// 						+ " retires remaning.");
// 			}
// 		}
// 
// 		return false;
// 	}
// }


// Path: src/main/java/org/cloudfoundry/community/servicebroker/datalifecycle/config/AWSCopyProviderConfig.java
import org.cloudfoundry.community.servicebroker.datalifecycle.aws.AWSCopyProvider;
import org.cloudfoundry.community.servicebroker.datalifecycle.aws.AWSHelper;
import org.cloudfoundry.community.servicebroker.datalifecycle.provider.CopyProvider;
import org.cloudfoundry.community.servicebroker.datalifecycle.utils.HostUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.amazonaws.services.ec2.AmazonEC2Client;

package org.cloudfoundry.community.servicebroker.datalifecycle.config;



@Configuration
class AWSCopyProviderConfig {

	@Value("#{environment.PROD_DB_USER}")
	private String username;
	@Value("#{environment.PROD_DB_PASSWORD}")
	private String password;
	@Value("#{environment.PROD_DB_URI}")
	private String uri;
	@Value("#{environment.SOURCE_INSTANCE_ID}")
	private String sourceInstance;
	@Value("#{environment.SUBNET_ID}")
	private String subnetId;
	@Autowired
	private AmazonEC2Client ec2Client;
	@Autowired
	private HostUtils hostUtils;

	@Value("#{environment.BOOT_CHECK_PORT}")
	private int bootCheckPort;

	@Bean
	CopyProvider copyProvider() {