https://github.com/hexresearch/lxcops
Wrapper for lxc console tools
https://github.com/hexresearch/lxcops
Last synced: about 1 year ago
JSON representation
Wrapper for lxc console tools
- Host: GitHub
- URL: https://github.com/hexresearch/lxcops
- Owner: hexresearch
- Created: 2017-11-23T20:03:57.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-05T17:06:03.000Z (over 8 years ago)
- Last Synced: 2025-02-26T11:17:17.885Z (over 1 year ago)
- Language: Haskell
- Size: 14.6 KB
- Stars: 0
- Watchers: 13
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# lxcops
Это обёртка над консольными командами lxc.
Интерфейс — как в библиотеке https://hackage.haskell.org/package/lxc, но без
использования `bindings-lxc`, и реализован только частично, по необходимости.
#### Пример использования
[Main.hs](./examples/lxcops-example/src/Main.hs)
```haskell
module Main where
import Data.Monoid
import Control.Applicative
import Control.Monad (when)
import Control.Monad.IO.Class (liftIO)
import System.LxcOps
import System.LxcOps.Types
lxcAttachOptions :: AttachOptions
lxcAttachOptions = defaultAttachOptions { attachEnvPolicy = AttachClearEnv }
main = do
withContainer (Container "container-name" Nothing) $ do
isdef <- isDefined
when isdef $ do
ci <- containerInfo
liftIO $ putStrLn $ "Container exists: " <> show ci
stop
wait ContainerStopped (-1)
destroy
pure ()
d <- create "download" Nothing Nothing [] ["-d", "ubuntu", "-r", "xenial", "-a", "amd64"]
start False []
wait ContainerRunning (-1)
cmdresult <- attachRunWait lxcAttachOptions "uname" ["-a"]
liftIO $ putStrLn $ "uname result: " <> show cmdresult
stop
wait ContainerStopped (-1)
clone (Just "new-name") Nothing [CloneSnapshot] Nothing Nothing Nothing []
withContainer (Container "new-name" Nothing) $ do
ci <- containerInfo
liftIO $ putStrLn $ "Clone: " <> show ci
```