Example #1
0
func DeleteServer(svcId, srvId string) error {
	// in case of failure
	srv, err := database.GetServer(svcId, srvId)
	if err != nil {
		if !strings.Contains(err.Error(), "No Server Found") {
			return err
		}
	}

	// delete rule from balancer
	if err = balance.DeleteServer(svcId, srvId); err != nil {
		if !strings.Contains(err.Error(), "No Server Found") {
			return err
		}
	}

	if !database.CentralStore {
		// remove from backend
		if err = database.DeleteServer(svcId, srvId); err != nil && !strings.Contains(err.Error(), "No Server Found") {
			// undo balance action
			if uerr := balance.SetServer(svcId, srv); uerr != nil {
				err = fmt.Errorf("%v - %v", err.Error(), uerr.Error())
			}
			return err
		}
	}
	return nil
}
Example #2
0
func TestGetServer(t *testing.T) {
	server, err := database.GetServer(testService1.Id, testServer2.Id)
	if err != nil {
		t.Errorf("Failed to GET server - %v", err)
	}

	if server.Id != testServer2.Id {
		t.Errorf("Read server differs from written server")
	}
}
Example #3
0
func GetServer(svcId, srvId string) (*core.Server, error) {
	return database.GetServer(svcId, srvId)
}