summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/dnbd3/Test.java
blob: 35ec2a73d5e45b70e84baa345040c85c609a5c94 (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
package org.openslx.dnbd3;

import java.util.List;

import org.openslx.dnbd3.xml.Client;
import org.openslx.dnbd3.xml.Image;

public class Test {

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

        try {
            DNBD3Server server = new DNBD3Server();
            
            String group = "Test 11.11";
            int vid = 10;
            int rid = 1;
            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";
            String cache = "/tmp/image.iso.cache";
            Image image = new Image(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<Image> images = server.getImages();
            for (Image 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.getFile() + "\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<Client> clients = server.getClients();
            for (Client client : clients) {
                System.out.print(client.getIp() + "\t");
                System.out.print(client.getFile());
                System.out.println();
            }
            System.out.println();
            System.out.println("Number clients: " + clients.size());
            System.out.println();

            server.delImage(new Image("", vid, rid, "", ""));
            
            // server.doReload();
            // server.doShutdown();

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

        }
    }

}