File: vmx2xmlmock.c

package info (click to toggle)
libvirt 12.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 212,536 kB
  • sloc: ansic: 537,688; xml: 342,012; python: 12,056; perl: 2,626; sh: 2,175; makefile: 448; javascript: 126; cpp: 22
file content (77 lines) | stat: -rw-r--r-- 2,280 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <config.h>

#include "internal.h"
#include "esx_vi.h"

int
esxVI_LookupDatastoreList(esxVI_Context *ctx G_GNUC_UNUSED,
                          esxVI_String *propertyNameList,
                          esxVI_ObjectContent **datastoreList)
{
    esxVI_String *tmp;

    for (tmp = propertyNameList; tmp; tmp = tmp->_next) {
        esxVI_ObjectContent *obj = NULL;
        esxVI_DynamicProperty *prop = NULL;

        if (STRNEQ(tmp->value, "summary.name"))
            continue;

        esxVI_ObjectContent_Alloc(&obj);

        esxVI_DynamicProperty_Alloc(&prop);
        prop->name = g_strdup("summary.name");

        esxVI_AnyType_Alloc(&prop->val);
        prop->val->type = esxVI_Type_String;
        prop->val->other = g_strdup("xsd:string");
        prop->val->value = g_strdup("datastore");
        prop->val->string = prop->val->value;
        esxVI_DynamicProperty_AppendToList(&obj->propSet, prop);

        esxVI_ObjectContent_AppendToList(datastoreList, obj);
    }

    return 0;
}


int
esxVI_LookupDatastoreHostMount(esxVI_Context *ctx G_GNUC_UNUSED,
                               esxVI_ManagedObjectReference *datastore G_GNUC_UNUSED,
                               esxVI_DatastoreHostMount **hostMount,
                               esxVI_Occurrence occurrence G_GNUC_UNUSED)
{
    esxVI_DatastoreHostMount *hm = NULL;

    esxVI_DatastoreHostMount_Alloc(&hm);
    esxVI_HostMountInfo_Alloc(&hm->mountInfo);
    hm->mountInfo->path = g_strdup("/non/existent");
    hm->mountInfo->accessMode = g_strdup("readWrite");
    hm->mountInfo->accessible = esxVI_Boolean_True;

    *hostMount = hm;
    return 0;
}


int
esxVI_LookupDatastoreByName(esxVI_Context *ctx G_GNUC_UNUSED,
                            const char *name,
                            esxVI_String *propertyNameList G_GNUC_UNUSED,
                            esxVI_ObjectContent **datastore,
                            esxVI_Occurrence occurrence G_GNUC_UNUSED)
{
    esxVI_ObjectContent *obj = NULL;

    if (STREQ(name, "missing") || STREQ(name, "ds")) {
        *datastore = NULL;
        return 0;
    }

    /* No need to return anything useful, empty object is fine. */
    esxVI_ObjectContent_Alloc(&obj);
    esxVI_ObjectContent_AppendToList(datastore, obj);

    return 0;
}