-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add API to manage groups in meta-data #19
Conversation
Please move IDENTIFIER after cloud-init in the path |
83f28d0
to
5de86b2
Compare
I built and ran a container based on this branch and I can't get the This is the payload: {
"x3000": {
"syslog_aggregator": "127.0.0.1"
},
"canary-123": {
"syslog_aggregator": "172.16.0.105"
}
} I then try to POST to the curl 'https://stratus.openchami.cluster:8443/cloud-init/groups' -d @groups2.json -X POST But this returns
|
How is the container built? I'm wondering if something weird is happening with copying the binary. Also, is it possible to try again on bare metal? |
I'm using the Dockerfile go build ./cmd/cloud-init-server/
podman build -t cloud-init-server:test -f Dockerfile . |
This PR addresses #17 adds a groups API to cloud-init with the following endpoints:
/groups
adds data from request body tometadata.groups
/groups
update data from request body tometadata.groups
if it exists/groups
returns and prints existingmetadata.groups
as YAML/groups
removes existingmetadata.groups
forid
The endpoints above should be used for managing the entire group data structure. Groups with the structure can be further fine-tuned using an identifier:
/groups/{id}
add data for a specific group if the data does not exist forid
/groups/{id}
updates data if it already exists for specific group/groups/{id}
returns and prints existing data for specific group as YAML/groups/{id}
removes existing data for group specified withid
One thing to keep in mind is that to access the
meta-data
in the payload, you must specify the identifier with the waycloud-init
data is structured. The/groups
API only allows for setting the entiremeta-data.groups
data and not individual key-value pairs. This implementation requires themeta-data
to already exists and assumes a specific##groups
tag for thecitypes.CI.Name
(which can be changed). To set specific key-value pairs in a group, use the/groups/{id}
endpoints as shown below.Creating Groups Without the Groups API
Currently, groups can be created using the following without using the API added in this PR with the following:
curl 'http://127.0.0.1:27777/cloud-init/' -d @data.json -X POST
where
data.json
is something like:The internal data structure requires that there be a
name
identifier included in the data. The groups API assumes a specific name as mentioned above to get around this for now.Creating Groups Using the Groups API
Groups can be added and modified using the
/groups
endpoints to modify all the data or/groups/{id}
endpoints to modify specific key-value pairs within a group:The JSON in
groups.json
only contains the data to include in the groups:To confirm that the data was added and return as YAML:
curl 'http://127.0.0.1:27777/cloud-init/groups'
This should return something like this:
If instead you only want to add key-value pairs to your group data, you can do something similar to the
/groups
endpoint, but you must specify an identifier associated with the group:The data from
groups.json
will now be added as a value with atest
key and should return this:The commands above have been tested with a local instance of cloud-init built with the changes in this branch.