Exemplo n.º 1
0
func restoreTenant() error {
	strList, err := modeldb.ReadAllObj("tenant")
	if err != nil {
		log.Errorf("Error reading tenant list. Err: %v", err)
	}

	for _, objStr := range strList {
		// Parse the json model
		var tenant Tenant
		err = json.Unmarshal([]byte(objStr), &tenant)
		if err != nil {
			log.Errorf("Error parsing object %s, Err %v", objStr, err)
			return err
		}

		// add it to the collection
		collections.tenants[tenant.Key] = &tenant
	}

	return nil
}
Exemplo n.º 2
0
func restoreNetwork() error {
	strList, err := modeldb.ReadAllObj("network")
	if err != nil {
		log.Errorf("Error reading network list. Err: %v", err)
	}

	for _, objStr := range strList {
		// Parse the json model
		var network Network
		err = json.Unmarshal([]byte(objStr), &network)
		if err != nil {
			log.Errorf("Error parsing object %s, Err %v", objStr, err)
			return err
		}

		// add it to the collection
		collections.networks[network.Key] = &network
	}

	return nil
}