Exemplo n.º 1
0
//update outputs in riak, nuke the matching keys available
func (a *Ambly) NukeAndSetOutputs(m map[string][]string) error {

	if len(m) > 0 {
		log.Debugf("nuke and set outputs in riak [%s]", m)
		js := a.getOutputs()
		js.NukeAndSet(m) //just nuke the matching output key:
		update_fields := make(map[string]interface{})
		update_fields["Outputs"] = js.ToString()
		ops := ldb.Options{
			TableName:   ASSEMBLYBUCKET,
			Pks:         []string{"id"},
			Ccms:        []string{"org_id"},
			Hosts:       meta.MC.Scylla,
			Keyspace:    meta.MC.ScyllaKeyspace,
			Username:    meta.MC.ScyllaUsername,
			Password:    meta.MC.ScyllaPassword,
			PksClauses:  map[string]interface{}{"id": a.Id},
			CcmsClauses: map[string]interface{}{"org_id": a.OrgId},
		}

		if err := ldb.Updatedb(ops, update_fields); err != nil {
			return err
		}
	} else {
		return provision.ErrNoOutputsFound
	}
	return nil
}
Exemplo n.º 2
0
func (a *Ambly) NukeKeysInputs(m string) error {
	if len(m) > 0 {
		log.Debugf("nuke keys from inputs in cassandra [%s]", m)
		js := a.getInputs()
		js.NukeKeys(m) //just nuke the matching output key:
		update_fields := make(map[string]interface{})
		update_fields["Inputs"] = js.ToString()
		ops := ldb.Options{
			TableName:   ASSEMBLYBUCKET,
			Pks:         []string{"id"},
			Ccms:        []string{"org_id"},
			Hosts:       meta.MC.Scylla,
			Keyspace:    meta.MC.ScyllaKeyspace,
			Username:    meta.MC.ScyllaUsername,
			Password:    meta.MC.ScyllaPassword,
			PksClauses:  map[string]interface{}{"id": a.Id},
			CcmsClauses: map[string]interface{}{"org_id": a.OrgId},
		}

		if err := ldb.Updatedb(ops, update_fields); err != nil {
			return err
		}
	}
	return nil
}
Exemplo n.º 3
0
func (a *Ambly) SetStatus(status utils.Status) error {
	js := a.getInputs()
	LastStatusUpdate := time.Now().Local().Format(time.RFC822)
	m := make(map[string][]string, 2)
	m["lastsuccessstatusupdate"] = []string{LastStatusUpdate}
	m["status"] = []string{status.String()}
	js.NukeAndSet(m) //just nuke the matching output key:
	a.Status = status.String()

	update_fields := make(map[string]interface{})
	update_fields["inputs"] = js.ToString()
	update_fields["status"] = status.String()
	ops := ldb.Options{
		TableName:   ASSEMBLYBUCKET,
		Pks:         []string{"id"},
		Ccms:        []string{"org_id"},
		Hosts:       meta.MC.Scylla,
		Keyspace:    meta.MC.ScyllaKeyspace,
		Username:    meta.MC.ScyllaPassword,
		Password:    meta.MC.ScyllaPassword,
		PksClauses:  map[string]interface{}{"id": a.Id},
		CcmsClauses: map[string]interface{}{"org_id": a.OrgId},
	}
	if err := ldb.Updatedb(ops, update_fields); err != nil {
		return err
	}

	_ = eventNotify(status)
	return nil
}
Exemplo n.º 4
0
func (c *Component) SetStatus(status utils.Status) error {
	LastStatusUpdate := time.Now().Local().Format(time.RFC822)
	m := make(map[string][]string, 2)
	m["lastsuccessstatusupdate"] = []string{LastStatusUpdate}
	m["status"] = []string{status.String()}
	c.Inputs.NukeAndSet(m) //just nuke the matching output key:

	update_fields := make(map[string]interface{})
	update_fields["Inputs"] = c.Inputs.ToString()
	update_fields["Status"] = status.String()
	ops := ldb.Options{
		TableName:   COMPBUCKET,
		Pks:         []string{"Id"},
		Ccms:        []string{},
		Hosts:       meta.MC.Scylla,
		Keyspace:    meta.MC.ScyllaKeyspace,
		PksClauses:  map[string]interface{}{"Id": c.Id},
		CcmsClauses: make(map[string]interface{}),
	}
	if err := ldb.Updatedb(ops, update_fields); err != nil {
		return err
	}
	_ = eventNotify(status)
	return nil
}
Exemplo n.º 5
0
func (c *Component) UpdateOpsRun(opsRan upgrade.OperationsRan) error {
	mutatedOps := make([]*upgrade.Operation, 0, len(opsRan))

	for _, o := range opsRan {
		mutatedOps = append(mutatedOps, o.Raw)
	}

	update_fields := make(map[string]interface{})
	update_fields["Operations"] = mutatedOps
	ops := ldb.Options{
		TableName:   COMPBUCKET,
		Pks:         []string{"Id"},
		Ccms:        []string{},
		Hosts:       meta.MC.Scylla,
		Keyspace:    meta.MC.ScyllaKeyspace,
		Username:    meta.MC.ScyllaUsername,
		Password:    meta.MC.ScyllaPassword,
		PksClauses:  map[string]interface{}{"Id": c.Id},
		CcmsClauses: make(map[string]interface{}),
	}
	if err := ldb.Updatedb(ops, update_fields); err != nil {
		return err
	}

	return nil
}
Exemplo n.º 6
0
func (a *Ambly) SetState(state utils.State) error {
	update_fields := make(map[string]interface{})
	update_fields["state"] = state.String()
	ops := ldb.Options{
		TableName:   ASSEMBLYBUCKET,
		Pks:         []string{"id"},
		Ccms:        []string{"org_id"},
		Hosts:       meta.MC.Scylla,
		Keyspace:    meta.MC.ScyllaKeyspace,
		Username:    meta.MC.ScyllaUsername,
		Password:    meta.MC.ScyllaPassword,
		PksClauses:  map[string]interface{}{"id": a.Id},
		CcmsClauses: map[string]interface{}{"org_id": a.OrgId},
	}
	if err := ldb.Updatedb(ops, update_fields); err != nil {
		return err
	}
	return nil
}
Exemplo n.º 7
0
func (c *Component) SetState(state utils.State) error {
	update_fields := make(map[string]interface{})
	update_fields["State"] = state.String()
	ops := ldb.Options{
		TableName:   COMPBUCKET,
		Pks:         []string{"Id"},
		Ccms:        []string{},
		Hosts:       meta.MC.Scylla,
		Keyspace:    meta.MC.ScyllaKeyspace,
		Username:    meta.MC.ScyllaUsername,
		Password:    meta.MC.ScyllaPassword,
		PksClauses:  map[string]interface{}{"Id": c.Id},
		CcmsClauses: make(map[string]interface{}),
	}
	if err := ldb.Updatedb(ops, update_fields); err != nil {
		return err
	}
	return nil
}