func CleanUp(do *definitions.Do, dapp *definitions.Contracts) error { logger.Infof("Commensing CleanUp.\n") if do.Chain.ChainType == "throwaway" { logger.Debugf("Destroying Throwaway Chain =>\t%s\n", do.Chain.Name) doRm := definitions.NowDo() doRm.Operations = do.Operations doRm.Name = do.Chain.Name doRm.Rm = true doRm.RmD = true chains.KillChain(doRm) logger.Debugf("Removing latent files/dirs =>\t%s:%s\n", path.Join(common.DataContainersPath, do.Chain.Name), path.Join(common.BlockchainsPath, do.Chain.Name+".toml")) os.RemoveAll(path.Join(common.DataContainersPath, do.Chain.Name)) os.Remove(path.Join(common.BlockchainsPath, do.Chain.Name+".toml")) } else { logger.Debugf("No Throwaway Chain to destroy.\n") } logger.Debugf("Removing data dir on host =>\t%s\n", path.Join(common.DataContainersPath, do.Service.Name)) os.RemoveAll(path.Join(common.DataContainersPath, do.Service.Name)) logger.Debugf("Removing tmp srv contnr =>\t%s\n", do.Operations.SrvContainerName) perform.DockerRemove(do.Service, do.Operations, true) return nil }
func KillChain(cmd *cobra.Command, args []string) { // [csk]: if no args should we just start the checkedout chain? IfExit(ArgCheck(1, "ge", cmd, args)) do.Name = args[0] IfExit(chns.KillChain(do)) }
func CleanUp(do *definitions.Do, app *definitions.Contracts) error { log.Info("Cleaning up") if do.Chain.ChainType == "throwaway" { log.WithField("=>", do.Chain.Name).Debug("Destroying throwaway chain") doRm := definitions.NowDo() doRm.Operations = do.Operations doRm.Name = do.Chain.Name doRm.Rm = true doRm.RmD = true chains.KillChain(doRm) latentDir := filepath.Join(common.DataContainersPath, do.Chain.Name) latentFile := filepath.Join(common.ChainsPath, do.Chain.Name+".toml") log.WithFields(log.Fields{ "dir": latentDir, "file": latentFile, }).Debug("Removing latent dir and file") os.RemoveAll(latentDir) os.Remove(latentFile) } else { log.Debug("No throwaway chain to destroy") } doData := definitions.NowDo() doData.Name = do.Service.Name doData.Operations = do.Operations doData.Source = common.ErisContainerRoot if do.Path != pwd { doData.Destination = do.Path } else { doData.Destination = filepath.Join(common.DataContainersPath, doData.Name) } var loca string if do.Path != pwd { loca = filepath.Join(common.DataContainersPath, doData.Name, do.Path) } else { loca = filepath.Join(common.DataContainersPath, doData.Name, "apps", app.Name) } log.WithFields(log.Fields{ "path": doData.Source, "location": loca, }).Debug("Exporting results") data.ExportData(doData) if app.AppType.Name == "epm" { files, _ := filepath.Glob(filepath.Join(loca, "*")) for _, f := range files { dest := filepath.Join(do.Path, filepath.Base(f)) log.WithFields(log.Fields{ "from": f, "to": dest, }).Debug("Moving file") common.Copy(f, dest) } } if !do.RmD { log.WithField("dir", filepath.Join(common.DataContainersPath, do.Service.Name)).Debug("Removing data dir on host") os.RemoveAll(filepath.Join(common.DataContainersPath, do.Service.Name)) } if !do.Rm { doRemove := definitions.NowDo() doRemove.Operations.SrvContainerName = do.Operations.DataContainerName log.WithField("=>", doRemove.Operations.SrvContainerName).Debug("Removing data container") if err := perform.DockerRemove(nil, doRemove.Operations, false, true); err != nil { return err } } return nil }
func KillChain(cmd *cobra.Command, args []string) { IfExit(ArgCheck(1, "ge", cmd, args)) do.Name = args[0] IfExit(chns.KillChain(do)) }
func CleanUp(do *definitions.Do, app *definitions.Contracts) error { logger.Infof("Commensing CleanUp.\n") if do.Chain.ChainType == "throwaway" { logger.Debugf("Destroying Throwaway Chain =>\t%s\n", do.Chain.Name) doRm := definitions.NowDo() doRm.Operations = do.Operations doRm.Name = do.Chain.Name doRm.Rm = true doRm.RmD = true chains.KillChain(doRm) logger.Debugf("Removing latent files/dirs =>\t%s:%s\n", path.Join(common.DataContainersPath, do.Chain.Name), path.Join(common.ChainsPath, do.Chain.Name+".toml")) os.RemoveAll(path.Join(common.DataContainersPath, do.Chain.Name)) os.Remove(path.Join(common.ChainsPath, do.Chain.Name+".toml")) } else { logger.Debugf("No Throwaway Chain to destroy.\n") } doData := definitions.NowDo() doData.Name = do.Service.Name doData.Operations = do.Operations doData.Source = common.ErisContainerRoot if do.Path != pwd { doData.Destination = do.Path } else { doData.Destination = filepath.Join(common.DataContainersPath, doData.Name) } var loca string if do.Path != pwd { loca = path.Join(common.DataContainersPath, doData.Name, do.Path) } else { loca = path.Join(common.DataContainersPath, doData.Name, "apps", app.Name) } logger.Debugf("Exporting Results =>\t\t%s:%s\n", doData.Source, loca) data.ExportData(doData) if app.AppType.Name == "epm" { files, _ := filepath.Glob(filepath.Join(loca, "*")) for _, f := range files { dest := filepath.Join(do.Path, filepath.Base(f)) logger.Debugf("Moving file =>\t\t\t%s:%s\n", f, dest) common.Copy(f, dest) } } if !do.RmD { logger.Debugf("Removing data dir on host =>\t%s\n", path.Join(common.DataContainersPath, do.Service.Name)) os.RemoveAll(path.Join(common.DataContainersPath, do.Service.Name)) } if !do.Rm { doRemove := definitions.NowDo() doRemove.Operations.SrvContainerName = do.Operations.DataContainerName logger.Debugf("Removing data contnr =>\t\t%s\n", doRemove.Operations.SrvContainerName) if err := perform.DockerRemove(nil, doRemove.Operations, false, true); err != nil { return err } } return nil }