diff --git a/spotty/__init__.py b/spotty/__init__.py index e398332..07f744c 100644 --- a/spotty/__init__.py +++ b/spotty/__init__.py @@ -1 +1 @@ -__version__ = '1.3.2' +__version__ = '1.3.3' diff --git a/spotty/deployment/abstract_cloud_instance/abstract_cloud_instance_manager.py b/spotty/deployment/abstract_cloud_instance/abstract_cloud_instance_manager.py index e71cfa3..3082df7 100644 --- a/spotty/deployment/abstract_cloud_instance/abstract_cloud_instance_manager.py +++ b/spotty/deployment/abstract_cloud_instance/abstract_cloud_instance_manager.py @@ -164,12 +164,11 @@ def ssh_host(self): if not instance or not instance.is_running: raise InstanceNotRunningError(self.instance_config.name) - public_ip_address = instance.public_ip_address - if not public_ip_address: - raise ValueError('The running instance doesn\'t have a public IP address.\n' - 'Use the "localSshPort" parameter if you want to create a tunnel to the instance.') + instance_ip_address = instance.public_ip_address if instance.public_ip_address else instance.private_ip_address + if not instance_ip_address: + raise ValueError('Instance IP address not found') - return public_ip_address + return instance_ip_address @property def ssh_port(self) -> int: diff --git a/spotty/deployment/abstract_cloud_instance/resources/abstract_instance.py b/spotty/deployment/abstract_cloud_instance/resources/abstract_instance.py index a51f2c1..bf45013 100644 --- a/spotty/deployment/abstract_cloud_instance/resources/abstract_instance.py +++ b/spotty/deployment/abstract_cloud_instance/resources/abstract_instance.py @@ -7,6 +7,10 @@ class AbstractInstance(ABC): def public_ip_address(self): raise NotImplementedError + @property + def private_ip_address(self): + raise NotImplementedError + @property def is_running(self): """Returns true if the instance is running.""" diff --git a/spotty/providers/aws/instance_manager.py b/spotty/providers/aws/instance_manager.py index bfd3d92..49f50a8 100644 --- a/spotty/providers/aws/instance_manager.py +++ b/spotty/providers/aws/instance_manager.py @@ -49,6 +49,8 @@ def get_status_text(self): if instance.public_ip_address: table.append(('Public IP Address', instance.public_ip_address)) + elif instance.private_ip_address: + table.append(('Private IP Address', instance.private_ip_address)) if instance.lifecycle == 'spot': spot_price = instance.get_spot_price() diff --git a/spotty/providers/aws/resources/instance.py b/spotty/providers/aws/resources/instance.py index 6f902e6..1f5b649 100644 --- a/spotty/providers/aws/resources/instance.py +++ b/spotty/providers/aws/resources/instance.py @@ -35,6 +35,10 @@ def instance_id(self): def public_ip_address(self) -> str: return self._data.get('PublicIpAddress', None) + @property + def private_ip_address(self) -> str: + return self._data.get('PrivateIpAddress', None) + @property def state(self) -> str: return self._data['State']['Name']