Coder Social home page Coder Social logo

Comments (8)

MarkGibbons avatar MarkGibbons commented on August 17, 2024 1

good luck.

from chef.

MarkGibbons avatar MarkGibbons commented on August 17, 2024

@rejo-oommen

There's nothing in go-chef/chef that allows for retrieving partial information from a node.
https://docs.chef.io/api_chef_server/#get-38 shows the doc for the underlying Chef Server API get call. The GET named node endpoint doesn't take any parameters or any json body. There's nothing documented that would allow retrieval of specific database fields. Being able to get node information without the automatic data would likely cut the size down to something reasonable. This api client isn't the place to initiate that change though. The Chef Server API would need to allow a request like that.

I looked through the er-chef API code. I'm pretty sure no option exists there to get the node data without the automatic attributes.

Sorry that's not more help,
Mark

from chef.

RejoOommen avatar RejoOommen commented on August 17, 2024

Thank You for the response @MarkGibbons . I don't see the option in the chef server api too.
Is there a possibility in the PUT call to ignore the automatic attributes received from GET and update only the rest?

from chef.

MarkGibbons avatar MarkGibbons commented on August 17, 2024

You can set:
node1.AutomaticAttributes = map[string]interface{}{}
Where node1 is a chef Node struct.

The json generated and sent with the PUT request to the api ignores the empty AutomaticAttributes field. The Chef Server however sets the automatic attributes for the node to nil in this case. So, you can do that if you don't mind wiping out the values. The next chef-client run will repopulate the values.

from chef.

RejoOommen avatar RejoOommen commented on August 17, 2024

Ok. I would need to evaluate if I can afford making it nil. Was basically looking at skipping that attribute in PUT. Anyways thanks for clarifying.

from chef.

MarkGibbons avatar MarkGibbons commented on August 17, 2024

Hi @RejoOommen
Did you have more questions?

from chef.

RejoOommen avatar RejoOommen commented on August 17, 2024

@MarkGibbons Yes, wanted to check if I could do something similar to the example given below(using knife ) which I believe will avoid the node PUT call thereby not touching the other parameters for my current use case.

Add a role to a node runlist
knife node run_list add xyz.com "role[maintain_23]"

Remove a role from a node runlist
knife node run_list remove xyz.com "role[maintain_15]"

from chef.

MarkGibbons avatar MarkGibbons commented on August 17, 2024

knife node add and remove do a get and put under the covers.
For instance see /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.8.23/lib/chef/node.rb and the save method.

When you make a change to the run_list knife first loads the node then does a node.save which is in essence a put. If you want to use the API.

get the node and populate a node strucuture
update the node structure
put the node.

Set the automatic attributes to nil first if you want to eliminate some of the data transfer back. I don't see any other options in the server api. That's what knife does too.

from chef.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.