I am working on some uri calls with netbackup and with swagger shows that it only works with but the uri modual is using {}. Any thoughts or tricks to get that to format correctly?
For example i am sending a body uri body of:
`
name: Create MSDP Disk Pool
uri:
url: “{{baseurl}}storage/disk-pools”
method: POST
body_format: json
status_code: 201
headers:
authorization: “{{login.json.token}}”
content-type: application/vnd.netbackup+json;version=3.0
body:
data:
type: diskPool
attributes:
name: server_dpm
diskVolumes:
[name: PureDiskVolume]
maximumIoStreams:
limitIoStreams: true
streamsPerVolume: 75
relationships:
storageServers:
data:
type: storageServer
id: ‘PureDisk:server.domain’
validate_certs: no
return_content: yes
register: dp_create
`
Which produces this:
`
“body”: {
“data”: {
“attributes”: {
“diskVolumes”: [
{
“name”: “PureDiskVolume”
}
],
“maximumIoStreams”: {
“limitIoStreams”: true,
“streamsPerVolume”: 75
},
“name”: “server_dpm”
},
“relationships”: {
“storageServers”: {
“data”: {
“id”: “PureDisk:server.domain”,
“type”: “storageServer”
}
}
},
“type”: “diskPool”
}
},
`
While swagger produces it as this:
`
working:
{
“data”: {
“type”: “diskPool”,
“attributes”: {
“name”: “server_dpm”,
“diskVolumes”: [
{
“name”: “PureDiskVolume”
}
],
“maximumIoStreams”: {
“limitIoStreams”: true,
“streamsPerVolume”: 75
}
},
“relationships”: {
“storageServers”: {
“data”: [
{
“type”: “storageServer”,
“id”: “PureDisk:server.domain”
}
]
}
}
}
}
`
You’re sending something that doesn’t work, and you seem to know exactly what the problem is, and also what format does work. So the solution is… send that?
Or am I missing something
The problem is I don’t know how to make ansible send the right bracket. Testing from swagger I know what it expects.
racke
(Stefan Hornburg)
December 14, 2019, 8:35am
4
The problem is I don't know how to make ansible send the right bracket. Testing from swagger I know what it expects.
Hello Nicholas,
try to use a list instead of a dict:
data:
- type: storageServer
id: 'PureDisk:server.domain'
Regards
Racke
Is it the - in front of type that makes it a list over a dict?
When i try that i get a syntax error.
fatal: [127.0.0.1]: FAILED! => {
“reason”: “Syntax Error while loading YAML.\n did not find expected ‘-’ indicator\n\nThe error appears to be in ‘/home/nbritton/ansible/gts-core-storage-operations/netbackup/tasks/msdp.create.include.yml’: line 78, column 17, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n - type: storageServer\n id: ‘PureDisk:server’\n ^ here\nThis one looks easy to fix. It seems that there is a value started\nwith a quote, and the YAML parser is expecting to see the line ended\nwith the same kind of quote. For instance:\n\n when: "ok" in result.stdout\n\nCould be written as:\n\n when: ‘"ok" in result.stdout’\n\nOr equivalently:\n\n when: "‘ok’ in result.stdout"\n”
}
vbotka
(Vladimir Botka)
December 14, 2019, 3:19pm
7
Hi Nicholas,
When i try that i get a syntax error.
fatal: [127.0.0.1]: FAILED! => {
"reason": "Syntax Error while loading YAML.\n
Literal style indicator of the block is missing "|"
https://yaml.org/spec/1.2/spec.html#id2795688
Try:
body: |
instead of
> > body:
> > data:
> > type: diskPool
> > attributes:
> > name: server_dpm
> > diskVolumes:
> > [name: PureDiskVolume]
> > maximumIoStreams:
> > limitIoStreams: true
> > streamsPerVolume: 75
> > relationships:
> > storageServers:
> > data:
> > type: storageServer
> > id: 'PureDisk:server.domain'
Cheers,
-vlado
vbotka
(Vladimir Botka)
December 14, 2019, 3:40pm
8
Hi Nicholas,
When i try that i get a syntax error.
fatal: [127.0.0.1]: FAILED! => {
"reason": "Syntax Error while loading YAML.\n
Indentation is wrong. (Disregard my previous email.)
> > body:
> > data:
> > . type: diskPool
> > . attributes:
> > . name: server_dpm
> > . diskVolumes:
> > . [name: PureDiskVolume]
> > . maximumIoStreams:
> > . limitIoStreams: true
> > . streamsPerVolume: 75
> > .relationships:
> > .storageServers:
> > data:
> > type: storageServer
> > id: 'PureDisk:server.domain'
Cheers,
-vlado
Okay I can try that. Looks like you added a . In front of each line but the last one that needs to be a list? Did I see that correct?
Thank everyone for the help. Once i lined up the - correctly it worked. That was a nice trick to learn.
relationships:
storageServers:
data:
type: storageServer
id: “PureDisk:{{mediaserver}}.{{domain}}”