summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/Test.java
blob: 56afc7f1806e9e97e3336c8a8f1010f673318955 (plain) (blame)
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
package org.openslx;

import java.util.List;

import org.openslx.dnbd3.DNBD3Client;
import org.openslx.dnbd3.DNBD3Image;
import org.openslx.dnbd3.DNBD3Server;

public class Test {

    public static void main(String[] args) {

        try {
            DNBD3Server server = new DNBD3Server();

            String group = "Test";
            int vid = 10;
            int rid = 1;
            String path = "/image.iso";
            String servers = "132.230.4.29;132.230.4.220;10.1.1.1";
            String cache = "/tmp/image.iso.cache";
            DNBD3Image image = new DNBD3Image(group, vid, rid, path, servers, cache);
            server.addImage(image);

            System.out.println("Exported images (group, atime, vid, rid, path, servers, cache):");
            System.out.println("===============================================================");
            List<DNBD3Image> images = server.getImages();
            for (DNBD3Image i : images) {
                System.out.print(i.getGroup() + "\t");
                System.out.print(i.getAtime() + "\t");
                System.out.print(i.getVid() + "\t");
                System.out.print(i.getRid() + "\t");
                System.out.print(i.getPath() + "\t");
                System.out.print(i.getServers() + "\t");
                System.out.print(i.getCache());
                System.out.println();
            }
            System.out.println();
            System.out.println("Number images: " + images.size());
            System.out.println();

            System.out.println("Connected clients (ip, file)");
            System.out.println("============================");
            List<DNBD3Client> clients = server.getClients();
            for (DNBD3Client client : clients) {
                System.out.print(client.getIp() + "\t");
                System.out.print(client.getImage());
                System.out.println();
            }
            System.out.println();
            System.out.println("Number clients: " + clients.size());
            System.out.println();

            // server.doReload();
            // server.doShutdown();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}