Skip to content

Commit

Permalink
Merge pull request #4 from Maxhy/master
Browse files Browse the repository at this point in the history
Fixes to work with Jenkins 2.89.4
  • Loading branch information
justnom authored Mar 1, 2018
2 parents ec0cc34 + 42202b5 commit 15d0cd3
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 96 deletions.
18 changes: 8 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.554.1</version><!-- which version of Jenkins is this plugin built against? -->
<version>3.4</version>
<relativePath />
</parent>

<groupId>io.jenkins.plugins</groupId>
<artifactId>proxmox</artifactId>
<version>0.2.2</version>
<version>0.3.0</version>
<packaging>hpi</packaging>
<properties>
<jenkins.version>2.89.4</jenkins.version>
<java.level>8</java.level>
</properties>
<name>Jenkins Proxmox plugin</name>
<description>This plugin allows Jenkins to use Proxmox virtual machines as slaves.</description>
<url>http://wiki.jenkins-ci.org/display/JENKINS/Proxmox+Plugin</url>
Expand Down Expand Up @@ -59,12 +65,4 @@
<scope>compile</scope>
</dependency>
</dependencies>

<properties>
<!--
explicitly specifying the latest version here because one we get from the parent POM
tends to lag behind a bit
-->
<maven-hpi-plugin.version>1.96</maven-hpi-plugin.version>
</properties>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jenkinsci.plugins.proxmox.pve2api.Connector;
import org.kohsuke.stapler.DataBoundConstructor;
Expand Down Expand Up @@ -112,6 +113,7 @@ public boolean isInstantiable() {

public ListBoxModel doFillDatacenterDescriptionItems() {
ListBoxModel items = new ListBoxModel();
items.add("[Select]", "");
for (Cloud cloud : Hudson.getInstance().clouds) {
if (cloud instanceof Datacenter) {
//TODO: Possibly add the `datacenterDescription` as the `displayName` and `value` (http://javadoc.jenkins-ci.org/hudson/util/ListBoxModel.html)
Expand All @@ -122,30 +124,42 @@ public ListBoxModel doFillDatacenterDescriptionItems() {
return items;
}

//TODO: Possibly replace these with `doFillDatacenterNodeItems` function
public List<String> getDatacenterNodes(String datacenterDescription) {
public ListBoxModel doFillDatacenterNodeItems(@QueryParameter("datacenterDescription") String datacenterDescription) {
ListBoxModel items = new ListBoxModel();
items.add("[Select]", "");
Datacenter datacenter = getDatacenterByDescription(datacenterDescription);
if (datacenter != null) {
return datacenter.getNodes();
for (String node : datacenter.getNodes()) {
items.add(node);
}
}
return new ArrayList<String>();
return items;
}

public HashMap<String, Integer> getQemuVirtualMachines(String datacenterDescription, String datacenterNode) {
public ListBoxModel doFillVirtualMachineIdItems(@QueryParameter("datacenterDescription") String datacenterDescription, @QueryParameter("datacenterNode") String datacenterNode) {
ListBoxModel items = new ListBoxModel();
items.add("[Select]", "");
Datacenter datacenter = getDatacenterByDescription(datacenterDescription);
if (datacenter != null) {
return datacenter.getQemuMachines(datacenterNode);
HashMap<String, Integer> machines = datacenter.getQemuMachines(datacenterNode);
for (Map.Entry me : machines.entrySet()) {
items.add(me.getKey().toString(), me.getValue().toString());
}
}
return new HashMap<String, Integer>();
return items;
}

public List<String> getQemuSnapshotNames(String datacenterDescription, String datacenterNode,
Integer virtualMachineId) {
public ListBoxModel doFillSnapshotNameItems(@QueryParameter("datacenterDescription") String datacenterDescription, @QueryParameter("datacenterNode") String datacenterNode,
@QueryParameter("virtualMachineId") String virtualMachineId) {
ListBoxModel items = new ListBoxModel();
items.add("[Select]", "");
Datacenter datacenter = getDatacenterByDescription(datacenterDescription);
if (datacenter != null) {
return datacenter.getQemuMachineSnapshots(datacenterNode, virtualMachineId);
if (datacenter != null && virtualMachineId != null && virtualMachineId.length() != 0) {
for (String snapshot : datacenter.getQemuMachineSnapshots(datacenterNode, Integer.parseInt(virtualMachineId))) {
items.add(snapshot);
}
}
return new ArrayList<String>();
return items;
}

public String getDatacenterDescription() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private static void ignoreAllCerts() {
TrustManager trm = new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] certs, String authType) {}
public void checkServerTrusted(X509Certificate[] certs, String authType) {}
public X509Certificate[] getAcceptedIssuers() { return null; }
public X509Certificate[] getAcceptedIssuers() { return null; }
};

HostnameVerifier hnv = new HostnameVerifier() {
Expand Down
4 changes: 1 addition & 3 deletions src/main/resources/index.jelly
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<!--
This view is used to render the installed plugins page.
-->
<?jelly escape-by-default='true'?>
<div>
Enables proxmox machines to be used as slaves. Supports reverting from a snapshot
</div>
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">

<f:entry title="${%Hostname}" field="hostname" help="/plugin/proxmox/help-datacenter-hostname.html">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<j:if test="${it.launchSupported and it.offline and !it.temporarilyOffline}">
<j:choose>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,19 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:sel="/lib/form">

<script type="text/javascript">var rootURL='${rootURL}';</script>
<script src="${rootURL}/plugin/proxmox/virtualMachineSlave.js" type="text/javascript" />

<f:entry title="${%Datacenter}" field="datacenterDescription" help="/plugin/proxmox/help-vm-datacenterDescription.html">
<f:select onchange="onChangeListBox('datacenterNode',[['desc',this]])" />
<f:select/>
</f:entry>

<f:entry title="${%Datacenter Node}" field="datacenterNode">
<select class="setting-input select" name="datacenterNode" value="${instance.datacenterNode}" onchange="onChangeListBox('virtualMachineId',[['desc','_.datacenterDescription'],['node',this]])">
<j:forEach var="node" items="${descriptor.getDatacenterNodes(it.datacenterDescription)}" varStatus="loop">
<option selected="${node==it.datacenterNode?'true':null}">
${node}
</option>
</j:forEach>
</select>
<f:select fillDependsOn="datacenterDescription" />
</f:entry>

<f:entry title="${%Virtual Machine}" field="virtualMachineId"> <!--value="${instance.virtualMachineName}" -->
<select class="setting-input select" name="virtualMachineId" onchange="onChangeListBox('snapshotName',[['desc','_.datacenterDescription'],['node','datacenterNode'],['vmid',this]])">
<j:forEach var="vm" items="${descriptor.getQemuVirtualMachines(it.datacenterDescription, it.datacenterNode)}" varStatus="loop">
<option value="${vm.getValue()}" selected="${vm.getValue()==it.virtualMachineId?'true':null}">
${vm.getKey()}
</option>
</j:forEach>
</select>
<f:entry title="${%Virtual Machine}" field="virtualMachineId">
<f:select fillDependsOn="datacenterDescription,datacenterNode" />
</f:entry>

<f:entry title="${%Revert Snapshot}" field="snapshotName" help="/plugin/proxmox/help-vm-snapshotName.html">
<select class="setting-input select" name="snapshotName" value="${instance.snapshotName}">
<j:forEach var="snapshot" items="${descriptor.getQemuSnapshotNames(it.datacenterDescription, it.datacenterNode, it.virtualMachineId)}" varStatus="loop">
<option selected="${snapshot==it.snapshotName?'true':null}">
${snapshot}
</option>
</j:forEach>
</select>
<f:select fillDependsOn="datacenterDescription,datacenterNode,virtualMachineId" />
</f:entry>

<f:validateButton title="${%Test Rollback}" progress="${%Testing...}" method="testRollback"
Expand Down
43 changes: 0 additions & 43 deletions src/main/webapp/virtualMachineSlave.js

This file was deleted.

0 comments on commit 15d0cd3

Please sign in to comment.