Skip to content

Instantly share code, notes, and snippets.

View yaronp68's full-sized avatar

Yaron Parasol yaronp68

  • Redis
  • London
View GitHub Profile
@Override
public boolean stopMachine(final String ip, final long duration, final TimeUnit unit)
throws InterruptedException, TimeoutException, CloudProvisioningException {
final long endTime = calcEndTimeInMillis(
duration, unit);
if (isStopRequestRecent(ip)) {
return false;
}
private String createServer(final String token, final CloudTemplate serverTemplate)
throws OpenstackException {
final String serverName = this.serverNamePrefix + System.currentTimeMillis();
final String securityGroup = getCustomTemplateValue(
serverTemplate, OPENSTACK_SECURITYGROUP, null, false);
final String keyPairName = getCustomTemplateValue(
serverTemplate, OPENSTACK_KEY_PAIR, null, false);
// Start the machine!
final String json =
@Override
public void setConfig(final Cloud cloud, final String templateName, final boolean management) {
super.setConfig(
cloud, templateName, management);
if (this.management) {
this.serverNamePrefix = this.cloud.getProvider().getManagementGroup();
} else {
this.serverNamePrefix = this.cloud.getProvider().getMachineNamePrefix();
}
user {
user Your_User_Here
apiKey Your_API_Key_Here
keyFile Your_PEM_File_Name_Here
}
private String createServer(final String token, final CloudTemplate serverTemplate)
throws OpenstackException {
final String serverName = this.serverNamePrefix + System.currentTimeMillis();
final String securityGroup = getCustomTemplateValue(
serverTemplate, OPENSTACK_SECURITYGROUP, null, false);
final String keyPairName = getCustomTemplateValue(
serverTemplate, OPENSTACK_KEY_PAIR, null, false);
// Start the machine!
final String json =
public MachineDetails[] startManagementMachines(final long duration, final TimeUnit unit)
throws TimeoutException, CloudProvisioningException {
final String token = createAuthenticationToken();
final long endTime = calcEndTimeInMillis(
duration, unit);
final int numOfManagementMachines = cloud.getProvider().getNumberOfManagementMachines();
// thread pool - one per machine
final ExecutorService executor =
@yaronp68
yaronp68 / cloudstack.groovy
Created February 8, 2012 17:08
Cloudstack Cloud Driver Configuration File
cloud {
name = "cloudstack"
configuration {
className "org.cloudifysource.esc.driver.provisioning.jclouds.DefaultProvisioningDriver"
managementMachineTemplate "CentOS5_4GS_JAVA"
connectToPrivateIp true
bootstrapManagementOnPublicIp false
remoteUsername "root"
remotePassword "Your Password Here"
}
cloud {
// Mandatory. The name of the cloud, as it will appear in the Cloudify UI.
name = "ec2"
/********
* General configuration information about the cloud driver implementation.
*/
configuration {
// Optional. The cloud implementation class. Defaults to the build in jclouds-based provisioning driver.
className "org.cloudifysource.esc.driver.provisioning.jclouds.DefaultProvisioningDriver"
public interface ProvisioningDriver {
/**************
* Called once on startup of the cloud driver, passing the cloud configuration to it.
*
* @param cloudTemplate
* @param cloud
*
* @param config The configuration settings.
@yaronp68
yaronp68 / gist:1710373
Created January 31, 2012 12:59
Apache Load Balancer Custom Commands
customCommands ([
"add-node" : { node, instanceID ->
def proxyConfigFile = new File(context.serviceDirectory + "/install/conf/extra/httpd-proxy-balancer.conf")
def config = proxyConfigFile.text
def modifiedConfig = config.replace("# Generated code - DO NOT MODIFY", "# Generated code - DO NOT MODIFY" + System.getProperty("line.separator") + "BalancerMember " + node + " route=" + instanceID)
proxyConfigFile.text = modifiedConfig
ServiceUtils.killProcess(context.externalProcessId)
},
"remove-node" : { node, instanceID ->