DataSift\Storyplayer\HostLib\Ec2Vm::determineIpAddress PHP Method

determineIpAddress() public method

public determineIpAddress ( Ec2VmDetails $vmDetails ) : string
$vmDetails Ec2VmDetails
return string
    public function determineIpAddress($vmDetails)
    {
        // what are we doing?
        $log = usingLog()->startAction("determine IP address of EC2 VM '{$vmDetails->hostId}'");
        // we need to get a fresh copy of the instance details
        $dnsName = fromEc2Instance($vmDetails->hostId)->getPublicDnsName();
        // do we have a DNS name?
        if (!$dnsName) {
            throw new E5xx_ActionFailed(__METHOD__, "Ec2Vm has no public DNS name - is the VM broken?");
        }
        // convert it to an IP address
        $ipAddress = gethostbyname($dnsName);
        // did we get one?
        if ($ipAddress == $dnsName) {
            throw new E5xx_ActionFailed(__METHOD__, "unable to convert hostname '{$dnsName}' into an IP address");
        }
        // all done
        $log->endAction("IP address is '{$ipAddress}'");
        return $ipAddress;
    }