Программируемость aci. Примеры применения
TRANSCRIPT
Программируемость ACI. Примеры применения. Хаванкин Максим cистемный архитектор, CCIE [email protected]
18 июня 2015
Cisco Confidential 2 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
§ Какие бывают API? § API инспектор
§ ACI toolkit
§ vCenter plugin, как пример использования APIC API
Содержание
Cisco Confidential 3 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
Cisco Confidential 4 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
API на уровне устройства • NETCONF • REST • JSON-RPC
Высокоуровневые абстракции и DevOps • Puppet • Chef • Openstack
Новые инструменты для настройки сетевых устройств
Cisco Confidential 5 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
REST
Cisco Confidential 6 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
REST использует знакомую модель
HTTP GET
HTML
Описывает как данные отображаются пользователю
HTTP GET
JSON/XML
Описывают данные в формате, который понятен приложению
{"ids":[303776224, 19449911, 607032789, 86544242, 2506725913, 17631389], "next_cursor":0, "next_cursor_str":"0", "previous_cursor":0, "previous_cursor_str":"0"}
Web серфинг REST API Twitter: IDs of last five followers
Cisco Confidential 7 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
REST= REpresentational State Transfer
Предложен Roy Fielding в 2000 году
Разработан W3C параллельно с HTTP 1.1
REST больше похож на архитектурный стиль (не протокол)
Простой набор операций CRUD при помощи HTTP
Клиент-серверная модель без сохранения состояния
Использование URI для идентификации операции
CRUD = Create Read Update Delete
Cisco Confidential 8 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
JSON-RPC
Cisco Confidential 9 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
JSON-RPC: выглядит как REST, но немного по другому
Cisco Confidential 10 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
Одинако: оба пересылают/принимают JSON поверх HTTP
REST (CSR 1000v) JSON-RPC (N9K NX-API)
Cisco Confidential 11 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
REST: много ресурсов
• https://172.6.1.118/api/v1… …/global/banner …/global/hostname …/global/reload …/interfaces/… …/routing-svc/… …/nat-svc/… …/acl/… …
JSON-RPC: мало ресурсов
• https://10.10.10.8/ins
Разное: Ресурсы (URI)
CSR1kV N9K
Cisco Confidential 12 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
REST: стандартные HTTP методы
• GET: Retrieve/List • PUT: Replace • POST: Create New Entry • DELETE: Delete
JSON-RPC: POST + body method
Разное: методы
Cisco Confidential 13 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
Cisco Confidential 14 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
• Действия в GUI превращаются в примеры API вызовов, которые нужно осуществить, чтобы получить такой же результат
• Postman (плагин для Chrome) • Poster (плагин для Firefox)
“API инспектор”
Cisco Confidential 15 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
Cisco Confidential 16 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
Программируемость и ACI
ACI предоставляет:
• REST API
• Полностью открытая модель объектов
• Доступ при помощи JSON или XML
• Python SDK для доступа к объектам
Но….
• Существенные затраты на обучение • 5000+ классов • Новые концепции
16
Cisco Confidential 17 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
Cisco Confidential 18 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
Почему появился ACI Toolkit?
• Снижение входного барьера
• Адресовать 80% сценариев использования
• Дать примеры скриптов конечным Заказчикам
• Ускорить процесс перехода на ACI
18
Cisco Confidential 19 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
Инфраструктура как код!
https://github.com/datacenter/acitoolkit http://datacenter.github.io/acitoolkit/
19
Cisco ACI Toolkit
Cisco Confidential 20 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
ACI Toolkit CLI интерфейс: network, security, cloud, application
APIC
ACI Toolkit
NX-OS like CLI
Custom Python Scripts
• Основан на открытых APIC API • Скрипты, написаны при помощи Toolkit просто создавать и редактировать
• Пока нет полной функциональности, наиболее часто используемые операции
• Фокус в основном на конфигурацию
Cisco Confidential 21 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
Tenant
Context / VRF
Subnet
Bridge Domain
Outside EPG
EPG
App. Profile
Taboo
Contract
Filter Entry
L3 Interface
L2 Interface
Interface
Node
Link
POD
1
* * 1 * * 1
1
* *
* * *
*
Provide / Consume
1
* *
*
*
*
1 1
* *
1
*
Provide / Consume
*
*
1
1
* 1
1
1 1
1
1 * 1 *
1
2
1
*
1
*
1
*
Network Physical Policy ACI Toolkit Модель политик
Jan/2015
Cisco Confidential 22 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
Скрипты
Очень просто начать процесс разработки и отладки
Cisco Confidential 23 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
Приложение «CLI»
• Эмуляция NX-OS CLI полностью написаная на Python
• Использует возможности toolkit
• Знакомый интерфейс для сетевого инженера
• Фокус на задачах поддержки • show epg • shutdown / no shutdown на interface
Cisco Confidential 24 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
§ Switch to a tenant configuration mode (ala VDC) § fabric# switchto tenant <tenant-name>
§ fabric-tenant# switchback
§ Create a Context and don't enforce contracts on it
§ fabric-tenant(config)# [no] context <context-name>
§ fabric-tenant(config-ctx)# [no] allow-all
Example of CLI Commands (1)
Cisco Confidential 25 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
§ Create a bridge domain and assign it to a context § fabric-tenant(config)# [no] bridgedomain <bd-name>
§ fabric-tenant(config-bd)# [no] context <context-name>
§ Create a subnet under the bridge domain
§ fabric-tenant(config-bd)# [no] ip address <ip-address>/<masklength> [ name <subnet-name> ]
Example of CLI commands (2)
Cisco Confidential 26 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
Приложение «Cable Plan»
• Дает возможность импортировать существующий кабельный план : • XML файла • APIC
• Выполнить экспорт и сравнение загруженных ранее кабельных планов
• Advanced use can build cable plan XML file, query, and modify cable plan
26
Cisco Confidential 27 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
Приложение «ACI Endpoint Tracker»
• Отслеживает подключение и историю перемещений оконечных
• Сохраняет данные в open source MySQL Database, давая возможность выполнять собственные запросы
• Основа для средств визуализации
• Помогает ответить на следующие вопросв: • Какие Endpoint подключены к сети? • Куда подключен определенный Endpoint? • Кто был подключен в прошлый Четверг между
3:30am и 4:00am? • История перемещения определенного
Endpoint? 27
Cisco Confidential 28 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
Cisco Confidential 29 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
VMware vCenter Plugin View
29
Cisco Confidential 30 © 2013-2014 Cisco and/or its affiliates. All rights reserved.
VMware vCenter Plugin View
30
Спасибо!