oci-cli
oci-cli copied to clipboard
oci compute compute-capacity-report says invalid json with generated sample json
oci compute compute-capacity-report reports Parameter 'shape_availabilities' must be in JSON format.
when using example json.
Following the documentation here ... https://docs.oracle.com/en-us/iaas/tools/oci-cli/3.37.7/oci_cli_docs/cmdref/compute/compute-capacity-report/create.html
oci compute compute-capacity-report create \
--generate-param-json-input shape-availabilities > shape-availabilities.json
shape-availabilities.json
[
{
"faultDomain": "string",
"instanceShape": "string",
"instanceShapeConfig": {
"memoryInGBs": 0.0,
"nvmes": 0,
"ocpus": 0.0
}
},
{
"faultDomain": "string",
"instanceShape": "string",
"instanceShapeConfig": {
"memoryInGBs": 0.0,
"nvmes": 0,
"ocpus": 0.0
}
}
]
Running
oci compute compute-capacity-report create --availability-domain $availability_domain \
--compartment-id $compartment_id --shape-availabilities file://shape-availabilities.json
Results in
Parameter 'shape_availabilities' must be in JSON format.
For help with formatting JSON input see our documentation here: https://docs.cloud.oracle.com/iaas/Content/API/SDKDocs/cliusing.htm#ManagingCLIInputandOutput
I followed the examples here https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/cliusing.htm#ManagingCLIInputandOutput but cant seem to make any sense of it.
I suspect there is a bug with the way the report expects input or how the sample data is generated? Thanks in advance.
You probably edited the shape-availabilities.json file above before using it in the subsequent command. But you don't show the final json file. I suspect there's a missing or extra bracket or comma that's causing the "must be in JSON format" error.
I edited my shape-availabilities.json file to look like:
[
{
"instanceShape": "VM.Standard.E4.Flex",
"instanceShapeConfig": {
"memoryInGBs": 32.0,
"ocpus": 8.0
}
}
]
and the command works okay.
I tried your exact shape-availabilities.json file contents and get the same error. Might be a windows problem?
If the json is syntactically correct and you're still getting the error, it may be due to character encoding in the file. See OCI Command Line JSON File Data for details. I'm not sure how to check or change the encoding, but this looks like a possible explanation.
I still see the issue. could you help us look at it:
➜ ~ oci compute compute-capacity-report create --availability-domain ypKW:US-ASHBURN-AD-3 --compartment-id $COMP --shape-availabilities file://shape-availabilities.json --auth security_token --profile DEFAULT ServiceError: { "client_version": "Oracle-PythonSDK/2.125.0, Oracle-PythonCLI/3.38.0", "code": "CannotParseRequest", "logging_tips": "Please run the OCI CLI command using --debug flag to find more debug information.", "message": "Incorrectly formatted request. Please refer to our documentation for help.", "opc-request-id": "B969808362764DC7A19D485EDA14E512/42AAB29560E119DAC29E223B05AB8633/776E248F2FE4E9356F9FF414608CD00C", "operation_name": "create_compute_capacity_report", "request_endpoint": "POST https://iaas.us-ashburn-1.oraclecloud.com/20160918/computeCapacityReports", "status": 400, "target_service": "compute", "timestamp": "2024-06-04T07:25:15.679687+00:00", "troubleshooting_tips": "See [https://docs.oracle.com/iaas/Content/API/References/apierrors.htm] for more information about resolving this error. If you are unable to resolve this issue, run this CLI command with --debug option and contact Oracle support and provide them the full error message." }
This works well:
oci compute compute-capacity-report create --availability-domain dbTR:US-ASHBURN-AD-3 --compartment-id $T --shape-availabilities file://shape.json
shape.json:
[
{
"faultDomain": "FAULT-DOMAIN-1",
"instanceShape": "VM.Standard.E4.Flex",
"instanceShapeConfig": {
"memoryInGBs": 16.0,
"nvmes": null,
"ocpus": 4.0
}
},
{
"faultDomain": "FAULT-DOMAIN-2",
"instanceShape": "VM.Standard.E4.Flex",
"instanceShapeConfig": {
"memoryInGBs": 16.0,
"nvmes": null,
"ocpus": 4.0
}
}
]
I would suggest you to check the tool we developed - https://github.com/oracle/oci-python-sdk/tree/master/examples/oci_capacity_reporter