propellor spin

This commit is contained in:
Joey Hess 2014-11-22 15:54:31 -04:00
parent 97931fe670
commit 40339a7fd8
Failed to extract signature
2 changed files with 11 additions and 6 deletions

View File

@ -53,9 +53,8 @@ processCmdLine = go =<< getArgs
exitFailure exitFailure
go ("--update":_:[]) = return $ Update Nothing go ("--update":_:[]) = return $ Update Nothing
go ("--boot":_:[]) = return $ Update Nothing -- for back-compat go ("--boot":_:[]) = return $ Update Nothing -- for back-compat
go ("--continue":s:[]) = case readish s of go ("--serialized":s:[]) = serialized Serialized s
Just cmdline -> return $ Continue cmdline go ("--continue":s:[]) = serialized Continue s
Nothing -> errorMessage $ "--continue serialization failure (" ++ s ++ ")"
go ("--gitpush":fin:fout:_) = return $ GitPush (Prelude.read fin) (Prelude.read fout) go ("--gitpush":fin:fout:_) = return $ GitPush (Prelude.read fin) (Prelude.read fout)
go (h:[]) go (h:[])
| "--" `isPrefixOf` h = usageError [h] | "--" `isPrefixOf` h = usageError [h]
@ -71,6 +70,10 @@ processCmdLine = go =<< getArgs
Just pf -> return $ f pf (Context c) Just pf -> return $ f pf (Context c)
Nothing -> errorMessage $ "Unknown privdata field " ++ s Nothing -> errorMessage $ "Unknown privdata field " ++ s
serialized mk s = case readish s of
Just cmdline -> return $ mk cmdline
Nothing -> errorMessage $ "serialization failure (" ++ s ++ ")"
-- | Runs propellor on hosts, as controlled by command-line options. -- | Runs propellor on hosts, as controlled by command-line options.
defaultMain :: [Host] -> IO () defaultMain :: [Host] -> IO ()
defaultMain hostlist = do defaultMain hostlist = do
@ -80,6 +83,7 @@ defaultMain hostlist = do
debug ["command line: ", show cmdline] debug ["command line: ", show cmdline]
go True cmdline go True cmdline
where where
go _ (Serialized cmdline) = go True cmdline
go _ (Continue cmdline) = go False cmdline go _ (Continue cmdline) = go False cmdline
go _ (Set field context) = setPrivData field context go _ (Set field context) = setPrivData field context
go _ (Dump field context) = dumpPrivData field context go _ (Dump field context) = dumpPrivData field context
@ -196,10 +200,10 @@ spin target relay hst = do
, "fi" , "fi"
] ]
runcmd = mkcmd [ "cd " ++ localdir ++ " && ./propellor --continue " ++ shellEscape (show cmd) ] runcmd = mkcmd [ "cd " ++ localdir ++ " && ./propellor " ++ cmd ]
cmd = if isNothing relay cmd = if isNothing relay
then SimpleRun target then "--continue " ++ shellEscape (show (SimpleRun target))
else Spin target (Just target) else "--serialized " ++ shellEscape (show (Spin target (Just target)))
runparams = catMaybes runparams = catMaybes
[ if isJust relay then Just "-A" else Nothing [ if isJust relay then Just "-A" else Nothing
, Just "-t" , Just "-t"

View File

@ -149,6 +149,7 @@ data CmdLine
| Edit PrivDataField Context | Edit PrivDataField Context
| ListFields | ListFields
| AddKey String | AddKey String
| Serialized CmdLine
| Continue CmdLine | Continue CmdLine
| Update (Maybe HostName) | Update (Maybe HostName)
| DockerInit HostName | DockerInit HostName