-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlxc-obj-defs.c
65 lines (51 loc) · 3.26 KB
/
lxc-obj-defs.c
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
#include "lxc-obj-defs.h"
static void AddLxcAgentResources(AwaObjectDefinition *objectDefinition)
{
AwaObjectDefinition_AddResourceDefinitionAsString(objectDefinition, atoi(LXCA_RESID_NAME), "Name", true, AwaResourceOperations_ReadOnly, "LXC Agent");
AwaObjectDefinition_AddResourceDefinitionAsNoType(objectDefinition, atoi(LXCA_RESID_CREATE), "Create", true, AwaResourceOperations_Execute);
AwaObjectDefinition_AddResourceDefinitionAsString(objectDefinition, atoi(LXCA_RESID_APPID), "AppID", true, AwaResourceOperations_ReadWrite, NULL);
}
static void AddLxcResources(AwaObjectDefinition *objectDefinition)
{
AwaObjectDefinition_AddResourceDefinitionAsString(objectDefinition, atoi(LXC_RESID_NAME), "Name", true, AwaResourceOperations_ReadOnly, LXC_DEFAULT_NAME);
AwaObjectDefinition_AddResourceDefinitionAsNoType(objectDefinition, atoi(LXC_RESID_START), "Start", true, AwaResourceOperations_Execute);
AwaObjectDefinition_AddResourceDefinitionAsNoType(objectDefinition, atoi(LXC_RESID_STOP), "Stop", true, AwaResourceOperations_Execute);
AwaObjectDefinition_AddResourceDefinitionAsNoType(objectDefinition, atoi(LXC_RESID_DESTROY), "Stop", true, AwaResourceOperations_Execute);
AwaObjectDefinition_AddResourceDefinitionAsString(objectDefinition, atoi(LXC_RESID_STATUS), "Status", true, AwaResourceOperations_ReadOnly, "UNKNOWN");
}
void DefineLxcAgentClientObject(AwaClientSession * session)
{
AwaObjectDefinition * objectDefinition = AwaObjectDefinition_New(atoi(LXC_AGENT_OBJID), "LXCD", 1, 1);
AddLxcAgentResources(objectDefinition);
AwaClientDefineOperation * operation = AwaClientDefineOperation_New(session);
AwaClientDefineOperation_Add(operation, objectDefinition);
AwaClientDefineOperation_Perform(operation, OPERATION_PERFORM_TIMEOUT);
AwaClientDefineOperation_Free(&operation);
}
void DefineLxcClientObject(AwaClientSession * session)
{
AwaObjectDefinition * objectDefinition = AwaObjectDefinition_New(atoi(LXC_OBJID), "Container", 0, LXC_MAX_INSTANCES);
AddLxcResources(objectDefinition);
AwaClientDefineOperation * operation = AwaClientDefineOperation_New(session);
AwaClientDefineOperation_Add(operation, objectDefinition);
AwaClientDefineOperation_Perform(operation, OPERATION_PERFORM_TIMEOUT);
AwaClientDefineOperation_Free(&operation);
}
void DefineLxcAgentServerObject(AwaServerSession * session)
{
AwaObjectDefinition * objectDefinition = AwaObjectDefinition_New(atoi(LXC_AGENT_OBJID), "LXCD", 1, 1);
AddLxcAgentResources(objectDefinition);
AwaServerDefineOperation * operation = AwaServerDefineOperation_New(session);
AwaServerDefineOperation_Add(operation, objectDefinition);
AwaServerDefineOperation_Perform(operation, OPERATION_PERFORM_TIMEOUT);
AwaServerDefineOperation_Free(&operation);
}
void DefineLxcServerObject(AwaServerSession * session)
{
AwaObjectDefinition * objectDefinition = AwaObjectDefinition_New(atoi(LXC_OBJID), "Container", 0, LXC_MAX_INSTANCES);
AddLxcResources(objectDefinition);
AwaServerDefineOperation * operation = AwaServerDefineOperation_New(session);
AwaServerDefineOperation_Add(operation, objectDefinition);
AwaServerDefineOperation_Perform(operation, OPERATION_PERFORM_TIMEOUT);
AwaServerDefineOperation_Free(&operation);
}