Skip to content
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

Conversation

VinceMacBuche
Copy link
Member

@VinceMacBuche
Copy link
Member Author

Commit modified

@VinceMacBuche VinceMacBuche force-pushed the ust_8924/policy_mode_api_global_directive_node branch from 467f3a1 to c721692 Compare September 7, 2016 15:49
@VinceMacBuche
Copy link
Member Author

PR rebased

@VinceMacBuche VinceMacBuche force-pushed the ust_8924/policy_mode_api_global_directive_node branch from c721692 to 0279871 Compare September 7, 2016 16:38
* Can not be empty nor null.
*/
, shortDescription : String
, policyMode : Option[PolicyMode]
Copy link
Member

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?

@VinceMacBuche
Copy link
Member Author

Commit modified

@VinceMacBuche VinceMacBuche force-pushed the ust_8924/policy_mode_api_global_directive_node branch 2 times, most recently from 9a7640f to 2124ece Compare September 12, 2016 08:56
@VinceMacBuche
Copy link
Member Author

Commit modified

1 similar comment
@VinceMacBuche
Copy link
Member Author

Commit modified

@VinceMacBuche VinceMacBuche force-pushed the ust_8924/policy_mode_api_global_directive_node branch from 2124ece to 0ae6f60 Compare September 12, 2016 08:59
@@ -484,7 +493,7 @@ objectclass ( RudderObjectClasses:23
STRUCTURAL
MUST ( directiveId $ techniqueVersion )
MAY ( cn $ description $ longDescription $ isEnabled $ isSystem $
directivePriority $ directiveVariable ) )
directivePriority $ directiveVariable $ policyMode ) )
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

@VinceMacBuche
Copy link
Member Author

PR rebased

@VinceMacBuche VinceMacBuche force-pushed the ust_8924/policy_mode_api_global_directive_node branch from f2e3bf1 to 5c03ec9 Compare September 12, 2016 10:30
@@ -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)
Copy link
Member

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 ?)

Copy link
Member Author

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

Copy link
Member

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))

Copy link
Member Author

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

@VinceMacBuche
Copy link
Member Author

PR rebased

@VinceMacBuche VinceMacBuche force-pushed the ust_8924/policy_mode_api_global_directive_node branch from 5c03ec9 to 388c448 Compare September 12, 2016 10:39
@@ -0,0 +1,112 @@
/*
*************************************************************************************
* Copyright 2013 Normation SAS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2016, isn't it ?

@VinceMacBuche
Copy link
Member Author

Commit modified

@VinceMacBuche VinceMacBuche force-pushed the ust_8924/policy_mode_api_global_directive_node branch 2 times, most recently from bf21a01 to 77f1963 Compare September 12, 2016 11:02
@VinceMacBuche
Copy link
Member Author

Commit modified

1 similar comment
@VinceMacBuche
Copy link
Member Author

Commit modified

@VinceMacBuche VinceMacBuche force-pushed the ust_8924/policy_mode_api_global_directive_node branch from 77f1963 to 1c5fa7c Compare September 12, 2016 14:01
id : NodeId
, modAgentRun: Option[SimpleDiff[Option[AgentRunInterval]]]
) extends NodeDiff with HashcodeCaching
object ModifyNodeAgentRunDiff{
Copy link
Member

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 ?

Copy link
Member Author

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

Copy link
Member Author

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 {
Copy link
Member

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(
Copy link
Member

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

Copy link
Member Author

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] = {
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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 :/

@VinceMacBuche
Copy link
Member Author

Commit modified

@VinceMacBuche VinceMacBuche force-pushed the ust_8924/policy_mode_api_global_directive_node branch from 5c338cd to 30a354c Compare September 15, 2016 13:08
Copy link
Member

@fanf fanf left a 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 !

@VinceMacBuche
Copy link
Member Author

PR rebased

@VinceMacBuche VinceMacBuche force-pushed the ust_8924/policy_mode_api_global_directive_node branch from 30a354c to bcff59a Compare September 19, 2016 08:03
@Normation-Quality-Assistant
Copy link
Contributor

OK, merging this PR

@Normation-Quality-Assistant Normation-Quality-Assistant merged commit bcff59a into Normation:master Sep 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants