@Override
	public IMachine createMachine(IComputeCenter computeCenter, IImage image, IMachineDescriptor machineDescriptor)
			throws InvalidObjectException, ConnectorException
	{

		boolean succeeded = false;
		Exception createFailureRootCause = null;
		Server server = null;

		CloudStackClient client = ClientLocator.getInstance().getClient(computeCenter.getProperties(), controllerServices);

		try
		{
			String controllerHost = System.getProperty(CONTROLLER_SERVICES_HOST_NAME_PROPERTY_KEY, InetAddress
					.getLocalHost().getHostAddress());

			int controllerPort = Integer.getInteger(CONTROLLER_SERVICES_PORT_PROPERTY_KEY, DEFAULT_CONTROLLER_PORT_VALUE);

			IAccount account = computeCenter.getAccount();
			String accountName = account.getName();
			String accessKey = account.getAccessKey();

			AgentResolutionEncoder agentResolutionEncoder = new AgentResolutionEncoder(controllerHost, controllerPort,
					accountName, accessKey);

			server = createServer(agentResolutionEncoder, image,  machineDescriptor.getProperties(), client);

			IMachine machine = controllerServices.createMachineInstance(server.getId(),
					agentResolutionEncoder.getUniqueHostIdentifier(), computeCenter, machineDescriptor, image,
					getAgentPort());

			logger.info(computeCenter.getType().getName() + " instance created; machine id:" + machine.getId()
					+ "; server id:" + server.getId());

			succeeded = true;
			return machine;
		}
		catch (Exception e)
		{
			createFailureRootCause = e;
			throw new ConnectorException(e.getMessage(), e);
		}
		finally
		{
			if (!succeeded && server != null)
			{
				try
				{
					client.terminateVirtualMachine(server.getId());
				}
				catch (Exception e)
				{
					throw new ConnectorException("Machine create failed, but terminate failed as well! "
							+ "We have an orphan " + computeCenter.getType().getName() + " instance with id: "
							+ server.getId() + " that must be shut down manually. Root cause for machine "
							+ "create failure is following: ", createFailureRootCause);
				}
			}
		}

	}