Example #1
0
func PlopChain(do *definitions.Do) error {
	do.Name = do.ChainID
	rootDir := path.Join("/home/eris/.eris/blockchains", do.ChainID)
	switch do.Type {
	case "genesis":
		do.Args = []string{"cat", path.Join(rootDir, "genesis.json")}
	case "config":
		do.Args = []string{"cat", path.Join(rootDir, "config.toml")}
	case "status":
		do.Args = []string{"mintinfo", "--node-addr", "http://0.0.0.0:46657", "status"}
	default:
		return fmt.Errorf("unknown plop option %s", do.Type)
	}
	return ExecChain(do)
}
Example #2
0
// TODO: skip errors flag
func RmData(do *definitions.Do) (err error) {
	if len(do.Args) == 0 {
		do.Args = []string{do.Name}
	}
	for _, name := range do.Args {
		do.Name = name
		if util.IsDataContainer(do.Name, do.Operations.ContainerNumber) {
			logger.Infoln("Removing data container " + do.Name)

			srv := definitions.BlankServiceDefinition()
			srv.Operations.SrvContainerName = util.ContainersName("data", do.Name, do.Operations.ContainerNumber)

			if err = perform.DockerRemove(srv.Service, srv.Operations, false); err != nil {
				logger.Errorf("Error removing %s: %v", do.Name, err)
				return err
			}

		} else {
			err = fmt.Errorf("I cannot find that data container for %s. Please check the data container name you sent me.", do.Name)
			logger.Errorln(err)
			return err
		}

		if do.RmHF {
			logger.Println("Removing host folder " + do.Name)
			if err = os.RemoveAll(path.Join(DataContainersPath, do.Name)); err != nil {
				return err
			}
		}
	}

	do.Result = "success"
	return err
}
Example #3
0
func StartService(do *definitions.Do) (err error) {
	var services []*definitions.ServiceDefinition

	cNum := do.Operations.ContainerNumber
	if err != nil {
		return err
	}
	do.Args = append(do.Args, do.ServicesSlice...)
	logger.Debugf("Building the Services Group =>\t%v\n", do.Args)
	for _, srv := range do.Args {
		// this forces CLI/Agent level overwrites of the Operations.
		// if this needs to get reversed, we should discuss on GH.
		s, e := BuildServicesGroup(srv, cNum)
		if e != nil {
			return e
		}
		services = append(services, s...)
	}
	for _, s := range services {
		//XXX does AutoMagic elim need for this?
		util.OverWriteOperations(s.Operations, do.Operations)
	}

	services, err = BuildChainGroup(do.ChainName, services)
	if err != nil {
		return err
	}

	// TODO: move this wg, ch logic into func StartGroup([]*definitions.ServiceDefinition) error {}
	wg, ch := new(sync.WaitGroup), make(chan error)
	StartGroup(ch, wg, services)
	go func() {
		wg.Wait()
		select {
		case ch <- nil:
		}
	}()
	if err := <-ch; err != nil {
		return err
	}

	return nil
}
Example #4
0
func StartService(do *definitions.Do) (err error) {
	var services []*definitions.ServiceDefinition

	cNum := do.Operations.ContainerNumber
	do.Args = append(do.Args, do.ServicesSlice...)
	logger.Infof("Building the Services Group =>\t%v\n", do.Args)
	for _, srv := range do.Args {
		s, e := BuildServicesGroup(srv, cNum)
		if e != nil {
			return e
		}
		services = append(services, s...)
	}
	for _, s := range services {
		// XXX does AutoMagic elim need for this?
		// [csk]: not totally we may need to have ops reconciliation, overwrite will, e.g., merge the maps and stuff
		util.OverWriteOperations(s.Operations, do.Operations)
	}

	logger.Debugln("services before build chain")
	for _, s := range services {
		logger.Debugln("\t", s.Name, s.Dependencies, s.Service.Links, s.Service.VolumesFrom)
	}
	services, err = BuildChainGroup(do.ChainName, services)
	if err != nil {
		return err
	}
	logger.Debugln("services after build chain")
	for _, s := range services {
		logger.Debugln("\t", s.Name, s.Dependencies, s.Service.Links, s.Service.VolumesFrom)
	}

	// NOTE: the top level service should be at the end of the list
	topService := services[len(services)-1]
	topService.Service.Environment = append(topService.Service.Environment, do.Env...)
	topService.Service.Links = append(topService.Service.Links, do.Links...)
	services[len(services)-1] = topService

	logger.Infof("Starting Services Group.\n")
	return StartGroup(services)
}
Example #5
0
func ListKnown(do *definitions.Do) error {
	do.Args = util.DataContainerNames()
	do.Result = strings.Join(do.Args, "\n")
	return nil
}