Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Thiago_Kobayash
Explorer

R80 API - set static route

Hi,


I've been working with R80' API with Python rest calls. I'm trying to configure static routes via API. I didn't find any api call related to routes, so I guess the only way is using the "run-script" and "put-file".

I've sucessfully used the put-file to upload the script to the host. But whenever i use the run-script to run the script, i get:


statusCode: "failed"

statusDescription: Permission denied


Does anyone know how to fix this?


Thanks

0 Kudos
7 Replies
PhoneBoy
Admin
Admin

You probably have to make the script executable (e.g. with chmod) before you can execute it.

0 Kudos
Ofir_Shikolski
Employee Alumnus
Employee Alumnus

please see this one:

Can we get the routes from R80? 

This command will run in "BASH" mode 

for clish mode is needed to run clish command .

 

 

1. login


2. run-script

{
"script-name" : "show routes",
"script" : "netstat -nr",
"targets" : [ "mgmt" ]
}

 

Results:
{
"tasks": [
{
"target": "mgmt",
"task-id": "b3ee3851-8c50-47e7-96a5-5b897538bab9"
}
]
}

 

3. show-task

{
"task-id" : "b3ee3851-8c50-47e7-96a5-5b897538bab9" , 
"details-level" : "full"
}

 

Results:

{
"tasks": [
{
"uid": "690c8f82-d1d1-4060-96ea-86a99950cfe0",
"name": "mgmt - show routes",
"type": "CdmTaskNotification",
"domain": {
"uid": "41e821a0-3720-11e3-aa6e-0800200c9fde",
"name": "SMC User",
"domain-type": "domain"
},
"task-id": "b3ee3851-8c50-47e7-96a5-5b897538bab9",
"task-name": "mgmt - show routes",
"status": "succeeded",
"progress-percentage": 100,
"start-time": {
"posix": 1501670168404,
"iso-8601": "2017-08-02T13:36+0300"
},
"last-update-time": {
"posix": 1501670170686,
"iso-8601": "2017-08-02T13:36+0300"
},
"suppressed": false,
"task-details": [
{
"uid": "aa1e472e-9a7c-47e1-891a-a060e3b4262a",
"name": null,
"domain": {
"uid": "41e821a0-3720-11e3-aa6e-0800200c9fde",
"name": "SMC User",
"domain-type": "domain"
},
"color": "black",
"statusCode": "succeeded",
"statusDescription": "Kernel IP routing table, Destination Gateway Genmask Flags MSS Window irtt Iface, 1.1.1.0 0.0.0.0 255.255.255.254 U 0 0 0 eth0.3, 10.0.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0, 0.0....",
"taskNotification": "690c8f82-d1d1-4060-96ea-86a99950cfe0",
"gatewayId": "37308a02-7395-0a43-9765-562fabbd76c2",
"gatewayName": "",
"transactionId": 235893072,
"responseMessage": "S2VybmVsIElQIHJvdXRpbmcgdGFibGUKRGVzdGluYXRpb24gICAgIEdhdGV3YXkgICAgICAgICBHZW5tYXNrICAgICAgICAgRmxhZ3MgICBNU1MgV2luZG93ICBpcnR0IElmYWNlCjEuMS4xLjAgICAgICAgICAwLjAuMC4wICAgICAgICAgMjU1LjI1NS4yNTUuMjU0IFUgICAgICAgICAwIDAgICAgICAgICAgMCBldGgwLjMKMTAuMC4wLjAgICAgICAgIDAuMC4wLjAgICAgICAgICAyNTUuMjU1LjAuMCAgICAgVSAgICAgICAgIDAgMCAgICAgICAgICAwIGV0aDAKMC4wLjAuMCAgICAgICAgIDEwLjAuMC4xICAgICAgICAwLjAuMC4wICAgICAgICAgVUcgICAgICAgIDAgMCAgICAgICAgICAwIGV0aDAK",
"responseError": "",
"meta-info": {
"validation-state": "ok",
"last-modify-time": {
"posix": 1501670170723,
"iso-8601": "2017-08-02T13:36+0300"
},
"last-modifier": "admin",
"creation-time": {
"posix": 1501670168688,
"iso-8601": "2017-08-02T13:36+0300"
},
"creator": "admin"
},
"tags": [],
"icon": "General/globalsNa",
"comments": "",
"display-name": "",
"customFields": null
}
],
"comments": "Completed",
"color": "black",
"icon": "General/globalsNa",
"tags": [],
"meta-info": {
"lock": "unlocked",
"validation-state": "ok",
"last-modify-time": {
"posix": 1501670170705,
"iso-8601": "2017-08-02T13:36+0300"
},
"last-modifier": "admin",
"creation-time": {
"posix": 1501670168440,
"iso-8601": "2017-08-02T13:36+0300"
},
"creator": "admin"
},
"read-only": false
}
]
}

4. base64 for "responseMessage"

https://www.base64decode.org/

 

Results:

 

Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
1.1.1.0 0.0.0.0 255.255.255.254 U 0 0 0 eth0.3
10.0.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 10.0.0.1 0.0.0.0 UG 0 0 0 eth0

0 Kudos
Thiago_Kobayash
Explorer

Ofir Sh,

Is it possible to run a configure command directly on "run-script"? I've been trying to configure the static route with something like:

{
"script-name" : "set static route",
"script" : "set static-route 10.10.10.0/24 nexthop gateway logical eth0 priority 1 on",
"targets" : [ "mgmt" ]
}

Then, I get this response:

"tasks": [
    {
      "color": "black",
      "comments": "Completed",
      "domain": {
        "domain-type": "domain",
        "name": "SMC User",
        "uid": "41e821a0-3720-11e3-aa6e-0800200c9fde"
      },
      "icon": "General/globalsNa",
      "last-update-time": {
        "iso-8601": "2017-09-11T07:35-0300",
        "posix": 1505126105056
      },
      "meta-info": {
        "creation-time": {
          "iso-8601": "2017-09-11T07:35-0300",
          "posix": 1505126104780
        },
        "creator": "f9329156",
        "last-modifier": "f9329156",
        "last-modify-time": {
          "iso-8601": "2017-09-11T07:35-0300",
          "posix": 1505126105080
        },
        "lock": "unlocked",
        "validation-state": "ok"
      },
      "name": "px10mancp001 - fileTeste",
      "progress-percentage": 100,
      "read-only": true,
      "start-time": {
        "iso-8601": "2017-09-11T07:35-0300",
        "posix": 1505126104733
      },
      "status": "succeeded",
      "suppressed": false,
      "tags": [],
      "task-details": [
        {
          "color": "black",
          "comments": "",
          "display-name": "",
          "domain": {
            "domain-type": "domain",
            "name": "SMC User",
            "uid": "41e821a0-3720-11e3-aa6e-0800200c9fde"
          },
          "gatewayId": "f37f7517-67e3-cb45-b825-31696de67a52",
          "gatewayName": "",
          "icon": "General/globalsNa",
          "meta-info": {
            "creation-time": {
              "iso-8601": "2017-09-11T07:35-0300",
              "posix": 1505126104806
            },
            "creator": "f9329156",
            "last-modifier": "f9329156",
            "last-modify-time": {
              "iso-8601": "2017-09-11T07:35-0300",
              "posix": 1505126105098
            },
            "validation-state": "ok"
          },
          "responseError": "",
          "responseMessage": "",
          "statusCode": "succeeded",
          "statusDescription": "",
          "tags": [],
          "taskNotification": "d0ad36bc-4644-48c9-b7ff-bad68161088a",
          "transactionId": 629377159,
          "uid": "0339ffd5-1a0e-4099-8166-97dab194e66b"
        }
      ],
      "task-id": "6e181a03-e15e-4297-8348-8b1457b0d4cb",
      "task-name": "px10mancp001 - fileTeste",
      "type": "CdmTaskNotification",
      "uid": "d0ad36bc-4644-48c9-b7ff-bad68161088a"
    }
  ]

But the route is not configured at all.

0 Kudos
PhoneBoy
Admin
Admin

Try clish -c "set static-route 10.10.10.0/24 nexthop gateway logical eth0 priority 1 on" instead

Thiago_Kobayash
Explorer

Dameon,

I works!.  Thanks for help

0 Kudos
Hugo_vd_Kooij
Advisor

Keep in mind that any script is run as BASH script. So you need to switch to CLISH manually.

For a oneliner the suggestion above is fine.

I was thinking about a multi line example but that needs some more testing as I am not getting the right responses yet.

<< We make miracles happen while you wait. The impossible jobs take just a wee bit longer. >>
0 Kudos
Hugo_vd_Kooij
Advisor

The sample script below shows you multiple CLISH commands.

clish << EndOfCommands
show interfaces
show interface eth0
show interface eth1
show interface eth3
show route
exit
EndOfCommands

  1. The "EndOfCommands" string at the beginning and end must match exactly.
  2. The exit command as the last valid clish command. Or you end up with a clish procress on your firewall that goes beserk. (Very funny in a lab but not something you want in real life.)

Enjoy.

<< We make miracles happen while you wait. The impossible jobs take just a wee bit longer. >>

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events