Skip to content

Commit

Permalink
add KVM/QEMU plugin
Browse files Browse the repository at this point in the history
version 2018.1.1
  • Loading branch information
lamarios committed Jan 13, 2018
1 parent 29c8fdc commit 9028446
Show file tree
Hide file tree
Showing 33 changed files with 627 additions and 25 deletions.
2 changes: 1 addition & 1 deletion models/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.ftpix.homedash</groupId>
<artifactId>homedash</artifactId>
<version>2017.8.4</version>
<version>2018.1.1</version>
</parent>

<artifactId>models</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion notifications/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>homedash</artifactId>
<groupId>com.ftpix.homedash</groupId>
<version>2017.8.4</version>
<version>2018.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion plugins/couchpotato/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.ftpix.homedash.plugins</groupId>
<artifactId>plugins</artifactId>
<version>2017.8.4</version>
<version>2018.1.1</version>
</parent>

<artifactId>couchpotato</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion plugins/docker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.ftpix.homedash.plugins</groupId>
<artifactId>plugins</artifactId>
<version>2017.8.4</version>
<version>2018.1.1</version>
</parent>

<artifactId>docker</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion plugins/dockercompose/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>plugins</artifactId>
<groupId>com.ftpix.homedash.plugins</groupId>
<version>2017.8.4</version>
<version>2018.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion plugins/dynamicdns/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.ftpix.homedash.plugins</groupId>
<artifactId>plugins</artifactId>
<version>2017.8.4</version>
<version>2018.1.1</version>
</parent>

<artifactId>dynamicdns</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion plugins/googlepubliccalendar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.ftpix.homedash.plugins</groupId>
<artifactId>plugins</artifactId>
<version>2017.8.4</version> </parent>
<version>2018.1.1</version> </parent>

<artifactId>googlepubliccalendar</artifactId>
<name>googlepubliccalendar</name>
Expand Down
2 changes: 1 addition & 1 deletion plugins/harddisk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.ftpix.homedash.plugins</groupId>
<artifactId>plugins</artifactId>
<version>2017.8.4</version>
<version>2018.1.1</version>
</parent>

<artifactId>harddisk</artifactId>
Expand Down
62 changes: 62 additions & 0 deletions plugins/kvm/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>plugins</artifactId>
<groupId>com.ftpix.homedash.plugins</groupId>
<version>2018.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>kvm</artifactId>
<name>kvm</name>

<repositories>
<repository>
<id>libvirt-org</id>
<url>https://libvirt.org/maven2</url>
</repository>
</repositories>


<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<sigar.version>1.6.4</sigar.version>
</properties>
<dependencies>
<dependency>
<groupId>org.libvirt</groupId>
<artifactId>libvirt</artifactId>
<version>0.5.1</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.5.1</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.lesscss</groupId>
<artifactId>lesscss-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>net.tqh.plugins</groupId>
<artifactId>uglifyjs-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
44 changes: 44 additions & 0 deletions plugins/kvm/src/main/java/assets/files/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
87 changes: 87 additions & 0 deletions plugins/kvm/src/main/java/assets/js/kvm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
function kvm(moduleId) {
this.moduleId = moduleId;

this.onConnect = function () {

};

this.documentReady = function (size) {
if (size === 'full-screen') {
var self = this;
$(document).on('click', '.action', function () {
console.log('Uoooo');
self.sendAction($(this).attr('data-domain'), $(this).attr('data-action'));
});
}
};


this.onMessage = function (size, command, message, extra) {
switch (size) {
case '1x1':
this.onMessage_1x1(command, message, extra);
break;
case 'full-screen':
this.onMessage_fullScreen(command, message, extra);
break;
}
}

this.onMessage_1x1 = function (command, message, extra) {
var root = rootElement(this.moduleId);
root.find('.running').html(message);
};

this.onMessage_fullScreen = function (command, message, extra) {
if (command === 'refresh') {
this.refreshVMInfo(message);
} else if (command === 'success') {
this.refreshVMInfo(extra);

}
}

this.refreshVMInfo = function (message) {
var html = '';

message.forEach(function (domain) {
html += '<tr>';
html += '<td>' + domain.name + '</td>';
html += '<td>' + domain.status + '</td>';

var actions = '';
switch (domain.status) {
case 'Paused':
actions += '<button class="action btn btn-sm btn-default" data-domain="' + domain.name + '" data-action="resume"><i class="fa fa-play"/></button>';
actions += '<button class="action btn btn-sm btn-default" data-domain="' + domain.name + '" data-action="force-off"><i class="fa fa-bolt"/> <i class="fa fa-stop"/></button> ';
break;
case 'Running':
actions += '<button class="action btn btn-sm btn-default" data-domain="' + domain.name + '" data-action="pause"><i class="fa fa-pause"/></button> ';
actions += '<button class="action btn btn-sm btn-default" data-domain="' + domain.name + '" data-action="shutdown"><i class="fa fa-stop"/></button> ';
actions += '<button class="action btn btn-sm btn-default" data-domain="' + domain.name + '" data-action="reboot"><i class="fa fa-refresh"/></button> ';
actions += '<button class="action btn btn-sm btn-default" data-domain="' + domain.name + '" data-action="force-off"><i class="fa fa-bolt"/> <i class="fa fa-stop"/></button> ';
actions += '<button class="action btn btn-sm btn-default" data-domain="' + domain.name + '" data-action="force-reset"><i class="fa fa-bolt"/> <i class="fa fa-refresh"/></button> ';
break;
default:
actions += '<button class="action btn btn-sm btn-default" data-domain="' + domain.name + '" data-action="start"><i class="fa fa-play"/></button>';
break;
}

html += '<td>' + actions + '</td>';


html += '</tr>';
});


var root = rootElement(this.moduleId);
root.find('#vms').html(html);

}

this.sendAction = function (domain, action) {
console.log('send action !');
sendMessage(this.moduleId, 'action', JSON.stringify({'domain': domain, 'action': action}));
}

}
29 changes: 29 additions & 0 deletions plugins/kvm/src/main/java/assets/less/kvm.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.kvm.size-1x1{
background-color: #9C27B0;
color:white;

background-image: url("../files/logo.svg");

background-size: cover;


h3{
margin: 2px 2px;
font-size:18px;
}

.running{
text-align: center;
font-size:38px;
}

p{
position:absolute;
left:0;
right:0;
bottom: 2px;
text-align: center;
margin:0;
}

}
3 changes: 3 additions & 0 deletions plugins/kvm/src/main/java/assets/templates/kvm-1x1.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
h3 kvm
.running
p VMs running
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
h2 Virtual Machines
table.table.table-striped
thead
tr
th name
th status
th actions
tbody#vms
7 changes: 7 additions & 0 deletions plugins/kvm/src/main/java/assets/templates/kvm-settings.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.form-group
label(for="url") KVM/Qemu connection string (ex: qemu+ssh://localhost/system)
if settings && settings.containsKey("url")
input.form-control(type="text", id="url", name="url", placeholder="URL", value='#{settings.get("url")}')
else
input.form-control(type="text", id="url", name ="url", placeholder = "URL")

Loading

0 comments on commit 9028446

Please sign in to comment.