Beispiel #1
0
func SaveDestination(dest *Destination) error {

	exist, err := DoesDestinationExist(dest.LocalPort)
	if err != nil {
		return err
	}
	if exist {
		return fmt.Errorf("Destination with port %q already exist.", dest.LocalPort)
	}

	_, err = db.InsertRow(destTable, *dest)
	if err != nil {
		return err
	}

	return nil
}
Beispiel #2
0
func Save(node *Node) error {

	exist, err := DoesNodeExist(node.Name)
	if err != nil {
		return err
	}
	if exist {
		return fmt.Errorf("Node with name %q already exist.", node.Name)
	}

	keys, err := db.InsertRow(nodeTable, *node)
	if err != nil {
		return err
	}

	if len(keys) >= 1 {
		node.Id = keys[0]
		return nil
	}

	return fmt.Errorf("No ID was generated.")
}