Commit 01d1ed41 by Tomasz Ciesielczyk

node id list

parent d7598ed1
package psnc.m2dc.rtm.client
const val APP_VERSION = "1.1.426_33338"
\ No newline at end of file
const val APP_VERSION = "1.1.426_51333"
\ No newline at end of file
......@@ -8,7 +8,6 @@ import psnc.m2dc.rtm.client.utils.debugConsole
import psnc.m2dc.rtm.rest.Handlers
import psnc.m2dc.rtm.rest.HandlersMap
import psnc.m2dc.rtm.utils.toJson
import java.util.*
/**
*
......@@ -17,7 +16,7 @@ import java.util.*
@CommandLine.Command(name = "status", description = ["rtm state "])
class StatusCommand : Runnable {
enum class Option {
rcuutil, rtm, powermanagement, totalpower, nodepower, save, resources, nodelist
rcuutil, rtm, powermanagement, totalpower, nodepower, save, resources, nodelist, nodeid
}
//["object type: "]
......@@ -39,6 +38,7 @@ class StatusCommand : Runnable {
Option.save -> saveState()?.toJson(true)
Option.resources -> listResources()?.toJson(true)
Option.nodelist -> listNodes()?.toJson(true)
Option.nodeid -> listNodeIds()?.joinToString(separator = ",") { it }
}
......@@ -61,7 +61,7 @@ class StatusCommand : Runnable {
}
private fun listNodes(): Any? {
debugConsole("get node list")
debugConsole("get node list")
return RTMRestClient.instance.connect(
HandlersMap.resource_list.replace(":${Handlers.RESTParams.type_name}", "node")
, Connection.Method.GET, "")
......@@ -69,6 +69,15 @@ class StatusCommand : Runnable {
}
private fun listNodeIds(): Set<String>? {
debugConsole("get node list")
return RTMRestClient.instance.connect(
HandlersMap.resource_list.replace(":${Handlers.RESTParams.type_name}", "node")
, Connection.Method.GET, "")
.get<Map<String, Any>>(Handlers.RESTKeys.result.toString(), RTMRestClient.instance.debug)?.keys
}
private fun getState(): HashMap<String, Any>? {
debugConsole("get state")
return RTMRestClient.instance.connect(HandlersMap.get_state, Connection.Method.GET).get<HashMap<String,
......
......@@ -62,7 +62,7 @@ class RECSMonitoringApi private constructor(/*storage: IStorage<String>? = null*
// printConsole(Keys.TestBed.resource_list.getNullable()?.first() ?: "null ")
val nodes = listNodes(host).nodeList.filter {
// printConsole(Keys.TestBed.resource_list.getNullable()?.contains(it.id)?.toString() ?: "null ")
// printConsole(Keys.TestBed.resource_list.getNullable()?.contains(it.id)?.toString() ?: "null ")
// printConsole("id ${it.id}")
!map.containsKey(it.id) &&
......@@ -73,16 +73,13 @@ class RECSMonitoringApi private constructor(/*storage: IStorage<String>? = null*
nodes.forEach {
try {
// val resourceType = DAO.ResourcesManagerApi.getResourceType(it.id + "_recsnode")
// ?: DAO.ResourcesManagerApi.getResourceType("recsnode")
// ?: throw RPMApiException("Default recs node resource type is not defined")
// val cpuType = DAO.ResourcesManagerApi.getResourceType(it.id + "_recscpu")
// ?: DAO.ResourcesManagerApi.getResourceType("recscpu")
// ?: throw RPMApiException("Default recs node cpu type is not defined")
// val typeId = resourceType.id
val typeId = "recsnode"
val resource = Resource(it.id, typeId, null, properties = HashMap())
val typeId = DAO.Resource.getType(it.id)
val resource = Resource(it.id, typeId ?: "recsnode", null, properties = HashMap())
if (typeId == null) {
logWarn("Recs resource type is not set, try reload:${resource.id}")
l.add(resource)
}
resource.put(Resource.Property.recs_host, host)
val model = NodeModel.create(it.id, it.architecture ?: "unknown", HashMap())
resource.put(Resource.Property.ssh_host, Keys.SSHHosts.get(resource.id))
......@@ -95,7 +92,7 @@ class RECSMonitoringApi private constructor(/*storage: IStorage<String>? = null*
resource.put(Resource.Property.node_id, resource.id)
//resource.resourceType = resourceType
l.add(resource)
} catch (e: Exception) {
// e.printStackTrace()
logError(e, "CANNOT get details for: " + it.id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment