/** * Create a complete command line, including path and arguments. * * @return Configured command line, ready for execution */ private CommandLine createCommandLine() { final String javaPath = getJavaPath(); final String gsHome = Environment.getHomeDirectory(); final String[] commandParams = { "-Dcom.gs.home=" + gsHome, "-Dorg.hyperic.sigar.path=" + gsHome + "/lib/platform/sigar", "-Dcom.gs.usm.RecipeShutdownTimeout=" + timeout, IntegratedProcessingUnitContainer.class.getName(), "-cluster", "id=1", "total_members=1" }; final CommandLine cmdLine = new CommandLine(javaPath); for (final String param : commandParams) { cmdLine.addArgument(param); } if (this.serviceFileName != null) { cmdLine.addArgument("-properties"); cmdLine.addArgument( "embed://" + CloudifyConstants.CONTEXT_PROPERTY_SERVICE_FILE_NAME + "=" + this.serviceFileName); } // -Dcom.gs.usm.RecipeShutdownTimeout=10 return cmdLine; }
/** * Returns the directory (as a File object) if it exists. If the directory is not found in the * given location or is not a directory - an IllegalStateException is thrown. * * @param dirName Directory name, relative to the home directory * @return Directory as a File object. */ private File getDirIfExists(final String dirName) { final File requiredDir = new File(Environment.getHomeDirectory() + File.separator + dirName); if (!requiredDir.exists()) { throw new IllegalStateException("Could not find directory: " + dirName); } if (!requiredDir.isDirectory()) { throw new IllegalStateException(requiredDir + " is not a directory"); } return requiredDir; }
/** @return */ private static File getUsmLibDir(final Service service) { final Map<String, String> customProperties = service.getCustomProperties(); File usmLibDir = null; if (customProperties != null) { final String usmJarPathProp = customProperties.get(USM_JAR_PATH_PROP); if (usmJarPathProp != null) { usmLibDir = new File(usmJarPathProp); } } if (usmLibDir == null) { usmLibDir = new File(Environment.getHomeDirectory() + "/lib/platform/usm"); } return usmLibDir; }
@SuppressWarnings("unchecked") @Override public void setConfig( final Cloud cloud, final String templateName, final boolean management, final String[] zones) { super.setConfig(cloud, templateName, management, zones); // Per template properties this.availabilitySet = (String) this.template.getCustom().get(AZURE_AVAILABILITY_SET); String pfxFile = (String) this.template.getCustom().get(AZURE_PFX_FILE); if (pfxFile == null && management) { throw new IllegalArgumentException("Custom field '" + AZURE_PFX_FILE + "' must be set"); } if (this.management) { this.pathToPfxFile = Environment.getHomeDirectory() + File.separator + this.template.getLocalDirectory() + File.separator + pfxFile; } else { this.pathToPfxFile = this.template.getRemoteDirectory() + File.separator + pfxFile; } this.pfxPassword = (String) this.template.getCustom().get(AZURE_PFX_PASSWORD); if (pfxPassword == null && management) { throw new IllegalArgumentException("Custom field '" + AZURE_PFX_PASSWORD + "' must be set"); } this.deploymentSlot = (String) this.template.getCustom().get(AZURE_DEPLOYMENT_SLOT); if (deploymentSlot == null) { deploymentSlot = "Staging"; } this.endpoints = (List<Map<String, String>>) this.template.getCustom().get(AZURE_ENDPOINTS); this.imageName = this.template.getImageId(); this.userName = this.template.getUsername(); this.password = this.template.getPassword(); this.size = this.template.getHardwareId(); this.subscriptionId = this.cloud.getUser().getUser(); this.cleanup = Boolean.parseBoolean((String) this.cloud.getCustom().get(AZURE_CLEANUP_ON_TEARDOWN)); this.location = (String) this.cloud.getCustom().get(AZURE_AFFINITY_LOCATION); if (location == null) { throw new IllegalArgumentException( "Custom field '" + AZURE_AFFINITY_LOCATION + "' must be set"); } this.addressSpace = (String) this.cloud.getCustom().get(AZURE_NETOWRK_ADDRESS_SPACE); if (addressSpace == null) { throw new IllegalArgumentException( "Custom field '" + AZURE_NETOWRK_ADDRESS_SPACE + "' must be set"); } this.affinityGroup = (String) this.cloud.getCustom().get(AZURE_AFFINITY_GROUP); if (affinityGroup == null) { throw new IllegalArgumentException("Custom field '" + AZURE_AFFINITY_GROUP + "' must be set"); } this.networkName = (String) this.cloud.getCustom().get(AZURE_NETWORK_NAME); if (networkName == null) { throw new IllegalArgumentException("Custom field '" + AZURE_NETWORK_NAME + "' must be set"); } this.storageAccountName = (String) this.cloud.getCustom().get(AZURE_STORAGE_ACCOUNT); if (storageAccountName == null) { throw new IllegalArgumentException( "Custom field '" + AZURE_STORAGE_ACCOUNT + "' must be set"); } if (this.management) { this.serverNamePrefix = this.cloud.getProvider().getManagementGroup(); } else { this.serverNamePrefix = this.cloud.getProvider().getMachineNamePrefix(); } final String wireLog = (String) this.cloud.getCustom().get(AZURE_WIRE_LOG); boolean enableWireLog = false; if (wireLog != null) { enableWireLog = Boolean.parseBoolean(wireLog); } initRestClient(this.subscriptionId, this.pathToPfxFile, this.pfxPassword, enableWireLog); }
/** * Gets the CLI directory. * * @return the CLI directory */ public static File getCliDirectory() { return new File(Environment.getHomeDirectory(), "/tools/cli"); }