summaryrefslogtreecommitdiffabout
path: root/src/lsinst.c
blob: ab2d82fc466f7503efc20d930d3deb1fdf171599 (plain)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/* This file is part of Eclat.
   Copyright (C) 2012-2014 Sergey Poznyakoff.
 
   Eclat is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.
 
   Eclat is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
 
   You should have received a copy of the GNU General Public License
   along with Eclat.  If not, see <http://www.gnu.org/licenses/>. */

#include "eclat.h"

static void
parse_options(struct eclat_command const *cmd, int argc, char *argv[],
	      int *index)
{
	static char *architecture_str[] = { "i386", "x86_64", NULL };
	static char *lifecycle_str[] = { "spot", NULL };
	static char * state_code_str[] = {
		"0 (pending)", "16 (running)", "32 (shutting-down)",
		"48 (terminated)", "64 (stopping)", "80 (stopped)",
		NULL
	};
	static char *state_name_str[] = {
		"pending", "running",
		"shutting-down", "terminated",
		"stopping", "stopped",
		NULL
	};
	static char *state_str[] = { "disabled", "enabled", NULL };
	static char *prod_code_str[] = { "devpay", "marketplace",
					 NULL };
	static char *device_type_str[] = {
		"ebs",
		"instance-store",
		NULL
	};
	static char *virt_type_str[] = { "paravirtual", "hvm", NULL };
	static char *hypervisor_str[] = { "ovm", "xen", NULL };
	static char *iface_status_str[] = { "available", "in-use", NULL };
	static char *iface_att_str[] = {
		"attaching", "attached", "detaching", "detached", NULL
	};
	static struct filter_descr filters[] = {
		{ "architecture",    FILTER_ENUM, architecture_str },
		{ "availability-zone", FILTER_STRING },
		{ "block-device-mapping.attach-time", FILTER_DATE },
		{ "block-device-mapping.delete-on-termination", FILTER_BOOL },
		{ "block-device-mapping.device-name", FILTER_STRING },
		{ "block-device-mapping.status", FILTER_STRING },
		{ "block-device-mapping.volume-id", FILTER_STRING },
		{ "client-token", FILTER_STRING },
		{ "dns-name", FILTER_STRING },
		{ "group-id", FILTER_STRING },
		{ "group-name", FILTER_STRING },
		{ "image-id", FILTER_STRING },
		{ "instance-id", FILTER_STRING },
		{ "instance-lifecycle", FILTER_ENUM, lifecycle_str },
		{ "instance-state-code", FILTER_ENUM, state_code_str },
		{ "instance-state-name", FILTER_ENUM, state_name_str },
		{ "instance-type", FILTER_STRING },
		{ "instance.group-id", FILTER_STRING },
		{ "instance.group-name", FILTER_STRING },
		{ "ip-address", FILTER_STRING },
		{ "kernel-id", FILTER_STRING },
		{ "key-name", FILTER_STRING },
		{ "launch-index", FILTER_STRING },
		{ "launch-time", FILTER_DATE },
		{ "monitoring-state", FILTER_ENUM, state_str },
		{ "owner-id", FILTER_STRING },
		{ "placement-group-name", FILTER_STRING },
		{ "private-dns-name", FILTER_STRING },
		{ "private-ip-address", FILTER_STRING },
		{ "product-code", FILTER_STRING },
		{ "product-code.type", FILTER_ENUM, prod_code_str },
		{ "ramdisk-id", FILTER_STRING },
		{ "reason", FILTER_STRING },
		{ "requester-id", FILTER_STRING },
		{ "reservation-id", FILTER_STRING },
		{ "root-device-name", FILTER_STRING },
		{ "root-device-type", FILTER_ENUM, device_type_str },
		{ "source-dest-check", FILTER_BOOL },
		{ "spot-instance-request-id", FILTER_STRING },
		{ "state-reason-code", FILTER_STRING },
		{ "state-reason-message", FILTER_STRING },
		{ "subnet-id", FILTER_STRING },
		{ "tag-key", FILTER_STRING },
		{ "tag-value", FILTER_STRING },
		{ "tag:<KEY>", FILTER_STRING },
		{ "virtualization-type", FILTER_STRING, virt_type_str },
		{ "vpc-id", FILTER_STRING },
		{ "hypervisor", FILTER_ENUM, hypervisor_str },
		{ "network-interface.description", FILTER_STRING },
		{ "network-interface.subnet-id", FILTER_STRING },
		{ "network-interface.vpc-id", FILTER_STRING },
		{ "network-interface.network-interface.id", FILTER_STRING },
		{ "network-interface.owner-id", FILTER_STRING },
		{ "network-interface.availability-zone", FILTER_STRING },
		{ "network-interface.requester-id", FILTER_STRING },
		{ "network-interface.requester-managed", FILTER_BOOL },
		{ "network-interface.status", FILTER_ENUM, iface_status_str },
		{ "network-interface.mac-address", FILTER_STRING },
		{ "network-interface-private-dns-name", FILTER_STRING },
		{ "network-interface.source-destination-check", FILTER_BOOL },
		{ "network-interface.group-id", FILTER_STRING },
		{ "network-interface.group-name", FILTER_STRING },
		{ "network-interface.attachment.attachment-id", FILTER_STRING },
		{ "network-interface.attachment.instance-id", FILTER_STRING },
		{ "network-interface.attachment.instance-owner-id", FILTER_STRING },
		{ "network-interface.addresses.private-ip-address", FILTER_STRING },
		{ "network-interface.attachment.device-index", FILTER_INT },
		{ "network-interface.attachment.status", FILTER_ENUM,
		  iface_att_str },
		{ "network-interface.attachment.attach-time", FILTER_DATE },
		{ "network-interface.attachment.delete-on-termination",
		  FILTER_BOOL },
		{ "network-interface.addresses.primary", FILTER_BOOL },
		{ "network-interface.addresses.association.public-ip",
		  FILTER_STRING },
		{ "network-interface.addresses.association.ip-owner-id", FILTER_STRING },
		{ "association.public-ip", FILTER_STRING },
		{ "association.ip-owner-id", FILTER_STRING },
		{ "association.allocation-id", FILTER_STRING },
		{ NULL }
	};

	available_filters = filters;
	generic_proginfo->print_help_hook = list_filters;
	return generic_parse_options(cmd,
				     "List instances",
				     argc, argv, index);
}

int
eclat_describe_instances(eclat_command_env_t *env, int argc, char **argv)
{
	int i;
	
	parse_options(env->cmd, argc, argv, &i);
	argv += i;
	argc -= i;
	translate_ids(argc, argv, MAP_INSTANCE);

	describe_query_create(env, argc, argv, "InstanceId");
	return 0;
}

Return to:

Send suggestions and report system problems to the System administrator.