Bug with hammer --csv subnet info --id 1 domains output?

When I list a subnet that has more than 1 domain you get ,domain1,domain2 in the output.
And maybe that is okay, but I was expecting something that could be used with the
hammer subnet create
–domains DOMAIN_NAMES Comma separated list of values. Values containing comma should be quoted or escaped with backslash

I was expecting something like ,“domain1,domain2”

The good part is that it is at the end of the list and the header does show ,Domains::1,Domains::2

I was trying to get around it with:
hammer --csv --csv-separator | subnet info --id 39
but I still get |domain1|domain2
I was hoping for |“domain1,domain2”

Does this make sense? Or am I being too picky?

I am looking at Foreman version 1.16

Thanks!

Serialization of structured data to CSV is a pain. The domains are defined
in the view as a list o objects and to be able to flatten it to CSV we
decided to convert the values into separate columns named <List

:: instead of comma-separated list (which wouldn’t work well if
the item has more then one attribute to display). This approach make it
possible to parse the values by a script however it makes it harder to
import into a spreadsheet without further processing. So the result is
valid csv format just maybe of unexpected structure.

Would it be possible solution to use different format (–output yaml,
–ouptut json) and do some custom post-processing of the output?

HTH,
Martin

I agree, that the csv format isn’t the best for this case.

The --output json looks the best to me.

How would I use the json file on another server to import the subnet?

Is there a way to use the hammer command with the json file or do you use something else to import it?

Thanks for your help!

Hammer commands are not able to receive the parameters as a JSON. It is good idea for a RFE though. It shouldn’t be difficult to iterate over the json with some script and produce/call the hammer create commands. Other option would be to iterate over the JSON and pass it directly to API which accepts JSON POST params.

Thank you for your help!
How would I go about creating an RFE?

I am looking for a good way to export the subnets and domain and pretty much all the metadata from Foreman and be able to put it into another Foreman server.

Installing Foreman is pretty easy adding all the bits so that you can use it is harder. I am looking for a good way to do that?

Thanks again for any help!

You can create a new issue on https://projects.theforeman.org/projects/hammer-cli/issues/new set the Tracker to Feature and fill in the Subject and Description. It helps if you describe in detail what problem the feature should solve and how you expect it to be used. Ideally with examples or samples of data going in and out. Then it is easier to discuss how it fits to the current design and iterate towards the implementation.

There are many ways to configure Foreman and which is best for you depends on your workflow. If you have a primary Instance and want to duplicate it exporting relevant bits and importing elsewhere may be a good choice. If you want to create exact copy you may use backup of your server and restore it on another box and change a hostname and a few other things. Some prefer to configure Foreman using Ansible playbook with https://github.com/theforeman/foreman-ansible-modules. I have no experience in this area so I let others speak.

I have been thinking about this problem. What I would really like to be able to do is output/export the information and I am thinking that I would like to store it as json files in such a way that it could be fed to the API with little or no reformatting. And store the json files in GitHub. So then people wouldn’t really need to know how to code to manage the configuration because it would just be json files. So if you need a new domain you just copy one and change it a little or anything else that you might want to change. I am still trying to figure out what reading a json file and using the API to add it to Foreman might look like in ruby?

Thanks!