summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/Test.java
blob: 111e9f298506ff897af3077d3e6a844fe6cdb037 (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
62
63
64
65
66
package org.openslx;

import java.io.IOException;
import java.util.List;

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

public class Test {

    public static void main(String[] args) throws IOException {

        try {
            DNBD3Server server = new DNBD3Server();

            String group = "Test";
            int vid = 10;
            int rid = 0;
            String path = "/home/jjl/Data/ISOs/Ubuntu/ubuntu-10.04.3-desktop-i386.iso";
            String servers = "132.230.4.29;132.230.4.220;10.1.1.1;10.1.1.2";
            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.doShutdown();
            // server.doReload();

        } catch (DNBD3Exception e) {
            System.out.println(e);

        }
    }

}