Related
I try to translate a IFC file by API, but failed.
And I can translate this file successful in [https://viewer.autodesk.com/designviews].
The manifest
{
"urn": "dXJuOmFkc2sub2JqZWN0czp......",
"derivatives": [
{
"hasThumbnail": "false",
"name": "XXXXXXXX.ifc",
"progress": "complete",
"messages": [
{
"type": "error",
"message": "Unrecoverable exit code from extractor: -1073741829",
"code": "TranslationWorker-InternalFailure"
}
],
"outputType": "svf",
"status": "failed"
}
],
"hasThumbnail": "false",
"progress": "complete",
"type": "manifest",
"region": "US",
"version": "1.0",
"status": "failed"
}
I am a newbie with Hasicorp Consul. I want to add to the Hashicorp Consul (v.1.7.1) watches config file the second service to be watched. How should it be done correctly?
I've tried several variants, but none of them is working. In this case it warks for service-2, but ignores service-1.
{
"watches": [{
"type": "service",
"service": "service-1",
"tag": [ "tag1","tag2","tag3"],
"args": ["./script.sh"],
"type": "service",
"service": "service-2",
"tag": [ "tag1","tag2","tag3"],
"args": ["./script.sh"]
}]
}
Watches is a list of watch specifications, so each individual watch needs to be a separate dict/hash item in the array.
The following config snippet should successfully fire a watch for each specified service.
{
"watches": [
{
"type": "service",
"service": "service-1",
"tag": [
"tag1",
"tag2",
"tag3"
],
"args": [
"./script.sh"
]
},
{
"type": "service",
"service": "service-2",
"tag": [
"tag1",
"tag2",
"tag3"
],
"args": [
"./script.sh"
]
}
]
}
i am wriiting an Azure ARM Template for deploying VNETs. Therefore i have a deployment file "VNET.json and a parameter file "VNET.parameter.json.
Now i want to hand over ONLY in the paramter File a variable but always got the error:
'The template variable 'IP' is not found. Please see https://aka.ms/arm-template/#variables for usage details.
or is it not "allowd" to use a variable in a parameter?
Here is my json file.
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"variables": {
"IP": "172.37.0.0/24"
},
"parameters": {
"VNetSettings":{
"value":{
"name":"ManagementNW",
"addressPrefixes": [
{
"name": "VPN",
"addressPrefix": "192.168.0.0/16"
},
{
"name": "Control",
"addressPrefix": "172.37.0.0/16"
},
{
"name": "Service",
"addressPrefix": "172.36.0.0/16"
},
{
"name": "DMZ",
"addressPrefix": "172.35.4.0/24"
}
],
"subnets":[
{
"name": "VPN-subnet",
"addressPrefix": "192.168.1.0/24"
},
{
"name": "Control-subnet",
"addressPrefix": "172.37.0.0/24"
},
{
"name": "Service-subnet",
"addressPrefix": "172.36.0.0/24"
},
{
"name": "DMZ-subnet",
"addressPrefix": "172.35.4.0/24"
},
{
"name": "Gateway-subnet",
"addressPrefix": "192.168.255.0/24"
},
{
"name":"AzureFirewall-subnet",
"addressPrefix":"192.168.254.0/24"
}
]
}
},
"Control-NSG-settings": {
"value": {
"securityRules": [
{
"direction": "Inbound",
"name": "VPNGW_to_Tableau_all",
"sourceAddressPrefix": "192.168.255.0/24",
"sourcePortRange": "*",
"destinationAddressPrefix": "172.37.0.41",
"destinationPortRange": "*",
"protocol": "*",
"access": "Allow",
"priority": 101,
"description": "allow RDP connections"
},
{
"direction": "Inbound",
"name": "VPNGW_to_Control_all",
"sourceAddressPrefix": "192.168.255.0/24",
"sourcePortRange": "*",
"destinationAddressPrefix": "[variables('IP')]",
"destinationPortRange": "*",
"protocol": "*",
"access": "deny",
"priority": 102,
"description": "deny"
},
KR
Marvin
In the template, you reference the value for the parameter by using the variables function.
In the ARM template json file, you use variables to simplify your template. Rather than repeating complicated expressions throughout your template, you define a variable that contains the complicated expression. However, if you only use once you do not need to use variables.
Also, as usrone said, your template looks suspicious. The normal template is as this one you could refer to.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "",
"apiProfile": "",
"parameters": { },
"variables": { },
"functions": [ ],
"resources": [ ],
"outputs": { }
}
I need to get the value of key in json from ansible play. Here is the issue is - Not sure the key will be in particular level of Json. It may vary from json to json. So, I need to 'serach' for the keys in json blindly and get the values for them [Not sure how many keys are avalible and how deep they are available]. Here I'm giving the sample json and play to achieve same.
JSON Data:
{
"status": "SUCCESS",
"errors": [
{
"jobname": "DbcAllJob_td_part_20190211150403_1",
"errorList": [
{
"id": "1",
"migrationId": "b9e19f6b-bc2e-4e2b-8fe9-20efb74d8289",
"jobId": "27",
"backupPhase": "DATA",
"restorePhase": "NULL",
"errorType": "ABORT",
"atTimeStamp": "2019/02/11 15:27:46",
"errorStatus": "UNRESOLVED",
"errorcode": "1148",
"errortext": "1148: DSA DSMAIN-BARNC Communication Exception: 1001:(**********K) recv() call has EOF",
"report": {
"root": {
"system": "TARGET",
"host": "**********",
"state_text": "2019/02/11 07:26:52.181 [ 27:29152:29152] ERROR Executor - Exception received by master thread: recv() call has EOF",
"entityId": "**********_clienthandler",
"logTime": "2019/02/11 07:26:52.181",
"peers": [
"**********_clienthandler"
],
"phase": "",
"rootError": "BarNC - User shutdown request from command line received, stopping BARNC",
"software": "clienthandler"
},
"sequence": [
{
"host": "sdt09586",
"state_text": "Feb 11 07:25:20 sdt09586 DSA[27578]: CRITICAL: DSA: 4751002 #CRITICAL: DataStreamController: 4751002 #DSC version[16.20.24.00], Commons version[16.20.24.00], DSC cannot connect to activeMQ Broker.",
"entityId": "sdt09586_messages",
"logTime": "2019/02/11 7:25:20.000",
"peers": [],
"phase": "",
"software": "messages"
},
{
"system": "SOURCE",
"host": "**********",
"state_text": "Feb 11 07:26:52 ********** Teradata[19593]: INFO: Teradata: 6670 # DSMAIN 1148: DSA DSMAIN-BARNC Communication Exception: 1001:(**********K) recv() call has EOF",
"entityId": "**********_messages",
"logTime": "2019/02/11 7:26:52.000",
"peers": [],
"phase": "",
"software": "messages"
},
{
"system": "SOURCE",
"host": "**********",
"state_text": "Feb 11 07:26:52 ********** Teradata[6369]: INFO: Teradata: 3265 #Transaction has been Aborted by Administrator or Operations Staff.",
"entityId": "**********_messages",
"logTime": "2019/02/11 7:26:52.000",
"peers": [],
"phase": "",
"software": "messages"
},
{
"system": "SOURCE",
"host": "**********",
"state_text": "2019/02/11 07:26:52.900 (134226672): Exception rethrown caught in DSMBackupTask::BeginWriteTask.",
"entityId": "27_**********_barlog_26623_34_3_3",
"logTime": "2019/02/11 07:26:52.900",
"peers": [
"AMP =1"
],
"phase": "",
"software": "barlog_26623_34_3_3"
},
{
"system": "SOURCE",
"host": "**********",
"state_text": "2019/02/11 07:26:52.900 (134226672): SendInternalAbort assumeMsgFromStpAab = 1",
"entityId": "27_**********_barlog_26623_34_3_3",
"logTime": "2019/02/11 07:26:52.900",
"peers": [
"AMP =1"
],
"phase": "",
"software": "barlog_26623_34_3_3"
},
{
"system": "SOURCE",
"host": "**********",
"state_text": "2019/02/11 07:26:52.900 (134226672): SendInternalAbort, partition = 34, jobId = 27",
"entityId": "27_**********_barlog_26623_34_3_3",
"logTime": "2019/02/11 07:26:52.900",
"peers": [
"AMP =1"
],
"phase": "",
"software": "barlog_26623_34_3_3"
},
{
"system": "SOURCE",
"host": "**********",
"state_text": "2019/02/11 07:26:52.900 (134226672): errorCode = 1148, errorTextLength = 84, errorText = 1148: DSA DSMAIN-BARNC Communication Exception: 1001:(**********K) recv() call has EOF",
"entityId": "27_**********_barlog_26623_34_3_3",
"logTime": "2019/02/11 07:26:52.900",
"peers": [
"AMP =1"
],
"phase": "",
"software": "barlog_26623_34_3_3"
},
{
"system": "SOURCE",
"host": "**********",
"state_text": "2019/02/11 07:26:52.910 (134254672): AbortTask has a message...",
"entityId": "27_**********_barlog_26623_34",
"logTime": "2019/02/11 07:26:52.910",
"peers": [],
"phase": "DATA/BUILD",
"software": "barlog_26623_34"
}
]
},
"remedy": [
{
"seqNum": 1,
"remedy": "Configure all machines to have same bynet configuration",
"remedyOpcode": "RECONFIGURE_BYNET",
"remedyInfo": [
{
"systemName": "**********",
"ipAddress": "**********",
"username": "**********",
"password": "**********",
"osUser": "root"
},
{
"systemName": "**********",
"ipAddress": "**********",
"username": "**********",
"password": "**********",
"osUser": "root"
}
]
},
{
"seqNum": 2,
"remedy": "Bring ClientHandler up on **********",
"remedyOpcode": "RESTART_SERVICE",
"remedyInfo": {
"systemName": "**********",
"ipAddress": "**********",
"username": "**********",
"password": "**********",
"osUser": "root"
}
},
{
"seqNum": 3,
"remedy": "Re-submit the job",
"remedyOpcode": "RESUBMIT",
"remedyInfo": null
}
],
"detailedreport": [
{
"component": "TPANode : **********",
"description": "TPANODE status : Up and Running",
"additionalProperties": {}
},
{
"component": "TPANode : **********",
"description": "TPANODE status : Up and Running",
"additionalProperties": {}
},
{
"component": "Bynet : [**********, **********]",
"description": "Bynet configuration mismatch",
"additionalProperties": {}
},
{
"component": "ClientHandler : **********",
"description": "ClientHandler status : not running",
"additionalProperties": {}
},
{
"component": "ActiveMQ : **********",
"description": "ActiveMQ status : running",
"additionalProperties": {}
},
{
"component": "ActiveMQ Queue: **********",
"description": "ActiveMQ message count : 13",
"additionalProperties": {}
},
{
"component": "DSC : **********",
"description": "DSC status : running, DSARest status : running",
"additionalProperties": {}
},
{
"component": "DSC Processes: **********",
"description": "Number of DSC processes running : 1",
"additionalProperties": {}
},
{
"component": "DSMAIN : **********",
"description": "DSMain status : Up and Running, Left over Processes : No left over processes",
"additionalProperties": {}
},
{
"component": "DSMAIN : **********",
"description": "DSMain status : Up and Running, Left over Processes : No left over processes",
"additionalProperties": {}
},
{
"component": "DatabaseConnection : **********",
"description": "Database status : UP",
"additionalProperties": {}
},
{
"component": "DatabaseConnection : **********",
"description": "Database status : UP",
"additionalProperties": {}
},
{
"component": "DatabaseConnection : **********",
"description": "Database status : UP",
"additionalProperties": {}
}
]
},
{
"id": "2",
"migrationId": "b9e19f6b-bc2e-4e2b-8fe9-20efb74d8289",
"jobId": "27",
"backupPhase": null,
"restorePhase": null,
"errorType": "ABORT",
"atTimeStamp": "",
"errorStatus": null,
"errorcode": "1160",
"errortext": "An error occurred restoring statistics.",
"report": {
"root": null,
"sequence": null
},
"remedy": [
{
"seqNum": -1,
"remedy": null,
"remedyOpcode": null,
"remedyInfo": null
}
],
"detailedreport": [
{
"component": null,
"description": null,
"additionalProperties": {}
}
]
}
]
}
]
}
From above json I need to read the 'remedy' values. But not sure at what level they are available always.
Here is the ansible script for the same.
---
- hosts: localhost
tasks:
- name: loop
set_fact:
migration_detail_status: "{{ lookup('file', 'inj_error.json') }}"
until: "'{{ migration_detail_status.errors.0.errorList.0.remedy.1.remedy | search('Bring ClientHandler up on') }}' and '{{ migration_detail_status.errors.0.errorList.0.remedy.1.remedyOpcode | search('RESTART_SERVICE') }}'"
retries: 2
delay: 5
ignore_errors: yes
- debug:
var: migration_detail_status.errors.0.errorList.0.remedy.1.remedyOpcode
At until condition I've traversed over json as I know the format of json. but, it may not be same for all the cases. So, please help to traverse to get the searching key:value from json irrespective of their level.
You can get a list of all remedy's with JMESPath query: errors[].errorList[].remedy[].remedy.
[
"Configure all machines to have same bynet configuration",
"Bring ClientHandler up on **********",
"Re-submit the job"
]
In Ansible you would use json_query filter to apply JMESPath queries.
If you also need opcodes: errors[].errorList[].remedy[].{r:remedy,o:remedyOpcode}
[
{
"r": "Configure all machines to have same bynet configuration",
"o": "RECONFIGURE_BYNET"
},
{
"r": "Bring ClientHandler up on **********",
"o": "RESTART_SERVICE"
},
{
"r": "Re-submit the job",
"o": "RESUBMIT"
},
{
"r": null,
"o": null
}
]
Example:
- debug:
msg: "{{ migration_detail_status | json_query('errors[].errorList[].remedy[].remedy') }}"
I need some help with formatting json data. I'm converting a table to json to be ingested into a log collector. The collector only likes json in single line format. How can I convert this json:
[
{ "Severity": "Informational",
"Type": "Milestone",
"SiteCode": "ABC",
"DateTime": 1505840220813,
"System": "Server.domain.local",
"Component": "SMS_Distribution_Point_Monitoring",
"Module": "SMS Server",
"MessageID": 2380,
"Description": "Start to evaluate package ABC001F5 on distribution point Display=\\\\Server.domain.local\\ MSWNET: SMS_SITE=ABC \\\\Server.domain.local\\."
},
{ "Severity": "Informational",
"Type": "Milestone",
"SiteCode": "ABC",
"DateTime": 1505840220787,
"System": "Server.domain.local",
"Component": "SMS_Distribution_Point_Monitoring",
"Module": "SMS Server",
"MessageID": 2384,
"Description": "Package ABC0019F on distribution point Display=\\\\Server.domain.local\\ MSWNET: SMS_SITE=ABC \\\\Server.domain.local\\ has been verified successfully."
}
]
to this in powershell when outputting to a file:
[{"Severity":"Informational","Type":"Milestone","SiteCode":"ABC","DateTime":1505840220813,"System":"Server.thecarlylegroup.local","Component":"SMS_Distribution_Point_Monitoring","Module":"SMSServer","MessageID":2380,"Description":"StarttoevaluatepackageABC001F5ondistributionpointDisplay=\\\\Server.thecarlylegroup.local\\MSWNET:SMS_SITE=ABC\\\\Server.thecarlylegroup.local\\."},
{"Severity":"Informational","Type":"Milestone","SiteCode":"ABC","DateTime":1505840220787,"System":"Server.thecarlylegroup.local","Component":"SMS_Distribution_Point_Monitoring","Module":"SMSServer","MessageID":2384,"Description":"PackageABC0019FondistributionpointDisplay=\\\\Server.thecarlylegroup.local\\MSWNET:SMS_SITE=ABC\\\\Server.thecarlylegroup.local\\hasbeenverifiedsuccessfully."}]
Assuming you get your data out of your table and into a string similar to the following:
$json = #"
[
{ "Severity": "Informational",
"Type": "Milestone",
"SiteCode": "ABC",
"DateTime": 1505840220813,
"System": "Server.domain.local",
"Component": "SMS_Distribution_Point_Monitoring",
"Module": "SMS Server",
"MessageID": 2380,
"Description": "Start to evaluate package ABC001F5 on distribution point Display=\\\\Server.domain.local\\ MSWNET: SMS_SITE=ABC \\\\Server.domain.local\\."
},
{ "Severity": "Informational",
"Type": "Milestone",
"SiteCode": "ABC",
"DateTime": 1505840220787,
"System": "Server.domain.local",
"Component": "SMS_Distribution_Point_Monitoring",
"Module": "SMS Server",
"MessageID": 2384,
"Description": "Package ABC0019F on distribution point Display=\\\\Server.domain.local\\ MSWNET: SMS_SITE=ABC \\\\Server.domain.local\\ has been verified successfully."
}
]
"#
Then you can do this (the depth was chosen arbitrarily to ensure that the entire object was converted):
$compressedJson = $json | ConvertFrom-Json | ConvertTo-Json -Compress -Depth 100
If you're working a string:
$var = (#"
[
{ "Severity": "Informational",
"Type": "Milestone",
"SiteCode": "ABC",
"DateTime": 1505840220813,
"System": "Server.domain.local",
"Component": "SMS_Distribution_Point_Monitoring",
"Module": "SMS Server",
"MessageID": 2380,
"Description": "Start to evaluate package ABC001F5 on distribution point Display=\\\\Server.domain.local\\ MSWNET: SMS_SITE=ABC \\\\Server.domain.local\\."
},
{ "Severity": "Informational",
"Type": "Milestone",
"SiteCode": "ABC",
"DateTime": 1505840220787,
"System": "Server.domain.local",
"Component": "SMS_Distribution_Point_Monitoring",
"Module": "SMS Server",
"MessageID": 2384,
"Description": "Package ABC0019F on distribution point Display=\\\\Server.domain.local\\ MSWNET: SMS_SITE=ABC \\\\Server.domain.local\\ has been verified successfully."
}
]
"# -split "`n" | % { $_.Trim() }) -join ''