New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #8924: Policy mode API (Global, Directive, Node) #1189
Fixes #8924: Policy mode API (Global, Directive, Node) #1189
Conversation
Commit modified |
467f3a1
to
c721692
Compare
PR rebased |
c721692
to
0279871
Compare
* Can not be empty nor null. | ||
*/ | ||
, shortDescription : String | ||
, policyMode : Option[PolicyMode] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you adda a description like for other parameters here?
Commit modified |
9a7640f
to
2124ece
Compare
Commit modified |
1 similar comment
Commit modified |
2124ece
to
0ae6f60
Compare
@@ -484,7 +493,7 @@ objectclass ( RudderObjectClasses:23 | |||
STRUCTURAL | |||
MUST ( directiveId $ techniqueVersion ) | |||
MAY ( cn $ description $ longDescription $ isEnabled $ isSystem $ | |||
directivePriority $ directiveVariable ) ) | |||
directivePriority $ directiveVariable $ policyMode ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to update also the 099-1-rudder.ldif file in test/resources/ldap-data/schema
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!
PR rebased |
f2e3bf1
to
5c03ec9
Compare
@@ -558,6 +583,9 @@ class LDAPEntityMapper( | |||
entry +=! (A_PRIORITY, directive.priority.toString) | |||
entry +=! (A_IS_ENABLED, directive.isEnabled.toLDAPString) | |||
entry +=! (A_IS_SYSTEM, directive.isSystem.toLDAPString) | |||
for { | |||
mode <- directive.policyMode | |||
} entry +=! (A_POLICY_MODE, mode.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this construct ? (compared to a map, or a yield ?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's foreach syntax with a for
I don't need the result, so don't need yield/flatmap or map
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the readability is poor compared to
directive.policyMode.map( x => entry +=! (A_POLICY_MODE, x.name))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could do it with a foreach, but i prefer the for way
PR rebased |
5c03ec9
to
388c448
Compare
@@ -0,0 +1,112 @@ | |||
/* | |||
************************************************************************************* | |||
* Copyright 2013 Normation SAS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2016, isn't it ?
Commit modified |
bf21a01
to
77f1963
Compare
Commit modified |
1 similar comment
Commit modified |
77f1963
to
1c5fa7c
Compare
id : NodeId | ||
, modAgentRun: Option[SimpleDiff[Option[AgentRunInterval]]] | ||
) extends NodeDiff with HashcodeCaching | ||
object ModifyNodeAgentRunDiff{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why replacing the case class by an object ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal (discussed with @fanf) is to remove the old events (ModifyNodeAgentRun, ModifyNodeProperties ModifyNodeHeartbeat) by one and only one event that is 'ModifyNode'
I removed possibility to save/create those events but we need to be able to read previous events
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those object are only used as syntax sugar when we are reading the old event (Could be replaced by ModifyNode(agentRun,None,None,None)
) | ||
|
||
object ModifyNodeDiff { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why both a case class and an object ??
, principal: EventActor | ||
, modifyDiff: ModifyNodePropertiesDiff | ||
, reason:Option[String]) = { | ||
def saveModifyNode( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think i prefered the name NodeProperties, as modify node leads me to think we are changing the node, and not properties attached to it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are changing the node now, not only 'properties'
* If the node is a system one, the methods fails. | ||
*/ | ||
private[this] def update(nodeId: NodeId, updateNode: Node => Node, logAction: (Node, Node) => Box[EventLog]) : Box[Node] = { | ||
def updateNode(node: Node, modId: ModificationId, actor:EventActor, reason:Option[String]) : Box[Node] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, here i tend to think the method change a node
def getModifyNodeDetails(xml:NodeSeq) : Box[ModifyNodeDiff] = { | ||
for { | ||
entry <- getEntryContent(xml) | ||
node <- (entry \ "node").headOption ?~! ("Entry type is not node : " + entry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you align the <- please ?
case eb : EmptyBox => | ||
val e = eb ?~! s"Could not get Node '${nodeId.value}' details" | ||
logger.error(e.messageChain) | ||
throw new Exception(e.messageChain) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm really not convinced by throwing an exception when loading the page.
With this, we go from a safe-ish approach where the error The node with id '${nodeId.value}' was not found was displayed to user to an exception, that won't probably be of any help to user :/
Commit modified |
5c338cd
to
30a354c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems OK for me. Please rebase the commit and merge !
PR rebased |
30a354c
to
bcff59a
Compare
OK, merging this PR |
https://www.rudder-project.org/redmine/issues/8924