Skip to content

API

layout class-attribute

layout = ForeignKeyField(
    LayoutModel, backref="machines", on_delete="CASCADE"
)

instance_name class-attribute

instance_name = CharField()

instance_id class-attribute

instance_id = CharField()

instance_state class-attribute

instance_state = CharField()

public_ip class-attribute

public_ip = CharField()

private_ip class-attribute

private_ip = CharField()

created class-attribute

created = DateTimeField(default=datetime.datetime.utcnow())

extra class-attribute

extra = JSONField(null=True)

tainted class-attribute

tainted = BooleanField(default=False)

remote_state_file class-attribute

remote_state_file = CharField(null=True)

Meta

table_name class-attribute

table_name = 'machines'

state

state() -> Node | None

Returns the store remote state of a node in the cloud

Source code in ogc/models/machine.py
def state(self) -> Node | None:
    """Returns the store remote state of a node in the cloud"""
    state_file_p = Path(str(self.remote_state_file))
    if state_file_p.exists():
        out: Node = pickle_to_model(state_file_p.read_bytes())
        return out
    return None

ssh

ssh() -> ParamikoSSHClient | None

Provides an SSH Client for use with provisioning

Source code in ogc/models/machine.py
@retry(tries=5, delay=5, jitter=(1, 5), logger=None)
def ssh(self) -> ParamikoSSHClient | None:
    """Provides an SSH Client for use with provisioning"""
    priv_key = Path(self.layout.ssh_private_key).expanduser().resolve()
    if self.public_ip and self.layout.username:
        _client = ParamikoSSHClient(
            str(self.public_ip),
            username=str(self.layout.username),
            key=str(priv_key),
            timeout=300,
            use_compression=True,
        )
        try:
            _client.connect()
        except paramiko.ssh_exception.SSHException:
            log.error(
                f"Authentication failed for: ({self.layout.name}/{priv_key}) {self.layout.username}@{self.public_ip}"
            )
            return None
        return _client
    return None