Name

global.FindLogicalDataCenter

Description

Find Logical Data Center based on FQDN associated with one of its resources

Script

var FindLogicalDataCenter = Class.create();
FindLogicalDataCenter.prototype = {
  initialize: function() {
  },
  
  getHostForEndpoint: function(endpointGr) {
  	var hostname = endpointGr.getValue('host_name');
  	gs.debug("FindLogicalDataCenter: hostname = {0}, endpointGr.host = {1}", hostname, endpointGr.host);
  	
  	// In case the host on the endpoint is different than the hostname, we are probably in the case of endpoint
  	// from the LB to the next tier
  	if (endpointGr.host != hostname && JSUtil.notNil(hostname))
  		return null;
  	
  	var findHostStrategies = new FindHostStrategies();
  	gs.debug("FindLogicalDataCenter: calling findHostStrategies.findLogicalDataCenterFromHostname with {0}", hostname);
  	var ldc = findHostStrategies.findLogicalDataCenterFromHostname(hostname);
  	if (ldc)
  		return ldc;
  	var ip = endpointGr.getValue('ip_address');
  	
  	gs.debug("FindLogicalDataCenter: calling findHostStrategies.findLogicalDataCenterFromIp with {0}", ip);
  	ldc = findHostStrategies.findLogicalDataCenterFromIp(ip);
  	if (ldc)
  		return ldc;
  	
  	gs.debug("FindLogicalDataCenter: calling findHostStrategies.findLogicalDataCenterFromDnsAlias with {0}", hostname);
  	ldc = findHostStrategies.findLogicalDataCenterFromDnsAlias(hostname);
  	if (ldc)
  		return ldc;
  	
  	return null;
  },
  
  type: 'FindLogicalDataCenter'
};

Sys ID

c59ea6807f3322005598baf8befa91d0

Offical Documentation

Official Docs: