Beispiel #1
0
void system_destroy(arcus_system *sys)
{
    if (!sys)
        return;
    
    if (sys->id)
        free(sys->id);
    if (sys->metric)
        metric_destroy(sys->metric);
    if (sys->cs)
        christoffel_destroy(sys->cs);
    if (sys->range)
        af_destroy_formula(sys->range);
    
    free(sys);
}
Beispiel #2
0
/**
 *  Populates data entry with configuration object attributes
 *
 *  \param oid type of object
 *  \param atts attributes of object
 *  \param superentry master data entry of object
 */
static void mds_populate_configuration_attributes(OID_Type supertype, 
						const char *name,
						const AttributeList *atts,
						DataEntry *superentry)
{
	int j;

	// These objects are here just to satifsy the dimutil_*_fill_attr()
	// functions, that are also used to update actual MDS objects

	struct Metric *metric = metric_instance();
	struct Metric *metric_n = metric_instance();
	struct Metric *metric_e = metric_instance();
	struct Metric *metric_s = metric_instance();
	struct Numeric *numeric = numeric_instance(metric_n);
	struct Enumeration *enumeration = enumeration_instance(metric_e);
	struct PMStore *pmstore = pmstore_instance();

	octet_string simple_sa_obs_value;
	simple_sa_obs_value.length = 64;
	simple_sa_obs_value.value = calloc(64, sizeof(intu8));
	ScaleRangeSpec32 srs32 = {0, 0, 0, 0};
	SaSpec saspec = {0, {0, 0}, 0};
	struct RTSA *sart = rtsa_instance_spec32(metric_s, 1, simple_sa_obs_value,
							srs32, saspec);

	superentry->choice = COMPOUND_DATA_ENTRY;
	superentry->u.compound.entries_count = atts->count;
	superentry->u.compound.entries = calloc(atts->count, sizeof(DataEntry));
	superentry->u.compound.name = data_strcp(name);
		

	for (j = 0; j < atts->count; ++j) {
		AVA_Type att = atts->value[j];
		OID_Type type = att.attribute_id;
		Any data = att.attribute_value;
		ByteStreamReader *r = byte_stream_reader_instance(data.value, data.length);
		DataEntry *entry = &(superentry->u.compound.entries[j]);
		int res = 0;

		if (supertype == MDC_MOC_VMO_METRIC_NU) {
			res = dimutil_fill_numeric_attr(numeric, type, r, entry);
		} else if (supertype == MDC_MOC_VMO_METRIC_ENUM) {
			res = dimutil_fill_enumeration_attr(enumeration, type, r, entry);
		} else if (supertype == MDC_MOC_VMO_METRIC) {
			res = dimutil_fill_metric_attr(metric, type, r, entry);
		} else if (supertype == MDC_MOC_VMO_METRIC_SA_RT) {
			res = dimutil_fill_rtsa_attr(sart, type, r, entry);
		} else if (supertype == MDC_MOC_VMO_PMSTORE) {
			res = dimutil_fill_pmstore_attr(pmstore, type, r, entry);
		}

		if (!res) {
			data_set_oid_type(entry, "OID", &type);
		}

		free(r);
	}

	metric_destroy(metric);
	numeric_destroy(numeric);
	pmstore_destroy(pmstore);
	rtsa_destroy(sart);
	enumeration_destroy(enumeration);

	free(metric);
	free(metric_e);
	free(metric_n);
	free(metric_s);
	free(numeric);
	free(pmstore);
	free(sart);
	free(enumeration);
}