From 6a2fa1750bbeaf69f35227feb104d07e2d61e247 Mon Sep 17 00:00:00 2001 From: David Barroso Date: Thu, 1 Oct 2015 12:40:41 +0200 Subject: [PATCH] Added get_facts --- ansible/napalm_get_facts | 66 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 ansible/napalm_get_facts diff --git a/ansible/napalm_get_facts b/ansible/napalm_get_facts new file mode 100644 index 0000000..3f5933b --- /dev/null +++ b/ansible/napalm_get_facts @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright 2014 Spotify AB. All rights reserved. +# +# The contents of this file are licensed under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + + +""" +""" + +import ast +import logging + +logger = logging.getLogger('eos_install_config') + +DOCUMENTATION = ''' +''' + +EXAMPLES = ''' +''' + + +def main(): + module = AnsibleModule( + argument_spec=dict( + hostname=dict(required=True), + username=dict(required=True), + password=dict(required=True), + dev_os=dict(required=True), + ), + supports_check_mode=True + ) + + hostname = module.params['hostname'] + username = module.params['username'] + dev_os = module.params['dev_os'] + password = module.params['password'] + + + network_driver = get_network_driver(dev_os) + + device = network_driver(hostname, username, password) + device.open() + + facts = device.get_facts() + facts['interface_details'] = device.get_interfaces() + + device.close() + + module.exit_json(ansible_facts=facts) + +from ansible.module_utils.basic import * +from napalm import get_network_driver + +main()