openstack horizon
play

OpenStack Horizon: Controlling the Cloud using Django David Lapsley - PowerPoint PPT Presentation

OpenStack Horizon: Controlling the Cloud using Django David Lapsley @devlaps, david.lapsley@metacloud.com August 21, 2014 OPENSTACK THAT JUST WORKS OpenStack Horizon in Action OPENSTACK THAT JUST WORKS Launching an Instance Admin Overview


  1. OpenStack Horizon: Controlling the Cloud using Django David Lapsley @devlaps, david.lapsley@metacloud.com August 21, 2014 OPENSTACK THAT JUST WORKS

  2. OpenStack Horizon in Action OPENSTACK THAT JUST WORKS

  3. Launching an Instance

  4. Admin Overview

  5. Project Overview

  6. Launching an Instance

  7. Launching an Instance

  8. Launching an Instance

  9. Launching an Instance

  10. Launching an Instance

  11. Launching an Instance

  12. OpenStack Clouds Architecture and Model OPENSTACK THAT JUST WORKS

  13. OpenStack Model http://docs.openstack.org/training-guides/content/module001-ch004-openstack-architecture.html http://docs.openstack.org/openstack-ops/content/example_architecture.html

  14. OpenStack Projects ● Nova (Compute) ● Nova (Network) ● VM Registration (Glance) ● Identity (Keystone) ● Object Storage (Swift) ● Block Storage (Cinder) ● Dashboard (Horizon)

  15. OpenStack Horizon Controlling the Cloud with Django OPENSTACK THAT JUST WORKS

  16. Horizon Overview ● Django-based application deployed via Apache and WSGI ● Provides access to OpenStack services ● Leverages existing technologies o Bootstrap, jQuery, Underscore.js, AngularJS, D3.js, Rickshaw, LESS CSS ● Extends Django to enhance extensibility

  17. Django Stack

  18. Horizon Stack

  19. Horizon UI Structure User Info Dashboard Projects Branding Panel Group Panel Panel Content Sidebar

  20. Admin Dashboard

  21. Admin Dashboard

  22. Project Dashboard

  23. Horizon CSS Structure

  24. OpenStack Horizon Panels and Features OPENSTACK THAT JUST WORKS

  25. Instance List

  26. Filtering

  27. Sorting

  28. Sorting

  29. Row Actions

  30. Table Actions

  31. Table Actions

  32. Table Actions

  33. Table Actions

  34. Instance Details

  35. Instance Details

  36. Instance Log

  37. Instance Console

  38. OpenStack Horizon Interesting Patterns OPENSTACK THAT JUST WORKS

  39. Dashboards & Panels ● Horizon provides a flexible framework for creating Dashboards and Panels ● Panels grouped into PanelGroups ● PanelGroups into Dashboards

  40. Dashboard App ● Dashboards created as Django Applications ● Dashboard modules partitioned into: o static o templates o python modules

  41. Directory Structure cloudopen/ __init__.py dashboard.py templates/ cloudopen/ static/ cloudopen/ css/ img/ js/

  42. settings.py INSTALLED_APPS = ( ... 'horizon', 'openstack_dashboard.dashboards.project', 'openstack_dashboard.dashboards.admin', 'openstack_dashboard.dashboards.metacloud', 'openstack_dashboard.dashboards.settings', 'openstack_dashboard.dashboards.cloudopen', ... )

  43. dashboard.py class BasePanelGroup(horizon.PanelGroup): slug = "overview" name = _("Overview") panels = ("hypervisors",) class CloudOpen(horizon.Dashboard): name = _("Linuxcon") slug = "linuxcon" panels = (BasePanelGroup,) default_panel = "hypervisors" roles = ("admin",) horizon.register(CloudOpen)

  44. CloudOpen Dashboard Dashboard PanelGroup

  45. View ¡Module ¡ ● View ¡module ¡,es ¡together ¡everything: ¡ o Tables, ¡Templates, ¡API ¡Calls ¡ ● Horizon ¡base ¡views: ¡ o APIView, ¡LoginView, ¡Mul,TableView, ¡ DataTableView, ¡MixedDataTableView, ¡ TabView, ¡TabbedTableView, ¡WorkflowView ¡

  46. views.py from horizon import tables class HypervisorsIndexView(tables.DataTableView): table_class = hv_tables.AdminHypervisorsTable template_name = ’cloudopen/hypervisors/index.html’ def get_data(self): hypervisors = [] states = {} hypervisors = api.nova.hypervisor_list(self.request) … return hypervisors

  47. Table ¡Module ¡ ● Table classes provide framework for tables: o consistent look and feel o configurable table_actions and row_actions o select/multi-select column o sorting o pagination ● Functionality is split server- and client-side

  48. tables.py class EnableAction(tables.BatchAction): … class DisableAction(tables.BatchAction): name = 'disable' classes = ('btn-danger',) def allowed(self, request, hv): return hv.service.get('status') == 'enabled' def action(self, request, obj_id): hv = api.nova.hypervisor_get(request, obj_id) host = getattr(hv, hv.NAME_ATTR) return api.nova.service_disable(request, host, 'nova-compute') def search_link(x): return '/admin/instances?q={0}'.format(x.hypervisor_hostname)

  49. tables.py class AdminHypervisorsTable(tables.DataTable): hypervisor_hostname = tables.Column( 'hypervisor_hostname', verbose_name=_('Hostname')) state = tables.Column( lambda hyp: hyp.service.get('state', _('UNKNOWN')).title(), verbose_name=_('State')) running_vms = tables.Column( 'running_vms', link=search_link, verbose_name=_('Instances')) ... class Meta: name = 'hypervisors' verbose_name = _('Hypervisors') row_actions = (EnableAction, DisableAction)

  50. Template ● Standard Django template format ● Typically leverage base horizon templates (e.g. base.html )

  51. index.html {% extends 'base.html' %} {% load i18n horizon humanize sizeformat %} {% block title %}{% trans 'Hypervisors' %}{% endblock %} {% block page_header %} {% include 'horizon/common/_page_header.html' with title=_('All Hypervisors') %} {% endblock page_header %} {% block main %} {{ table.render }} {% endblock %}

  52. URLs ¡Modules ¡ ● Provides ¡URL ¡to ¡View ¡mappings ¡

  53. index.html from django.conf.urls import patterns from django.conf.urls import url from openstack_dashboard.dashboards.cloudopen.hypervisors import views urlpatterns = patterns( 'openstack_dashboard.dashboards.cloudopen.hypervisors.views' url(r'^$', views.IndexView.as_view(), name='index'), )

  54. Completed Dashboard! Nav entries Panel rendering Column sorting Linking Row actions Data retrieval RPC

  55. Click through to Instances

  56. Authen,ca,on ¡ ● Keystone ¡manages ¡all ¡Authen,ca,on ¡for ¡ OpenStack ¡ ● To ¡access ¡an ¡OpenStack ¡service: ¡ o authen,cate ¡with ¡Keystone ¡and ¡obtain ¡a ¡ TOKEN ¡ o Use ¡TOKEN ¡for ¡transac,ons ¡with ¡Service ¡ ● Horizon ¡passes ¡all ¡Auth ¡requests ¡to ¡Keystone ¡

  57. backend.py class MetacloudKeystoneBackend(KeystoneBackend): def authenticate(self, request=None, username=None, password=None, user_domain_name=None, auth_url=None): keystone_client = get_keystone_client() client = keystone_client.Client( user_domain_name=user_domain_name, username=username, password=password, auth_url=auth_url, …) # auth_ref gets assigned here… … # If we made it here we succeeded. Create our User! user = create_user_from_token(request, Token(auth_ref)) request.user = user return user

  58. Customiza,on ¡Hooks ¡ ● Change ¡Site ¡Title, ¡Logo, ¡Brand ¡Links ¡ ● Modify ¡Dashboards ¡and ¡Panels ¡ ● Change ¡BuRon ¡Styles ¡ ● Use ¡Custom ¡Stylesheets ¡ ● Use ¡Custom ¡Javascript ¡

  59. Custom ¡Overrides ¡Module ¡ ● For ¡site-­‑wide ¡customiza,on, ¡Horizon ¡allows ¡for ¡a ¡ user-­‑defined ¡python ¡customiza,on ¡module ¡ ● Customiza,ons ¡can ¡include: ¡ o Registering/unregistering ¡panels ¡ o Modifying ¡dashboard ¡or ¡panel ¡aRributes ¡ o Moving ¡panels ¡between ¡dashboards ¡ o Modifying ¡aRributes ¡of ¡exis,ng ¡UI ¡elements ¡

  60. local_settings.py HORIZON_CONFIG = { ... 'customization_module': 'openstack_dashboard.dashboards.cloudopen.overrides', 'test_enabled': True, }

  61. overrides.py from openstack_dashboard.dashboards.cloudopen.test import panel\ as test_panel from openstack_dashboard.dashboards.cloudopen import dashboard \ as cloudopen_dashboard from django.conf import settings import horizon CLOUDOPEN_DASHBOARD_SETTINGS = horizon.get_dashboard('cloudopen') if settings.HORIZON_CONFIG.get('test_enabled'): CLOUDOPEN_DASHBOARD_SETTINGS .register(test_panel.Tests) cloudopen_dashboard.BasePanels.panels += ('ui', )

  62. Full CloudOpen Dashboard

  63. Test Panel

  64. Pluggable Settings ● Since Icehouse release, Horizon enables pluggable settings to control structure o Enable/Disable new Dashboards o Add new PanelGroups o Add/Remove Panels to/from PanelGroups ● Settings all live in: o openstack_dashboard/local/enabled

  65. Pluggable Settings _10_cloudopen.py _20_cloudopen_add_panel_group.py _30_tests_add_panel.py __init__.py

  66. Pluggable Settings _10_cloudopen.py DASHBOARD = 'cloudopen' DISABLED = False ADD_INSTALLED_APPS = [ 'openstack_dashboard.dashboards.cloudopen', ]

  67. Pluggable Settings _20_cloudopen_add_panel_group.py DASHBOARD = 'cloudopen' DISABLED = False ADD_INSTALLED_APPS = [ 'openstack_dashboard.dashboards.cloudopen', ]

  68. Pluggable Settings _30_tests_add_panel.py PANEL = 'test' PANEL_DASHBOARD = 'cloudopen' PANEL_GROUP = 'tests' ADD_PANEL = \ 'openstack_dashboard.dashboards.cloudopen.test.panel.Tests'

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend