Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,11 @@ def upgrade() -> None:
sa.Column("parent_use_latest", sa.Boolean(), nullable=True),
)

# Add the instance columns to the vms (ex programs) table
# Add new columns to the vms (ex programs) table
op.add_column(
"vms",
sa.Column(
"cloud_config", postgresql.JSONB(astext_type=sa.Text()), nullable=True
"authorized_keys", postgresql.JSONB(astext_type=sa.Text()), nullable=True
),
)
op.add_column("vms", sa.Column("program_type", sa.String(), nullable=True))
Expand Down Expand Up @@ -397,7 +397,7 @@ def downgrade() -> None:
op.execute("ALTER INDEX ix_vms_owner RENAME TO ix_programs_owner")

op.drop_column("programs", "program_type")
op.drop_column("programs", "cloud_config")
op.drop_column('programs', 'authorized_keys')

# Drop the parent column for persistent VMs
op.drop_column("program_machine_volumes", "parent")
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ install_requires =
aiohttp==3.8.4
aioipfs@git+https://github.com/aleph-im/aioipfs.git@d671c79b2871bb4d6c8877ba1e7f3ffbe7d20b71
alembic==1.8.1
aleph-message==0.4.0a1
aleph-message@git+https://github.com/aleph-im/aleph-message.git@34016aea9d097b21993ad00be3f81cb1d9c738e8
aleph-p2p-client@git+https://github.com/aleph-im/p2p-service-client-python@2c04af39c566217f629fd89505ffc3270fba8676
aleph-pytezos@git+https://github.com/aleph-im/aleph-pytezos.git@32dd1749a4773da494275709060632cbeba9a51b
asyncpg==0.26.0
Expand Down
4 changes: 2 additions & 2 deletions src/aleph/db/models/vms.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class VmBaseDb(Base):
replaces: Optional[str] = Column(ForeignKey(item_hash), nullable=True)
created: dt.datetime = Column(TIMESTAMP(timezone=True), nullable=False)

authorized_keys: Optional[List[str]] = Column(JSONB, nullable=True)

__mapper_args__: Dict[str, Any] = {
"polymorphic_on": type,
}
Expand All @@ -160,8 +162,6 @@ class VmInstanceDb(VmBaseDb):
"polymorphic_identity": VmType.INSTANCE.value,
}

cloud_config: Dict[str, Any] = Column(JSONB, nullable=True)

rootfs: RootfsVolumeDb = relationship(
"RootfsVolumeDb", back_populates="instance", uselist=False
)
Expand Down
2 changes: 1 addition & 1 deletion src/aleph/handlers/content/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def vm_message_to_db(message: MessageDb) -> VmBaseDb:
size_mib=content.rootfs.size_mib,
persistence=content.rootfs.persistence,
)
vm.cloud_config = content.cloud_config
vm.authorized_keys = content.authorized_keys

else:
raise TypeError(f"Unexpected VM message content type: {type(content)}")
Expand Down
13 changes: 10 additions & 3 deletions tests/message_processing/test_process_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ def fixture_instance_message(session_factory: DbSessionFactory) -> PendingMessag
"name": "test-rootfs",
"size_mib": 20000,
},
"cloud_config": {"password": "password"},
"authorized_keys": [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGULT6A41Msmw2KEu0R9MvUjhuWNAsbdeZ0DOwYbt4Qt user@example",
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH0jqdc5dmt75QhTrWqeHDV9xN8vxbgFyOYs2fuQl7CI",
],
"volumes": [
{
"comment": "Python libraries. Read-only since a 'ref' is specified.",
Expand Down Expand Up @@ -273,8 +276,12 @@ async def test_process_instance(

rootfs = instance.rootfs
assert rootfs.parent_ref == content_dict["rootfs"]["parent"]["ref"]
assert rootfs.parent_use_latest == content_dict["rootfs"]["parent"]["use_latest"]
assert rootfs.parent_use_latest == content_dict["rootfs"]["parent"]["use_latest"]
assert (
rootfs.parent_use_latest == content_dict["rootfs"]["parent"]["use_latest"]
)
assert (
rootfs.parent_use_latest == content_dict["rootfs"]["parent"]["use_latest"]
)
assert rootfs.size_mib == content_dict["rootfs"]["size_mib"]
assert rootfs.persistence == content_dict["rootfs"]["persistence"]

Expand Down