-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinfrakit-instance-oneview.c
79 lines (70 loc) · 2.41 KB
/
infrakit-instance-oneview.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// infrakit-instance-oneview.c
/* instance-infrakit-oneview - A Docker InfraKit plugin for HPE OneView
*
* Dan Finneran <finneran@hpe.com>
*
* (c) Copyright [2017] Hewlett Packard Enterprise Development LP;
*
* This software may be modified and distributed under the terms
* of the Apache 2.0 license. See the LICENSE file for details.
*/
#include "oneviewInfraKitPlugin.h"
#include "oneviewInfraKitState.h"
#include "oneviewInfraKitConsole.h"
#include <getopt.h>
#include <stdio.h>
static struct option long_options[] =
{
{"name", required_argument, NULL, 'n'},
{"state", required_argument, NULL, 's'},
{"log", required_argument, NULL, 'l'},
{"help", optional_argument, NULL, 'h'},
{NULL, 0, NULL, 0}
};
int main(int argc, char* argv[])
{
int ch;
int logLevel = 4;
char *statepath, *socketName;
if (argc >= 2) {
if (stringMatch("version", argv[1])) {
printf("\nHPE OneView Instance Plugin version 0.3.0\nContact: finneran@hpe.com\n\n");
return 0;
}
}
while ((ch = getopt_long(argc, argv, "n:s:l:h:", long_options, NULL)) != -1)
{
// check to see if a single character or long option came through
switch (ch)
{
// short option 't'
case 'n':
socketName = optarg;
if (socketName) {
setSocketName(socketName);
}
break;
// short option 'a'
case 's':
statepath = optarg;
if (statepath) {
setArgStatePath(statepath);
}
break;
case 'l':
logLevel = atoi(optarg);
if (logLevel < 6) {
setConsolOutputLevel(logLevel);
} else {
printf("\nError incorrect log level, maximum 5");
}
break;
case 'h':
printf("HPE OneView Instance Plugin for Docker\n\n Usage:\n ./infrakit-instance-oneview [flags]\n\n Available Commands:\n version\t\t print build version information\n\n Flags:\n\t--name\tPlugin name to advertise\n\t--log\tLogging level, maximum 5 being the most verbose\n\t--state\tPath to a state file to handle instance state information\n\n");
return 0;
break;
}
}
ovCreateInfraKitInstance();
return 0;
}