Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
middleware
/
rtm_services
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2af9ede7
authored
Jun 25, 2019
by
Tomasz Ciesielczyk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
recs id mapping
parent
82861fea
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
66 additions
and
30 deletions
+66
-30
m2dc-rtm-rest/src/main/kotlin/psnc/m2dc/rtm/commands/java/Version.kt
+2
-2
m2dc-rtm-restclient/src/main/kotlin/psnc/m2dc/rtm/client/Version.kt
+2
-2
m2dc-rtm-utils/src/main/kotlin/psnc/m2dc/rtm/dao/ResourceManager.kt
+13
-1
m2dc-rtm-utils/src/main/kotlin/psnc/m2dc/rtm/model/recs/Node.kt
+2
-2
m2dc-rtm-utils/src/main/kotlin/psnc/m2dc/rtm/rpm/RPMApiImpl.kt
+11
-8
m2dc-rtm-utils/src/main/kotlin/psnc/m2dc/rtm/rpm/nativeapi/RECSManagementApi.kt
+14
-0
m2dc-rtm-utils/src/main/kotlin/psnc/m2dc/rtm/rpm/nativeapi/RECSMonitoringApi.kt
+22
-15
No files found.
m2dc-rtm-rest/src/main/kotlin/psnc/m2dc/rtm/commands/java/Version.kt
View file @
2af9ede7
package
psnc.m2dc.rtm.commands.java
val
APP_VERSION
=
"1.0.631_57738"
\ No newline at end of file
val
APP_VERSION
=
"1.0.632_47979"
\ No newline at end of file
m2dc-rtm-restclient/src/main/kotlin/psnc/m2dc/rtm/client/Version.kt
View file @
2af9ede7
package
psnc.m2dc.rtm.client
const
val
APP_VERSION
=
"1.1.631_57738"
\ No newline at end of file
const
val
APP_VERSION
=
"1.1.632_47979"
\ No newline at end of file
m2dc-rtm-utils/src/main/kotlin/psnc/m2dc/rtm/dao/ResourceManager.kt
View file @
2af9ede7
...
...
@@ -6,6 +6,7 @@ import psnc.m2dc.rtm.properties.RTMProperties
import
psnc.m2dc.rtm.properties.keys.Keys
import
psnc.m2dc.rtm.rpm.*
import
psnc.m2dc.rtm.rpm.nativeapi.RECSApiImpl
import
psnc.m2dc.rtm.rpm.nativeapi.RECSManagementApi
import
psnc.m2dc.rtm.rpm.nativeapi.RECSMonitoringApi
import
psnc.m2dc.rtm.utils.*
import
psnc.m2dc.rtm.utils.Timer
...
...
@@ -182,11 +183,15 @@ class ResourceManager : DataDAO() {
val
timer
=
setWatch
()
val
details
=
this
.
getRecsHosts
(
false
)
printConsole
(
"recs hosts: ${details.toJson()}"
)
loadResourceFromFile
()
val
list
=
RECSMonitoringApi
.
instance
.
listAllNodes
(
details
)
// printConsole("loaded recs nodes1: ${list.toJson()}")
list
.
forEach
{
resource
->
res
[
resource
.
id
]
=
resource
}
setWatch
(
timer
)
// printConsole("loaded recs nodes: ${res.toJson()}")
res
...
...
@@ -217,6 +222,11 @@ class ResourceManager : DataDAO() {
it
.
value
.
getChildren
().
values
.
forEach
{
child
->
list
.
add
(
child
)
}
}
list
.
forEach
{
m
[
it
.
id
]
=
it
}
m
.
values
.
forEach
{
res
->
res
.
properties
[
"recs_id"
]
?.
let
{
RECSManagementApi
.
instance
.
setResourceId
(
it
.
toString
(),
res
.
id
)
}
}
return
m
}
catch
(
ex
:
Exception
)
{
logError
(
"Error occured while loading resources from file: ${ex.message}"
)
...
...
@@ -364,7 +374,9 @@ class ResourceManager : DataDAO() {
submittedTasks
.
forEach
{
id
,
taskResult
->
// printConsole("testx 9: $taskResult for $id")
try
{
taskResult
?.
get
(
TaskExecutor
.
SUBMIT_TIMEOUT
,
TimeUnit
.
MILLISECONDS
)
?.
getResult
()
?.
forEach
{
row
->
val
res
=
taskResult
?.
get
(
TaskExecutor
.
SUBMIT_TIMEOUT
,
TimeUnit
.
MILLISECONDS
)
?.
getResult
()
logDebug
(
"res: "
+
res
?.
toJson
())
res
?.
forEach
{
row
->
val
resource
=
row
.
first
val
sensorId
=
row
.
second
//(sensor name?)
...
...
m2dc-rtm-utils/src/main/kotlin/psnc/m2dc/rtm/model/recs/Node.kt
View file @
2af9ede7
...
...
@@ -7,7 +7,7 @@ import com.thoughtworks.xstream.io.HierarchicalStreamReader
import
com.thoughtworks.xstream.io.HierarchicalStreamWriter
class
Node
(
val
id
:
String
,
val
actualPowerUsage
:
Double
?,
val
actualNodePowerUsage
:
Double
?,
class
Node
(
val
id
:
String
,
val
actualPowerUsage
:
Double
?,
val
actualNodePowerUsage
:
Double
?,
val
actualPEGPowerUsage
:
Double
?,
val
maxPowerUsage
:
Int
?,
val
baseBoardId
:
String
?,
val
baseBoardPosition
:
Int
?,
val
state
:
Int
?,
val
architecture
:
String
?,
...
...
@@ -35,7 +35,7 @@ macAddressMgmt MAC address of the NIC connected to the management network (opti
*/
}
class
NodeList
(
val
nodeList
:
List
<
Node
>
=
ArrayList
<
Node
>())
{}
data class
NodeList
(
val
nodeList
:
List
<
Node
>
=
ArrayList
())
class
NodeConverter
:
Converter
{
...
...
m2dc-rtm-utils/src/main/kotlin/psnc/m2dc/rtm/rpm/RPMApiImpl.kt
View file @
2af9ede7
...
...
@@ -53,10 +53,10 @@ class RPMApiImpl : RPMApi {
ActionCache
.
restartActions
{
this
.
startAction
(
it
)
}
}
override
fun
startAction
(
result
:
ResourceActionResult
,
onSuccess
:
(()->
Unit
)?):
ResourceActionResult
{
override
fun
startAction
(
result
:
ResourceActionResult
,
onSuccess
:
(()
->
Unit
)?):
ResourceActionResult
{
logDebug
(
"startaction: "
+
result
.
toJson
())
logDebug
(
"startaction: "
+
(
Exception
().
stackTrace
.
toJson
()))
val
worker
=
ManagementWorkerImpl
(
result
.
resourceId
+
"_"
+
result
.
powerAction
.
name
,
{
actionTask
(
result
,
onSuccess
)
})
val
worker
=
ManagementWorkerImpl
(
result
.
resourceId
+
"_"
+
result
.
powerAction
.
name
,
{
actionTask
(
result
,
onSuccess
)
})
ManagementExecutor
.
executeTask
(
worker
,
TaskExecutor
.
ExecutionMode
.
WAIT
)
return
result
}
...
...
@@ -94,7 +94,7 @@ class RPMApiImpl : RPMApi {
}
finally
{
if
(!
actionFinished
)
{
ActionCache
.
registerFailure
(
result
)
}
else
{
}
else
{
onSuccess
?.
invoke
()
}
}
...
...
@@ -322,7 +322,7 @@ class RPMApiImpl : RPMApi {
}
}
}
?:
throw
NullPointerException
(
"Cannot load data for resourceId"
)
}
?:
throw
NullPointerException
(
"Cannot load data for
$
resourceId"
)
}
catch
(
e
:
Exception
)
{
ActionCache
.
registerFailure
(
apiDetails
,
resourceId
)
...
...
@@ -397,13 +397,16 @@ class RPMApiImpl : RPMApi {
private
fun
loadRecsData
(
host
:
String
):
List
<
Triple
<
String
,
String
,
Any
>>
{
val
result
=
ArrayList
<
Triple
<
String
,
String
,
Double
>>()
val
nodes
=
RECSMonitoringApi
.
instance
.
listNodes
(
host
)
logDebug
(
"loadRecsData: $host"
)
val
nodes
=
RECSMonitoringApi
.
instance
.
getNodeData
(
host
)
logDebug
(
nodes
.
toJson
())
nodes
.
nodeList
.
forEach
{
node
->
nodes
.
forEach
{
id
,
node
->
val
t1
=
node
.
inletTemperature
?:
node
.
outletTemperature
?:
0.0
val
t2
=
node
.
outletTemperature
?:
node
.
inletTemperature
?:
0.0
result
.
add
(
Triple
(
node
.
id
,
"current_power_usage"
,
node
.
actualPowerUsage
?:
0.0
))
result
.
add
(
Triple
(
node
.
id
,
"current_temperature"
,
(
t1
+
t2
)
/
2.0
))
result
.
add
(
Triple
(
id
,
"current_power_usage"
,
node
.
actualPowerUsage
?:
0.0
))
result
.
add
(
Triple
(
id
,
"current_temperature"
,
(
t1
+
t2
)
/
2.0
))
}
return
result
...
...
m2dc-rtm-utils/src/main/kotlin/psnc/m2dc/rtm/rpm/nativeapi/RECSManagementApi.kt
View file @
2af9ede7
...
...
@@ -2,12 +2,15 @@ package psnc.m2dc.rtm.rpm.nativeapi
import
org.slf4j.LoggerFactory
import
psnc.m2dc.rtm.dao.LightStorage
import
psnc.m2dc.rtm.model.recs.Node
import
psnc.m2dc.rtm.utils.logDebug
import
psnc.m2dc.rtm.utils.logWarn
class
RECSManagementApi
constructor
()
{
private
val
RECSApi
=
psnc
.
m2dc
.
rtm
.
rpm
.
nativeapi
.
RECSApiImpl
.
Instance
private
val
prefix
=
"RECS_"
companion
object
{
...
...
@@ -15,9 +18,20 @@ class RECSManagementApi constructor() {
fun
instance
():
RECSManagementApi
{
return
instance
}
val
log
=
LoggerFactory
.
getLogger
(
RECSManagementApi
::
class
.
java
.
name
)
!!
}
fun
setResourceId
(
recsId
:
String
,
resourceId
:
String
)
{
logDebug
(
"setResourceId $recsId $resourceId"
)
LightStorage
.
instance
.
put
(
listOf
(
prefix
,
"RESOURCE_MAP"
,
recsId
),
resourceId
)
}
fun
getResourceId
(
recsId
:
String
):
String
?
{
logDebug
(
"getResourceId $recsId "
)
return
LightStorage
.
instance
.
get
(
prefix
,
"RESOURCE_MAP"
,
recsId
)
}
/**
Turns on the node with the given ID and returns updated node XML
*/
...
...
m2dc-rtm-utils/src/main/kotlin/psnc/m2dc/rtm/rpm/nativeapi/RECSMonitoringApi.kt
View file @
2af9ede7
...
...
@@ -11,10 +11,7 @@ import psnc.m2dc.rtm.rpm.ManagementExecutor
import
psnc.m2dc.rtm.rpm.ManagementWorker
import
psnc.m2dc.rtm.rpm.ManagementWorkerImpl
import
psnc.m2dc.rtm.rpm.TaskExecutor
import
psnc.m2dc.rtm.utils.Timer
import
psnc.m2dc.rtm.utils.logError
import
psnc.m2dc.rtm.utils.logInfo
import
psnc.m2dc.rtm.utils.logWarn
import
psnc.m2dc.rtm.utils.*
import
java.util.concurrent.Future
import
java.util.concurrent.TimeUnit
...
...
@@ -33,29 +30,35 @@ class RECSMonitoringApi private constructor(/*storage: IStorage<String>? = null*
val
log
=
LoggerFactory
.
getLogger
(
RECSMonitoringApi
::
class
.
java
.
name
)
!!
}
fun
listAllNodes
(
hosts
:
List
<
String
>
,
reload
:
Boolean
=
true
):
List
<
Resource
>
{
fun
listAllNodes
(
hosts
:
List
<
String
>
/*, reload: Boolean = true*/
):
List
<
Resource
>
{
logInfo
(
"RECS: get nodes from: $hosts"
)
val
l
=
ArrayList
<
Resource
>()
d
/**
* resources to update via ssh api
*/
// val map = DAO.Resource.getNodes()
val
updateList
=
ArrayList
<
Resource
>()
hosts
.
forEach
{
host
->
val
map
=
DAO
.
Resource
.
getNodes
()
val
nodes
=
listNodes
(
host
).
nodeList
.
filter
{
(!
map
.
containsKey
(
it
.
id
)
||
reload
)
&&
(!
Keys
.
TestBed
.
filter_nodes
.
get
()
||
Keys
.
TestBed
.
resource_list
.
getNullable
()
?.
contains
(
it
.
id
)
?:
false
)
// (!map.containsKey(RECSManagementApi.instance.getResourceId( it.id)) || reload) &&
// (!Keys.TestBed.filter_nodes.get() ||
// Keys.TestBed.resource_list.getNullable()?.contains(it.id) ?: false)
(!
Keys
.
TestBed
.
filter_nodes
.
get
()
||
Keys
.
TestBed
.
resource_list
.
getNullable
()
?.
contains
(
it
.
id
)
?:
false
)
}
nodes
.
forEach
{
try
{
val
typeId
=
DAO
.
Resource
.
getType
(
it
.
id
)
val
resource
=
Resource
(
it
.
id
,
typeId
?:
""
,
null
,
properties
=
HashMap
())
val
resourceId
=
RECSManagementApi
.
instance
.
getResourceId
(
it
.
id
)
?:
it
.
id
logDebug
(
"Map RECS id: ${it.id} to $resourceId"
)
val
typeId
=
DAO
.
Resource
.
getType
(
resourceId
)
val
resource
=
Resource
(
resourceId
,
typeId
?:
""
,
null
,
properties
=
HashMap
())
resource
.
put
(
Resource
.
Property
.
recs_host
,
host
)
val
model
=
NodeModel
.
create
(
it
.
i
d
,
it
.
architecture
?:
"unknown"
,
HashMap
())
val
model
=
NodeModel
.
create
(
resourceI
d
,
it
.
architecture
?:
"unknown"
,
HashMap
())
Keys
.
SSHHosts
.
get
(
resource
.
id
)
Keys
.
SSHHosts
.
get
(
resource
.
id
)
?.
let
{
ssh_host
->
resource
.
put
(
Resource
.
Property
.
ssh_host
,
ssh_host
)
...
...
@@ -63,7 +66,7 @@ class RECSMonitoringApi private constructor(/*storage: IStorage<String>? = null*
Keys
.
RTM
.
default_ssh_user
.
getNullable
()
?.
let
{
resource
.
put
(
Resource
.
Property
.
ssh_username
,
it
)
}
if
(
typeId
==
null
&&
Keys
.
SSHHosts
.
get
(
resource
.
id
)
!=
null
&&
Keys
.
RTM
.
default_ssh_user
.
getNullable
()
!=
null
)
{
logWarn
(
"Recs resource type is not set, try reload:
${resource.id}
"
)
logWarn
(
"Recs resource type is not set, try reload:
${resource.id}.
"
)
updateList
.
add
(
resource
)
}
resource
.
put
(
model
)
...
...
@@ -166,8 +169,12 @@ class RECSMonitoringApi private constructor(/*storage: IStorage<String>? = null*
return
type
}
fun
getNodeData
(
host
:
String
):
Map
<
String
,
Node
>
=
this
.
listNodes
(
host
).
nodeList
.
map
{
val
id
=
RECSManagementApi
.
instance
.
getResourceId
(
it
.
id
)
?:
it
.
id
id
to
it
}.
toMap
()
fun
listNodes
(
host
:
String
):
NodeList
{
private
fun
listNodes
(
host
:
String
):
NodeList
{
val
result
=
RECSApi
.
getXML
<
NodeList
>(
"""http://$host/REST/node"""
)
return
result
.
first
?:
NodeList
()
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment