Example #1
0
func initializeStorageNode(node string, t *task.Task) error {
	sProfiles, err := skyring.GetDbProvider().StorageProfileInterface().StorageProfiles(nil, models.QueryOps{})
	if err != nil {
		logger.Get().Error("Unable to get the storage profiles. May not be able to apply storage profiles for node: %v err:%v", node, err)
	}
	if storage_node, ok := saltnodemanager.GetStorageNodeInstance(node, sProfiles); ok {
		if err := updateStorageNodeToDB(*storage_node); err != nil {
			logger.Get().Error("Unable to add details of node: %s to DB. error: %v", node, err)
			t.UpdateStatus("Unable to add details of node: %s to DB. error: %v", node, err)
			updateNodeState(node, models.NODE_STATE_FAILED)
			return err
		}
		if nodeErrorMap, configureError := skyring.GetCoreNodeManager().SetUpMonitoring(node, curr_hostname); configureError != nil && len(nodeErrorMap) != 0 {
			if len(nodeErrorMap) != 0 {
				logger.Get().Error("Unable to setup collectd on %s because of %v", node, nodeErrorMap)
				t.UpdateStatus("Unable to setup collectd on %s because of %v", node, nodeErrorMap)
				updateNodeState(node, models.NODE_STATE_FAILED)
				return err
			} else {
				logger.Get().Error("Config Error during monitoring setup for node:%s Error:%v", node, configureError)
				t.UpdateStatus("Config Error during monitoring setup for node:%s Error:%v", node, configureError)
				updateNodeState(node, models.NODE_STATE_FAILED)
				return err
			}
		}
		return nil
	} else {
		logger.Get().Critical("Error getting the details for node: %s", node)
		t.UpdateStatus("Error getting the details for node: %s", node)
		updateNodeState(node, models.NODE_STATE_FAILED)
		return fmt.Errorf("Error getting the details for node: %s", node)
	}
}
Example #2
0
func acceptNode(w http.ResponseWriter, hostname string, fingerprint string, t *task.Task) error {
	if _, err := GetCoreNodeManager().AcceptNode(hostname, fingerprint); err == nil {
		t.UpdateStatus("Adding the node to DB: %s", hostname)
		if err = AddStorageNodeToDB(hostname, models.NODE_STATE_INITIALIZING, models.STATUS_UP); err != nil {
			logger.Get().Error("Unable to add the node:%s to DB. error: %v", hostname, err)
			t.UpdateStatus("Unable to add the node:%s to DB. error: %v", hostname, err)
			return err
		}
	} else {
		logger.Get().Critical("Accepting the node: %s failed. error: %v", hostname, err)
		t.UpdateStatus("Accepting the node: %s failed. error: %v", hostname, err)
		return err
	}
	return nil
}
Example #3
0
func addAndAcceptNode(w http.ResponseWriter, request models.AddStorageNodeRequest, t *task.Task) error {
	t.UpdateStatus("Bootstrapping the node")
	// Add the node
	if _, err := GetCoreNodeManager().AddNode(
		curr_hostname,
		request.Hostname,
		uint(request.SshPort),
		request.SshFingerprint,
		request.User,
		request.Password); err == nil {
		t.UpdateStatus("Adding the node to DB: %s", request.Hostname)
		if err = AddStorageNodeToDB(request.Hostname, models.NODE_STATE_INITIALIZING, models.STATUS_UP); err != nil {
			logger.Get().Error("Unable to add the node:%s to DB. error: %v", request.Hostname, err)
			t.UpdateStatus("Unable to add the node:%s to DB. error: %v", request.Hostname, err)
			return err
		}

	} else {
		logger.Get().Critical("Bootstrapping the node: %s failed. error: %v: ", request.Hostname, err)
		t.UpdateStatus("Bootstrapping the node: %s failed. error: %v: ", request.Hostname, err)
		return err
	}
	return nil
}
Example #4
0
func FailTask(msg string, err error, t *task.Task) {
	logger.Get().Error("%s: %v", msg, err)
	t.UpdateStatus("Failed. error: %v", err)
	t.Done(models.TASK_STATUS_FAILURE)
}