in cloud-vmware-agent/src/main/java/jetbrains/buildServer/clouds/vmware/VMWarePropertiesReader.java [71:131]
public VMWarePropertiesReader(final BuildAgentConfigurationEx agentConfiguration,
@NotNull EventDispatcher<AgentLifeCycleListener> events) {
LOG.info("VSphere plugin initializing...");
myAgentConfiguration = agentConfiguration;
myVMWareRPCToolPath = getToolPath(myAgentConfiguration);
if (!"true".equalsIgnoreCase(myAgentConfiguration.getInternalProperty("teamcity.agent.cloud.integration.enable", "true"))
) {
LOG.warn("VMWare Virtual Machine metadata detection is disabled. Agent will not be able to update it's name if bundled as a VM image.");
return;
}
if (myVMWareRPCToolPath == null) {
LOG.info("Unable to locate " + VMWARE_RPCTOOL_NAME + ". Looks like not a VMWare VM or VWWare tools are not installed");
return;
} else {
LOG.info("Detected vmware-tools or open-vm-tools. Found required vmware-rpctool at " + myVMWareRPCToolPath + ". " +
"Will attempt to authorize agent as VMWare cloud agent. ");
}
events.addListener(new AgentLifeCycleAdapter() {
@Override
public void afterAgentConfigurationLoaded(@NotNull final BuildAgent agent) {
final String serverUrl = getPropertyValue(SERVER_URL);
if (StringUtil.isEmpty(serverUrl)) {
LOG.info("Unable to read property " + SERVER_URL + ". VMWare integration is disabled");
return;
} else {
LOG.info("Server URL: " + serverUrl);
}
final String instanceName = getPropertyValue(INSTANCE_NAME);
if (StringUtil.isEmpty(instanceName)) {
LOG.info("Unable to read property " + INSTANCE_NAME + ". VMWare integration is disabled");
return;
} else {
LOG.info("Instance name: " + instanceName);
}
myAgentConfiguration.setName(instanceName);
myAgentConfiguration.setServerUrl(serverUrl);
myAgentConfiguration.addConfigurationParameter(INSTANCE_NAME, instanceName);
String imageName = getPropertyValue(IMAGE_NAME);
if (!StringUtil.isEmpty(imageName)) {
LOG.info("Image name: " + imageName);
myAgentConfiguration.addConfigurationParameter(IMAGE_NAME, imageName);
}
String userData = getPropertyValue(USER_DATA);
if (!StringUtil.isEmpty(userData)) {
LOG.debug("UserData: " + userData);
final CloudInstanceUserData cloudUserData = CloudInstanceUserData.deserialize(userData);
if (cloudUserData != null) {
final Map<String, String> customParameters = cloudUserData.getCustomAgentConfigurationParameters();
for (Map.Entry<String, String> entry : customParameters.entrySet()) {
myAgentConfiguration.addConfigurationParameter(entry.getKey(), entry.getValue());
}
}
}
}
});
}