-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
428 additions
and
1 deletion.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...s/Java/swis-client/src/main/java/com/solarwinds/orionsdk/discovery/CorePluginContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.solarwinds.orionsdk.discovery; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class CorePluginContext { | ||
private final List<IpAddress> bulkList = new ArrayList<IpAddress>(); | ||
private final List<Credential> credentials = new ArrayList<Credential>(); | ||
private int wmiRetriesCount = 0; | ||
private int wmiRetryIntervalMiliseconds = 1000; | ||
|
||
public int getWmiRetriesCount() { | ||
return wmiRetriesCount; | ||
} | ||
|
||
public void setWmiRetriesCount(int wmiRetriesCount) { | ||
this.wmiRetriesCount = wmiRetriesCount; | ||
} | ||
|
||
public int getWmiRetryIntervalMiliseconds() { | ||
return wmiRetryIntervalMiliseconds; | ||
} | ||
|
||
public void setWmiRetryIntervalMiliseconds(int wmiRetryIntervalMiliseconds) { | ||
this.wmiRetryIntervalMiliseconds = wmiRetryIntervalMiliseconds; | ||
} | ||
|
||
public List<Credential> getCredentials() { | ||
return credentials; | ||
} | ||
|
||
public List<IpAddress> getBulkList() { | ||
return bulkList; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
Samples/Java/swis-client/src/main/java/com/solarwinds/orionsdk/discovery/Credential.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.solarwinds.orionsdk.discovery; | ||
|
||
public class Credential { | ||
private int credentialId; | ||
private int order; | ||
|
||
public Credential(int credentialId, int order) { | ||
setCredentialId(credentialId); | ||
setOrder(order); | ||
} | ||
|
||
public int getCredentialId() { | ||
return credentialId; | ||
} | ||
|
||
public void setCredentialId(int credentialId) { | ||
this.credentialId = credentialId; | ||
} | ||
|
||
public int getOrder() { | ||
return order; | ||
} | ||
|
||
public void setOrder(int order) { | ||
this.order = order; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...es/Java/swis-client/src/main/java/com/solarwinds/orionsdk/discovery/DiscoveredObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.solarwinds.orionsdk.discovery; | ||
|
||
public class DiscoveredObject { | ||
private String entityType; | ||
private String displayName; | ||
private String netObjectId; | ||
|
||
public String getEntityType() { | ||
return entityType; | ||
} | ||
|
||
public void setEntityType(String entityType) { | ||
this.entityType = entityType; | ||
} | ||
|
||
public String getDisplayName() { | ||
return displayName; | ||
} | ||
|
||
public void setDisplayName(String displayName) { | ||
this.displayName = displayName; | ||
} | ||
|
||
public String getNetObjectId() { | ||
return netObjectId; | ||
} | ||
|
||
public void setNetObjectId(String netObjectId) { | ||
this.netObjectId = netObjectId; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...es/Java/swis-client/src/main/java/com/solarwinds/orionsdk/discovery/DiscoveryResults.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.solarwinds.orionsdk.discovery; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class DiscoveryResults { | ||
public DiscoveryStatus getResult() { | ||
return result; | ||
} | ||
|
||
public void setResult(DiscoveryStatus result) { | ||
this.result = result; | ||
} | ||
|
||
public String getResultDescription() { | ||
return resultDescription; | ||
} | ||
|
||
public void setResultDescription(String resultDescription) { | ||
this.resultDescription = resultDescription; | ||
} | ||
|
||
public String getErrorMessage() { | ||
return errorMessage; | ||
} | ||
|
||
public void setErrorMessage(String errorMessage) { | ||
this.errorMessage = errorMessage; | ||
} | ||
|
||
public List<DiscoveredObject> getDiscoveredObjects() { | ||
return discoveredObjects; | ||
} | ||
|
||
private DiscoveryStatus result; | ||
private String resultDescription; | ||
private String errorMessage; | ||
private final List<DiscoveredObject> discoveredObjects = new ArrayList<DiscoveredObject>(); | ||
} |
5 changes: 5 additions & 0 deletions
5
...les/Java/swis-client/src/main/java/com/solarwinds/orionsdk/discovery/DiscoveryStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.solarwinds.orionsdk.discovery; | ||
|
||
public enum DiscoveryStatus { | ||
Unknown, InProgress, Finished, Error, NotScheduled, Scheduled, NotCompleted, Canceling, ReadyForImport | ||
} |
17 changes: 17 additions & 0 deletions
17
Samples/Java/swis-client/src/main/java/com/solarwinds/orionsdk/discovery/IpAddress.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.solarwinds.orionsdk.discovery; | ||
|
||
public class IpAddress { | ||
private String address; | ||
|
||
public IpAddress(String address) { | ||
setAddress(address); | ||
} | ||
|
||
public String getAddress() { | ||
return address; | ||
} | ||
|
||
public void setAddress(String address) { | ||
this.address = address; | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
...va/swis-client/src/main/java/com/solarwinds/orionsdk/discovery/OrionDiscoveryManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.solarwinds.orionsdk.discovery; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.solarwinds.orionsdk.swis_client.ISwisClient; | ||
|
||
public class OrionDiscoveryManager { | ||
private static final String ORION_DISCOVERY = "Orion.Discovery"; | ||
private ISwisClient swis; | ||
|
||
public OrionDiscoveryManager(ISwisClient swis) { | ||
this.swis = swis; | ||
} | ||
|
||
public String createCorePluginConfiguration(CorePluginContext context) { | ||
return swis.invoke(ORION_DISCOVERY, "CreateCorePluginConfiguration", context).getAsString(); | ||
} | ||
|
||
public int startDiscovery(StartDiscoveryContext context) { | ||
return swis.invoke(ORION_DISCOVERY, "StartDiscovery", context).getAsInt(); | ||
} | ||
|
||
public DiscoveryStatus checkDiscoveryStatus(final int profileId) { | ||
List<Map<String, Object>> results = swis.query( | ||
"SELECT Status FROM Orion.DiscoveryProfiles WHERE ProfileID = @profileId", | ||
param("profileId", profileId)); | ||
if (results.isEmpty()) | ||
return DiscoveryStatus.Unknown; | ||
|
||
return DiscoveryStatus.values()[(int) (long) (Long) results.get(0).get("Status")]; | ||
} | ||
|
||
public DiscoveryResults waitForCompletion(final int profileId) throws InterruptedException { | ||
DiscoveryStatus status; | ||
do { | ||
Thread.sleep(1000); | ||
status = checkDiscoveryStatus(profileId); | ||
} while (status == DiscoveryStatus.InProgress); | ||
|
||
List<Map<String, Object>> log = swis.query( | ||
"SELECT Result, ResultDescription, ErrorMessage, BatchID FROM Orion.DiscoveryLogs WHERE ProfileID = @profileId", | ||
param("profileId", profileId)); | ||
|
||
DiscoveryResults results = new DiscoveryResults(); | ||
results.setResult(DiscoveryStatus.values()[(int) (long) (Long) log.get(0).get("Result")]); | ||
results.setResultDescription((String) log.get(0).get("ResultDescription")); | ||
results.setErrorMessage((String) log.get(0).get("ErrorMessage")); | ||
|
||
if (results.getResult() == DiscoveryStatus.Finished) { | ||
String batchId = (String) log.get(0).get("BatchID"); | ||
List<Map<String, Object>> items = swis.query( | ||
"SELECT EntityType, DisplayName, NetObjectID FROM Orion.DiscoveryLogItems WHERE BatchID = @batchId", | ||
param("batchId", batchId)); | ||
for (Map<String, Object> item : items) { | ||
DiscoveredObject obj = new DiscoveredObject(); | ||
obj.setEntityType((String) item.get("EntityType")); | ||
obj.setDisplayName((String) item.get("DisplayName")); | ||
obj.setNetObjectId((String) item.get("NetObjectID")); | ||
results.getDiscoveredObjects().add(obj); | ||
} | ||
} | ||
|
||
return results; | ||
} | ||
|
||
private Map<String, Object> param(String name, Object value) { | ||
Map<String, Object> data = new HashMap<String, Object>(); | ||
data.put(name, value); | ||
return data; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...Java/swis-client/src/main/java/com/solarwinds/orionsdk/discovery/PluginConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.solarwinds.orionsdk.discovery; | ||
|
||
public class PluginConfiguration { | ||
private String pluginConfigurationItem; | ||
|
||
public PluginConfiguration(String item) { | ||
setPluginConfigurationItem(item); | ||
} | ||
|
||
public String getPluginConfigurationItem() { | ||
return pluginConfigurationItem; | ||
} | ||
|
||
public void setPluginConfigurationItem(String pluginConfigurationItem) { | ||
this.pluginConfigurationItem = pluginConfigurationItem; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
Samples/Java/swis-client/src/main/java/com/solarwinds/orionsdk/discovery/SnmpVersion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.solarwinds.orionsdk.discovery; | ||
|
||
public enum SnmpVersion { | ||
None, SNMP1, SNMP2c, SNMP3 | ||
} |
Oops, something went wrong.