Comments (8)
good luck.
from chef.
@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.
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.
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.
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.
Hi @RejoOommen
Did you have more questions?
from chef.
@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.
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)
- go.mod has a weird required module HOT 1
- Create test cases for the cookbook_artifact endpoints.
- Test against Goiardi
- Changing group membership fails. HOT 1
- fatal: No url found for submodule path 'testapi/bin/cookbooks/testsamp' HOT 4
- Taks: Improve node struct HOT 2
- Enhancement: Missing Error message detail
- Accept the chef-workstation license on the test instance HOT 1
- SearchResult#Rows should be an array of json.RawMessage and not empty interface HOT 2
- Environment tests
- Add an integration test for pkcs8
- Unexpected `Access` field in the `Cookbook` structure HOT 2
- Search result object has changed structure in recent versions of Chef Infra server HOT 3
- Use testify/assert for test cases.
- Need tests for config_rb_reader
- cfg.Proxy need tests
- Need tests for NewClientWithOutConfig, NoAuthNewRequest, MagicRequestResponseDecoderWithOutAuth
- Add tests for node.GetAttribute to the integration tests.
- Support encryption and decryption HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chef.