mirror of
https://github.com/Fishwaldo/rundeck-ovirt.git
synced 2025-03-15 19:41:34 +00:00
update to new ovirtSDK and fix NPE when evaluating VM status
This commit is contained in:
parent
e13ee6bc98
commit
fc1bede582
7 changed files with 53 additions and 7 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@
|
|||
*.iml
|
||||
*.iws
|
||||
build/
|
||||
/bin/
|
||||
|
|
6
.project
6
.project
|
@ -15,9 +15,15 @@
|
|||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
|
@ -23,6 +23,11 @@ configurations{
|
|||
extendsFrom pluginLibs
|
||||
}
|
||||
}
|
||||
compileJava {
|
||||
options.encoding = 'UTF-8'
|
||||
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
|
@ -43,7 +48,7 @@ dependencies {
|
|||
pluginLibs group: 'stax', name: 'stax', version: '1.2.0'
|
||||
pluginLibs group: 'stax-api', name: 'stax-api', version: '1.0.1'
|
||||
|
||||
pluginLibs group: 'org.ovirt.engine.sdk', name: 'ovirt-engine-sdk-java', version: '3.5.1.0'
|
||||
pluginLibs group: 'org.ovirt.engine.sdk', name: 'ovirt-engine-sdk-java', version: '3.6.10.0'
|
||||
pluginLibs group: 'commons-httpclient', name: 'commons-httpclient', version: '3.0-rc3'
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
version=1.0-SNAPSHOT
|
||||
version=1.1
|
||||
|
|
|
@ -28,6 +28,8 @@ import com.dtolabs.rundeck.core.common.INodeSet;
|
|||
import com.dtolabs.rundeck.core.common.NodeEntryImpl;
|
||||
import com.dtolabs.rundeck.core.common.NodeSetImpl;
|
||||
|
||||
import ac.dynam.rundeck.plugin.resources.ovirt.oVirtSDKWrapper;
|
||||
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
@ -74,9 +76,12 @@ class InstanceToNodeMapper {
|
|||
private void mapInstances(final NodeSetImpl nodeSet, final List<VM> instances) {
|
||||
for (final VM inst : instances) {
|
||||
logger.debug(this.runningStateOnly + inst.getStatus().getState());
|
||||
if (this.runningStateOnly == true) {
|
||||
if (!inst.getStatus().getState().equals("up"))
|
||||
if (this.runningStateOnly == true) {
|
||||
String status = inst.getStatus().getState();
|
||||
if (status != null && !status.equals("up"))
|
||||
continue;
|
||||
if (status == null)
|
||||
logger.warn("VM Status is Undefined: " + inst.getName());
|
||||
}
|
||||
logger.debug(inst.getName());
|
||||
final INodeEntry iNodeEntry;
|
||||
|
@ -199,6 +204,11 @@ class InstanceToNodeMapper {
|
|||
}
|
||||
|
||||
public static class GeneratorException extends Exception {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6384545528587691313L;
|
||||
|
||||
public GeneratorException() {
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ import java.util.*;
|
|||
@Plugin(name = "ovirt-source", service = "ResourceModelSource")
|
||||
public class oVirtResourceModelSourceFactory implements ResourceModelSourceFactory, Describable {
|
||||
public static final String PROVIDER_NAME = "ovirt-source";
|
||||
private Framework framework;
|
||||
|
||||
public static final String RUNNING_ONLY = "runningOnly";
|
||||
public static final String OVIRT_URL = "ovirtURL";
|
||||
|
@ -38,7 +37,6 @@ public class oVirtResourceModelSourceFactory implements ResourceModelSourceFacto
|
|||
public static final String REFRESH_INTERVAL = "refreshInterval";
|
||||
|
||||
public oVirtResourceModelSourceFactory(final Framework framework) {
|
||||
this.framework = framework;
|
||||
}
|
||||
|
||||
public ResourceModelSource createResourceModelSource(final Properties properties) throws ConfigurationException {
|
||||
|
|
|
@ -1,3 +1,21 @@
|
|||
/*
|
||||
* Copyright 2014 Dynamx (Singapore) Pte Ltd
|
||||
*
|
||||
* Based on the RunDeck EC2 Plugin
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package ac.dynam.rundeck.plugin.resources.ovirt;
|
||||
|
||||
|
||||
|
@ -7,6 +25,7 @@ import java.util.UUID;
|
|||
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.ovirt.engine.sdk.Api;
|
||||
import org.ovirt.engine.sdk.ApiBuilder;
|
||||
import org.ovirt.engine.sdk.decorators.VM;
|
||||
import org.ovirt.engine.sdk.entities.Action;
|
||||
import org.ovirt.engine.sdk.exceptions.ServerException;
|
||||
|
@ -19,7 +38,14 @@ public class oVirtSDKWrapper {
|
|||
public void login(String baseUrl, String userName, String password) {
|
||||
try {
|
||||
// true for filter, ie enable regular users to login
|
||||
this.api = new Api(baseUrl, userName, password, true);
|
||||
// this.api = new Api(baseUrl, userName, password, true);
|
||||
this.api = new ApiBuilder()
|
||||
.url(baseUrl)
|
||||
.user(userName)
|
||||
.password(password)
|
||||
.debug(true)
|
||||
.noHostVerification(false)
|
||||
.build();
|
||||
} catch (ClientProtocolException e) {
|
||||
this.message = "Protocol Exception: " + e.getMessage();
|
||||
} catch (ServerException e) {
|
||||
|
|
Loading…
Add table
Reference in a new issue