summaryrefslogtreecommitdiff
path: root/testprogs/ejs/ejsnet/nethost.js
blob: 9e11ae89c5e0ff4a27af499ca1e6426cfce45bd8 (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
function PrintNetHostHelp()
{
	println("Host management - available commands:");
	println("\t domainlist - list users in specified domain");
}


function ListDomains(hostCtx)
{
	var domain;

	var list = hostCtx.DomainList();
	if (list == undefined) {
		println("Error when listing domains");
		return -1;
	}

	for (var i = 0; i < list.Count; i++) {
		domain = list.Domains[i];
		printf("%s\n", domain.Name);
	}

	printf("\nResult: %s\n", list.Status.errstr);
}


function HostManager(ctx, options)
{
	var hostCtx;

	if (options.ARGV.length < 2) {
		PrintNetHostHelp();
		return -1;
	}

	var hostCmd = options.ARGV[1];

	if (hostCmd == "domainlist") {
		hostCtx = ctx.HostMgr();
		ListDomains(hostCtx);

	} else {
		println("unknown command");
	}
}