Skip to content

Commit

Permalink
MemoryBackend: init
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamc committed Mar 26, 2020
1 parent 4370ba1 commit 0911dea
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nixops/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import nixops.plugins
from nixops.storage import StorageBackend
from nixops.storage.legacy import LegacyBackend
from nixops.storage.memory import MemoryBackend


@nixops.plugins.hookimpl
def register_backends() -> Dict[str, Type[StorageBackend]]:
return {"legacy": LegacyBackend}
return {"legacy": LegacyBackend, "memory": MemoryBackend}
27 changes: 27 additions & 0 deletions nixops/storage/memory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import nixops.statefile
from nixops.storage import StorageArgDescriptions, StorageArgValues


class MemoryBackend:
@staticmethod
def arguments() -> StorageArgDescriptions:
raise NotImplementedError

def __init__(self, args: StorageArgValues) -> None:
pass

# fetchToFile: acquire a lock and download the state file to
# the local disk. Note: no arguments will be passed over kwargs.
# Making it part of the type definition allows adding new
# arguments later.
def fetchToFile(self, path: str, **kwargs) -> None:
pass

def onOpen(self, sf: nixops.statefile.StateFile, **kwargs) -> None:
sf.create_deployment()

# uploadFromFile: upload the new state file and release any locks
# Note: no arguments will be passed over kwargs. Making it part of
# the type definition allows adding new arguments later.
def uploadFromFile(self, path: str, **kwargs) -> None:
pass

0 comments on commit 0911dea

Please sign in to comment.