Ejemplo n.º 1
0
 def test_playbook_apply_commit(self):
     self.mock_request().get.side_effect = self._mock_manager
     pbb = PlayBookInstanceBuilder(self.conn, 'automation-coredump-pb',
                                   'HbEZ-instance', 'Core')
     pbb.apply(commit=True)
     self.assertEqual(self.mock_request().mock_calls[9][0], 'post')
     self.assertEqual(self.mock_request().mock_calls[9][1][0],
                      'https://1.1.1.1:8080/api/v1/configuration')
Ejemplo n.º 2
0
 def test_playbook_instance_builder_with_no_variable(self):
     self.mock_request().get.side_effect = self._mock_manager
     pbb = PlayBookInstanceBuilder(self.conn, 'automation-coredump-pb',
                                   'HbEZ-instance', 'Core')
     pbb.apply()
     self.assertEqual(self.mock_request().mock_calls[5][0], 'put')
     self.assertEqual(self.mock_request().mock_calls[5][1][0],
                      'https://1.1.1.1:8080/api/v1/device-group/Core')
Ejemplo n.º 3
0
 def test_playbook_schema_setter(self):
     self.mock_request().get.side_effect = self._mock_manager
     pbb = PlayBookInstanceBuilder(
         self.conn,
         'forwarding-table-summary',
         'HbEZ-instance',
         'Core')
     with self.assertRaises(RuntimeError):
         pbb.playbook_schema = 30
Ejemplo n.º 4
0
 def test_playbook_apply_commit(self):
     self.mock_request().get.side_effect = self._mock_manager
     with patch('jnpr.healthbot.healthbot.HealthBotClient.config_url',
                new_callable=PropertyMock) as mock_cnf:
         mock_cnf.return_value = "https://1.1.1.1:8080/api/v1"
         pbb = PlayBookInstanceBuilder(self.conn, 'automation-coredump-pb',
                                       'HbEZ-instance', 'Core')
         pbb.apply(commit=True)
         self.assertEqual(self.mock_request().mock_calls[9][0], 'post')
         self.assertEqual(self.mock_request().mock_calls[9][1][0],
                          'https://1.1.1.1:8080/api/v1/configuration')
Ejemplo n.º 5
0
 def test_playbook_instance_builder_with_variable_per_device(self):
     self.mock_request().get.side_effect = self._mock_manager
     pbb = PlayBookInstanceBuilder(self.conn, 'forwarding-table-summary',
                                   'HbEZ-instance', 'Core')
     routesummary_fib_summary = pbb.rule_variables[
         "protocol.routesummary/check-fib-summary"]
     routesummary_fib_summary.route_count_threshold = 200
     routesummary_fib_summary.route_address_family = 'abc'
     pbb.apply(device_ids=['vmx'])
     self.assertEqual(self.mock_request().mock_calls[7][0], 'put')
     self.assertEqual(self.mock_request().mock_calls[7][1][0],
                      'https://1.1.1.1:8080/api/v1/device/vmx')
Ejemplo n.º 6
0
 def test_playbook_instance_builder_delete(self):
     self.mock_request().get.side_effect = self._mock_manager
     pbb = PlayBookInstanceBuilder(
         self.conn, 'automation-coredump-pb', 'HbEZ-instance',
         'Core')
     pbb.delete()
     self.assertEqual(self.mock_request().mock_calls[6][0], 'put')
     self.assertEqual(
         self.mock_request().mock_calls[6][1][0],
         'https://1.1.1.1:8080/api/v2/config/device/vmx')
     self.assertEqual(
         self.mock_request().mock_calls[10][1][0],
         'https://1.1.1.1:8080/api/v2/config/device-group/Core')
Ejemplo n.º 7
0
 def test_clear(self):
     self.mock_request().get.side_effect = self._mock_manager
     pbb = PlayBookInstanceBuilder(self.conn, 'forwarding-table-summary',
                                   'HbEZ-instance', 'Core')
     routesummary_fib_summary = pbb.rule_variables[
         "protocol.routesummary/check-fib-summary"]
     routesummary_fib_summary.route_count_threshold = 200
     routesummary_fib_summary.route_address_family = 'abc'
     pbb.clear()
     routesummary_fib_summary = pbb.rule_variables[
         "protocol.routesummary/check-fib-summary"]
     self.assertEqual(routesummary_fib_summary.route_count_threshold,
                      '10000')
Ejemplo n.º 8
0
 def test_playbook_instance_builder_with_non_existing_device(self):
     self.mock_request().get.side_effect = self._mock_manager
     pbb = PlayBookInstanceBuilder(self.conn, 'forwarding-table-summary',
                                   'HbEZ-instance', 'Core')
     routesummary_fib_summary = pbb.rule_variables[
         "protocol.routesummary/check-fib-summary"]
     routesummary_fib_summary.route_count_threshold = 200
     routesummary_fib_summary.route_address_family = 'abc'
     self.assertRaises(RuntimeError, pbb.apply, device_ids=['fake'])
Ejemplo n.º 9
0
 def test_playbook_instance_builder_with_no_device_group(self):
     from jnpr.healthbot.exception import NotFoundError
     self.mock_request().get.side_effect = self._mock_manager
     pbb = PlayBookInstanceBuilder(
         self.conn, 'automation-coredump-pb', 'xyz', 'real')
     self.assertRaises(NotFoundError, pbb.apply)