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 #10823: Select system techniques and generate correct policies based on agent type #1667

Conversation

fanf
Copy link
Member

@fanf fanf commented Jun 15, 2017

https://www.rudder-project.org/redmine/issues/10823

This add the notion of AgentType

  • in the technique metadata.xml (parse and add structure AgentConfig which holds Bundle, Files and Templates (with a default behavior to handle the case were is not present, default-ing to cfengine-community + cfengine-nova)
  • in the generation, and especially in the Bundle generation.

We also add then new AgentSpecificLogic.scala which holds how bundle and files for agent, and is ready to be extensible and plugable.
There is also some renaming (node -> xml in parsing for ex, to keep reader sanity, or Cf3PromisesFileWriterService -> PolicyWriterService)

Must be merged before #1670 and #1669

@fanf
Copy link
Member Author

fanf commented Jun 15, 2017

PR rebased

@fanf fanf force-pushed the arch_10823/select_system_techniques_and_generate_correct_policies_based_on_agent_type branch from 1c6461e to 4cd6ab3 Compare June 15, 2017 15:21
@fanf
Copy link
Member Author

fanf commented Jun 16, 2017

PR rebased

@fanf fanf force-pushed the arch_10823/select_system_techniques_and_generate_correct_policies_based_on_agent_type branch from 4cd6ab3 to a37c213 Compare June 16, 2017 15:02
@fanf
Copy link
Member Author

fanf commented Jun 16, 2017

PR rebased

Copy link
Member

@ncharles ncharles left a comment

Choose a reason for hiding this comment

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

Two tests are failing:

Failed tests: The technique described should::have bundle list: 'bundle1,bundle2'(com.normation.cfclerk.domain.TechniqueTest): List(bundle1, bundle2, bundle1, bundle2) is not equal to List(bundle1, bundle2) / expected:<bundle1(..)
The technique described should::have templates 'tml1, tml2, tml3'(com.normation.cfclerk.domain.TechniqueTest): List(tml1, tml2, tml3, tml1, tml2, tml3) is not equal to List(tml1, tml2, tml3) / expected:<tml1(..)

if (node.label.toUpperCase == TECHNIQUE_ROOT) {
node.attribute(TECHNIQUE_NAME) match {
def parseXml(xml: Node, id: TechniqueId, expectedReportCsvExists: Boolean): Technique = {
//check that xml is <TECHNIQUE> and has a name attribute
Copy link
Member

Choose a reason for hiding this comment

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

this makes it much more readable, thank you !

{
//for compability reason, we cheat and make the template/file/bundlesequence under root
//and not in an <AGENT> sub-element be considered as being in <AGENT type="cfengine-community,cfengine-enterprise">
val forCompatibilityAgent = <AGENT type={s"${AgentType.CfeCommunity.toString},${AgentType.CfeEnterprise.toString}"}>
Copy link
Member

Choose a reason for hiding this comment

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

that's clever!

@@ -144,14 +143,14 @@ object NodeConfigurationHash {
*/
val nodeInfoHashValue = {
val i = nodeConfig.nodeInfo
List(
List[Int](
Copy link
Member

Choose a reason for hiding this comment

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

is there a real interest to use hashcode for boolean to be hashcoded ? (except for consistency purpose?)

Copy link
Member Author

Choose a reason for hiding this comment

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

AFAI recall, I had a warning by the compiler if not doing so

Copy link
Member

Choose a reason for hiding this comment

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

ok, thanks

along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<TECHNIQUE name="DSC Agant">
Copy link
Member

Choose a reason for hiding this comment

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

DSC Agent

@fanf fanf force-pushed the arch_10823/select_system_techniques_and_generate_correct_policies_based_on_agent_type branch from 8323367 to bc8f6cf Compare June 19, 2017 13:12
@fanf
Copy link
Member Author

fanf commented Jun 19, 2017

PR rebased

1 similar comment
@fanf
Copy link
Member Author

fanf commented Jun 19, 2017

PR rebased

@fanf fanf force-pushed the arch_10823/select_system_techniques_and_generate_correct_policies_based_on_agent_type branch from bc8f6cf to 582bc11 Compare June 19, 2017 14:42
@@ -231,7 +241,7 @@ class WriteSystemTechniquesTest extends Specification with Loggable with BoxSpec

//////////// set-up auto test cleaning ////////////
override def afterAll(): Unit = {
if(System.getProperty("tests.clean.tmp") != "false") {
if(false) { // System.getProperty("tests.clean.tmp") != "false") {
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 you forgot this one

@fanf
Copy link
Member Author

fanf commented Jun 19, 2017

PR rebased

@fanf fanf force-pushed the arch_10823/select_system_techniques_and_generate_correct_policies_based_on_agent_type branch from 582bc11 to 5426084 Compare June 19, 2017 14:58
@Normation-Quality-Assistant
Copy link
Contributor

OK, merging this PR

@Normation-Quality-Assistant Normation-Quality-Assistant merged commit 5426084 into Normation:prototype/windows-dsc Jun 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants