Junos Cup 2014
Highlighted
Junos Cup 2014

Tournament 3: Costa Rica Challenge & Solution: The Remote Task Execution

[ Edited ]
‎06-26-2014 07:26 AM

Country Flag: COSTA RICA

 

Author: Antonio Sánchez-Monge

 

Title: The Remote Task Execution

 

Type: Automation

 

Difficulty: Medium (1 point).

 

Technical Description:  Complete the development of an Op Script, that when launched from H will clear the OSPF adjacencies of R1.

 

Topology:

 

Costa-Rica-Topology

 

Challenge Instructions:

For this challenge, you need to start the topology called: “COSTA RICA – The Remote Task Execution”.

 

In this topology, H has an Op Script that should be connecting to R1 and clear the OSPF adjacencies of R1. However, it’s not working as expected. You should fix the script, with the following conditions:

 

- You should not change any device configuration

- You need to execute show ospf neighbor detail at R1 in order to make sure that the script triggers OSPF adjacency flaps.

 

TIP: You can edit the script as follows:

 

juniper@H> start shell user root

Password:

root@H% cd /var/db/scripts/op

root@H% vi <the-script-file-name>

--- Make your changes, save with escape :wq!

root@H% cli

root@H> op remote-executor host 10.0.0.1

 

There are two different flavors of the final script, and you are allowed to achieve either of them.

 

[Option 1 - Interactive] The script manually prompts for RSA key installation, and for the password:

 

juniper@H> op remote-executor host 10.0.0.1

The authenticity of host '10.0.0.1' can't be established.

RSA key fingerprint is <fingerprint>.

Are you sure you want to continue connecting (yes/no)? yes

juniper@10.0.0.1's password:

 

Connecting to 10.0.0.1 in order to clear its OSPF adjacencies

 

[Option 2 – Non-Interactive] The script relies on the RSA key being already installed, and does not prompt for a password. Prior to the first execution of the script, you are allowed to manually install the RSA key as follows:

 

 

juniper@H> ssh 10.0.0.1

The authenticity of host '10.0.0.1 (10.0.0.1)' can't be established.

ECDSA key fingerprint is e9:c8:a0:ba:20:03:0e:ba:0c:09:cc:46:80:b5:a3:f4.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '10.0.0.1' (ECDSA) to the list of known hosts.

Welcome to the cloud

password is Clouds

juniper@10.0.0.1's password:

 

--- TYPE ctrl-C here ---

 

 

juniper@H> op remote-executor host 10.0.0.1

 

Connecting to 10.0.0.1 in order to clear its OSPF adjacencies

 

NOTE: The Junos release running in the VM is affected by the following PR:

 

jcsSmiley Surprisedpen() only prompts for host key approval when the password is not provided

 

That’s why you need to preinstall the RSA key as described above for Option 2.

 

To solve this challenge submit either Option 1 or 2 scripts.  If you submit both correctly, you earn an extra point.

 

 

NOTE: If you have issues connecting to the Junosphere topology please check Junosphere Technical documentation, or request assistance in the Junosphere forum 

Send an email with your proposed solution to junos-cup@juniper.net:

  •  The subject should be “<country-name-of-the-challenge> -  <your-full-name>”. For example: “Brazil – Wolfgang Amadeus Mozart”.
  • In the email body, please include your proposed solution, along with your first and last name and complete mailing address including zip/postal code and your shirt size (S, M, L, XL, XXL, XXXL) (Only if you haven’t already submitted your address/shirt size on a previous submission)

 

Deadline to Respond: Tuesday, 1st of July 23:59:59 Pacific Daylight Time (PDT) 

Timezone Converter
Current PDT Time


Some additional notes:

  • You can try to solve and submit answers for as many active challenges as you wish
  • The answers will be read by the organization right after the deadline
  • The challenge instructions are final, and no additional information or tips will be provided before the publication of the solution and the winner list. Please don’t expect a reply from junos-cup@juniper.net.
  • If you feel that your initial solution is wrong or incomplete, you can send up to three messages for the same challenge, but please note that only your last message (received before the deadline) will be read.
  • If you think there is an error in the definition of the challenges, please send us an email with subject (“<country-name> ERROR”); if there is no reply, then it’s likely an intentional condition of the challenge, rather than an error.

 

OFFICIAL SOLUTIONS:

 

[Option 1 - Interactive]

 

match / {

  <op-script-results> {

 

    var $options := {

        <method> "junoscript";

        <username> "juniper";

    }

 

    var $cmd = <clear-ospf-neighbor-information>;

    var $con = jcsSmiley Surprisedpen($host, $options);

 

    <output> "Connecting to " _ $host _ " in order to clear its OSPF adjacencies";

    var $out = jcs:execute($con, $cmd);

 

  }

}

 

[Option 2 – Non-Interactive]

 

The same as above, just adding the password to the options:

 

    var $options := {

        <method> "junoscript";

        <username> "juniper";

        <password> "Clouds";

    }

 

Julie Wider
Advocacy Manager
Twitter: @JNetCommunity & @jawider