PEP8 compliance
This commit is contained in:
parent
37249ee7fa
commit
a70b44e30b
@ -39,13 +39,13 @@ LOGGING = {
|
||||
'null': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'django.utils.log.NullHandler',
|
||||
},
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'django.db.backends': {
|
||||
'handlers': ['null'],
|
||||
'propagate': False,
|
||||
},
|
||||
},
|
||||
'horizon': {
|
||||
'handlers': ['null'],
|
||||
'propagate': False,
|
||||
|
@ -74,9 +74,11 @@ def services_create(request, datacenter, parameters):
|
||||
|
||||
return res
|
||||
|
||||
|
||||
def get_time(obj):
|
||||
return obj.updated
|
||||
|
||||
|
||||
def services_list(request, datacenter_id):
|
||||
session_id = None
|
||||
sessions = windcclient(request).sessions.list(datacenter_id)
|
||||
@ -92,18 +94,18 @@ def services_list(request, datacenter_id):
|
||||
services = windcclient(request).activeDirectories.list(datacenter_id,
|
||||
session_id)
|
||||
services += windcclient(request).webServers.list(datacenter_id, session_id)
|
||||
|
||||
|
||||
|
||||
for i in range(len(services)):
|
||||
reports = windcclient(request).sessions.\
|
||||
reports(datacenter_id, session_id,
|
||||
services[i].id)
|
||||
reports = windcclient(request).sessions. \
|
||||
reports(datacenter_id, session_id,
|
||||
services[i].id)
|
||||
|
||||
for report in reports:
|
||||
services[i].operation = report.text
|
||||
|
||||
return services
|
||||
|
||||
|
||||
def get_active_directories(request, datacenter_id):
|
||||
session_id = None
|
||||
sessions = windcclient(request).sessions.list(datacenter_id)
|
||||
@ -121,14 +123,17 @@ def get_active_directories(request, datacenter_id):
|
||||
session_id)
|
||||
return services
|
||||
|
||||
|
||||
def services_get(request, datacenter_id, service_id):
|
||||
services = services_list(request, datacenter_id)
|
||||
|
||||
|
||||
for service in services:
|
||||
if service.id is service_id:
|
||||
service['operation'] = get_status_message_for_service(request, service_id)
|
||||
service['operation'] = get_status_message_for_service(request,
|
||||
service_id)
|
||||
return service
|
||||
|
||||
|
||||
def get_data_center_id_for_service(request, service_id):
|
||||
datacenters = datacenters_list(request)
|
||||
|
||||
@ -138,6 +143,7 @@ def get_data_center_id_for_service(request, service_id):
|
||||
if service.id == service_id:
|
||||
return dc.id
|
||||
|
||||
|
||||
def get_service_datails(request, service_id):
|
||||
datacenters = datacenters_list(request)
|
||||
services = []
|
||||
@ -148,6 +154,7 @@ def get_service_datails(request, service_id):
|
||||
if service.id == service_id:
|
||||
return service
|
||||
|
||||
|
||||
def get_status_message_for_service(request, service_id):
|
||||
environment_id = get_data_center_id_for_service(request, service_id)
|
||||
session_id = None
|
||||
@ -162,15 +169,16 @@ def get_status_message_for_service(request, service_id):
|
||||
if session_id is None:
|
||||
session_id = windcclient(request).sessions.configure(datacenter_id).id
|
||||
|
||||
reports = windcclient(request).sessions.\
|
||||
reports(environment_id, session_id, service_id)
|
||||
|
||||
reports = windcclient(request).sessions. \
|
||||
reports(environment_id, session_id, service_id)
|
||||
|
||||
result = 'Initialization.... \n'
|
||||
for report in reports:
|
||||
result += ' ' + str(report.text) + '\n'
|
||||
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def services_delete(request, datacenter_id, service_id):
|
||||
services = services_list(request, datacenter_id)
|
||||
|
||||
|
@ -30,13 +30,13 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PasswordField(forms.CharField):
|
||||
|
||||
# Setup the Field
|
||||
def __init__(self, label, *args, **kwargs):
|
||||
super(PasswordField, self).__init__(min_length=7, required=True,
|
||||
label=label,
|
||||
widget=forms.PasswordInput(render_value=False),
|
||||
*args, **kwargs)
|
||||
label=label,
|
||||
widget=forms.PasswordInput(
|
||||
render_value=False),
|
||||
*args, **kwargs)
|
||||
|
||||
def clean(self, value):
|
||||
|
||||
@ -75,8 +75,8 @@ class PasswordField(forms.CharField):
|
||||
class WizardFormServiceType(forms.Form):
|
||||
service = forms.ChoiceField(label=_('Service Type'),
|
||||
choices=[
|
||||
('Active Directory', 'Active Directory'),
|
||||
('IIS', 'Internet Information Services')
|
||||
('Active Directory', 'Active Directory'),
|
||||
('IIS', 'Internet Information Services')
|
||||
])
|
||||
|
||||
|
||||
@ -86,8 +86,6 @@ class WizardFormConfiguration(forms.Form):
|
||||
|
||||
|
||||
class WizardFormADConfiguration(forms.Form):
|
||||
|
||||
|
||||
dc_name = forms.CharField(label=_('Domain Name'),
|
||||
required=True)
|
||||
|
||||
@ -105,7 +103,6 @@ class WizardFormADConfiguration(forms.Form):
|
||||
super(WizardFormADConfiguration, self).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
|
||||
class WizardFormIISConfiguration(forms.Form):
|
||||
iis_name = forms.CharField(label=_('IIS Server Name'),
|
||||
required=True)
|
||||
@ -113,7 +110,7 @@ class WizardFormIISConfiguration(forms.Form):
|
||||
adm_password = PasswordField(_('Administrator password'))
|
||||
|
||||
iis_domain = forms.ChoiceField(label=_('Member of the Domain'),
|
||||
required=False)
|
||||
required=False)
|
||||
|
||||
def __init__(self, request, *args, **kwargs):
|
||||
super(WizardFormIISConfiguration, self).__init__(*args, **kwargs)
|
||||
@ -124,6 +121,5 @@ class WizardFormIISConfiguration(forms.Form):
|
||||
domains = api.get_active_directories(request, datacenter_id)
|
||||
|
||||
self.fields['iis_domain'].choices = [("", "")] + \
|
||||
[(domain.name, domain.name)
|
||||
for domain in domains]
|
||||
|
||||
[(domain.name, domain.name)
|
||||
for domain in domains]
|
||||
|
@ -3,4 +3,4 @@ import horizon
|
||||
from panel import WinDC
|
||||
|
||||
project = horizon.get_dashboard('project')
|
||||
project.register(WinDC)
|
||||
project.register(WinDC)
|
||||
|
@ -17,28 +17,14 @@
|
||||
|
||||
# TO DO: clear extra modules
|
||||
|
||||
import re
|
||||
import logging
|
||||
|
||||
from django import shortcuts
|
||||
from django import template
|
||||
from django.core import urlresolvers
|
||||
from django.template.defaultfilters import title
|
||||
from django.utils.http import urlencode
|
||||
from django.utils.translation import string_concat, ugettext_lazy as _
|
||||
|
||||
from horizon.conf import HORIZON_CONFIG
|
||||
from horizon import exceptions
|
||||
import re
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from horizon import messages
|
||||
from horizon import tables
|
||||
from horizon.templatetags import sizeformat
|
||||
from horizon.utils.filters import replace_underscores
|
||||
|
||||
from tabula.windc import api
|
||||
|
||||
from openstack_dashboard.dashboards.project.access_and_security \
|
||||
.floating_ips.workflows import IPAssociationWorkflow
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -102,8 +88,8 @@ class DeleteService(tables.BatchAction):
|
||||
try:
|
||||
api.services_delete(request, datacenter_id, service_id)
|
||||
except:
|
||||
messages.error(request,
|
||||
_('Sorry, you can not delete this service right now.'))
|
||||
messages.error(request, _('Sorry, you can not delete this '
|
||||
'service right now.'))
|
||||
|
||||
|
||||
class DeployDataCenter(tables.BatchAction):
|
||||
@ -112,7 +98,7 @@ class DeployDataCenter(tables.BatchAction):
|
||||
action_past = _('Deploy')
|
||||
data_type_singular = _('Data Center')
|
||||
data_type_plural = _('Data Center')
|
||||
classes = ('btn-launch')
|
||||
classes = 'btn-launch'
|
||||
|
||||
def allowed(self, request, datum):
|
||||
return True
|
||||
@ -135,20 +121,20 @@ class UpdateDCRow(tables.Row):
|
||||
|
||||
def get_data(self, request, datacenter_id):
|
||||
return api.datacenters_get(request, datacenter_id)
|
||||
|
||||
|
||||
|
||||
|
||||
class UpdateServiceRow(tables.Row):
|
||||
ajax = True
|
||||
|
||||
def get_data(self, request, service_id):
|
||||
link = request.__dict__['META']['HTTP_REFERER']
|
||||
datacenter_id = re.search('windc/(\S+)', link).group(0)[6:-1]
|
||||
|
||||
|
||||
service = api.services_get(request, datacenter_id, service_id)
|
||||
if service:
|
||||
service['operation'] = api.\
|
||||
service['operation'] = api. \
|
||||
get_status_message_for_service(request, service_id)
|
||||
|
||||
|
||||
return service
|
||||
|
||||
|
||||
@ -161,14 +147,12 @@ STATUS_DISPLAY_CHOICES = (
|
||||
|
||||
|
||||
class WinDCTable(tables.DataTable):
|
||||
|
||||
STATUS_CHOICES = (
|
||||
(None, True),
|
||||
('Ready to deploy', True),
|
||||
('Active', True)
|
||||
)
|
||||
|
||||
|
||||
name = tables.Column('name',
|
||||
link=('horizon:project:windc:services'),
|
||||
verbose_name=_('Name'))
|
||||
@ -189,7 +173,6 @@ class WinDCTable(tables.DataTable):
|
||||
|
||||
|
||||
class WinServicesTable(tables.DataTable):
|
||||
|
||||
STATUS_CHOICES = (
|
||||
(None, True),
|
||||
('Ready to deploy', True),
|
||||
|
@ -25,11 +25,12 @@ from tabula.windc import api
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class OverviewTab(tabs.Tab):
|
||||
name = _("Service")
|
||||
slug = "_service"
|
||||
template_name = '_services.html'
|
||||
|
||||
|
||||
def get_context_data(self, request):
|
||||
data = self.tab_group.kwargs['service']
|
||||
|
||||
@ -38,14 +39,15 @@ class OverviewTab(tabs.Tab):
|
||||
"service_type": data.service_type,
|
||||
"service_domain": data.domain}
|
||||
|
||||
|
||||
class LogsTab(tabs.Tab):
|
||||
name = _("Logs")
|
||||
slug = "_logs"
|
||||
template_name = '_service_logs.html'
|
||||
|
||||
|
||||
def get_context_data(self, request):
|
||||
data = self.tab_group.kwargs['service']
|
||||
|
||||
|
||||
reports = api.get_status_message_for_service(request, data.id)
|
||||
|
||||
return {"reports": reports}
|
||||
|
@ -27,13 +27,15 @@ from .forms import WizardFormServiceType, WizardFormConfiguration
|
||||
VIEW_MOD = 'openstack_dashboard.dashboards.project.windc.views'
|
||||
|
||||
urlpatterns = patterns(VIEW_MOD,
|
||||
url(r'^$', IndexView.as_view(), name='index'),
|
||||
url(r'^create$',
|
||||
Wizard.as_view([WizardFormServiceType, WizardFormConfiguration]),
|
||||
name='create'),
|
||||
url(r'^create_dc$', CreateWinDCView.as_view(), name='create_dc'),
|
||||
url(r'^(?P<data_center_id>[^/]+)/$', WinServices.as_view(),
|
||||
name='services'),
|
||||
url(r'^(?P<service_id>[^/]+)/details$', DetailServiceView.as_view(),
|
||||
name='service_details')
|
||||
)
|
||||
url(r'^$', IndexView.as_view(), name='index'),
|
||||
url(r'^create$',
|
||||
Wizard.as_view([WizardFormServiceType,
|
||||
WizardFormConfiguration]),
|
||||
name='create'),
|
||||
url(r'^create_dc$', CreateWinDCView.as_view(),
|
||||
name='create_dc'),
|
||||
url(r'^(?P<data_center_id>[^/]+)/$',
|
||||
WinServices.as_view(), name='services'),
|
||||
url(r'^(?P<service_id>[^/]+)/details$',
|
||||
DetailServiceView.as_view(),
|
||||
name='service_details'))
|
||||
|
@ -24,16 +24,12 @@ Views for managing instances.
|
||||
import logging
|
||||
import re
|
||||
|
||||
from django import http
|
||||
from django import shortcuts
|
||||
from django.views import generic
|
||||
from django.core.urlresolvers import reverse, reverse_lazy
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.contrib.formtools.wizard.views import SessionWizardView
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
from horizon import tabs
|
||||
from horizon import tables
|
||||
from horizon import workflows
|
||||
@ -44,12 +40,12 @@ from tabula.windc import api
|
||||
from .tables import WinDCTable, WinServicesTable
|
||||
from .workflows import CreateWinDC
|
||||
from .tabs import WinServicesTabs
|
||||
from .forms import (WizardFormServiceType, WizardFormConfiguration,
|
||||
WizardFormADConfiguration, WizardFormIISConfiguration)
|
||||
from .forms import (WizardFormADConfiguration, WizardFormIISConfiguration)
|
||||
|
||||
from horizon import messages
|
||||
|
||||
from django.http import HttpResponseRedirect
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -59,12 +55,7 @@ class Wizard(ModalFormMixin, SessionWizardView, generic.FormView):
|
||||
def done(self, form_list, **kwargs):
|
||||
link = self.request.__dict__['META']['HTTP_REFERER']
|
||||
datacenter_id = re.search('windc/(\S+)', link).group(0)[6:-1]
|
||||
|
||||
LOG.critical("/////////////////////////////")
|
||||
LOG.critical(link)
|
||||
LOG.critical(datacenter_id)
|
||||
LOG.critical("/////////////////////////////")
|
||||
|
||||
|
||||
url = "/project/windc/%s/" % datacenter_id
|
||||
|
||||
service_type = form_list[0].data.get('0-service', '')
|
||||
@ -73,7 +64,7 @@ class Wizard(ModalFormMixin, SessionWizardView, generic.FormView):
|
||||
if service_type == 'Active Directory':
|
||||
parameters['configuration'] = 'standalone'
|
||||
parameters['name'] = str(data.get('1-dc_name', 'noname'))
|
||||
parameters['domain'] = parameters['name'] # Fix Me in orchestrator
|
||||
parameters['domain'] = parameters['name'] # Fix Me in orchestrator
|
||||
parameters['adminPassword'] = str(data.get('1-adm_password', ''))
|
||||
dc_count = int(data.get('1-dc_count', 1))
|
||||
recovery_password = str(data.get('1-recovery_password', ''))
|
||||
@ -82,9 +73,11 @@ class Wizard(ModalFormMixin, SessionWizardView, generic.FormView):
|
||||
'recoveryPassword': recovery_password,
|
||||
'location': 'west-dc'})
|
||||
for dc in range(dc_count - 1):
|
||||
parameters['units'].append({'isMaster': False,
|
||||
'recoveryPassword': recovery_password,
|
||||
'location': 'west-dc'})
|
||||
parameters['units'].append({
|
||||
'isMaster': False,
|
||||
'recoveryPassword': recovery_password,
|
||||
'location': 'west-dc'
|
||||
})
|
||||
|
||||
elif service_type == 'IIS':
|
||||
password = data.get('1-adm_password', '')
|
||||
@ -102,8 +95,8 @@ class Wizard(ModalFormMixin, SessionWizardView, generic.FormView):
|
||||
parameters['credentials'] = {'username': 'Administrator',
|
||||
'password': password}
|
||||
parameters['domain'] = str(domain)
|
||||
# 'username': str(dc_user),
|
||||
# 'password': str(dc_pass)}
|
||||
# 'username': str(dc_user),
|
||||
# 'password': str(dc_pass)}
|
||||
parameters['location'] = 'west-dc'
|
||||
|
||||
parameters['units'] = []
|
||||
@ -185,7 +178,7 @@ class WinServices(tables.DataTableView):
|
||||
class DetailServiceView(tabs.TabView):
|
||||
tab_group_class = WinServicesTabs
|
||||
template_name = 'service_details.html'
|
||||
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(DetailServiceView, self).get_context_data(**kwargs)
|
||||
context["service"] = self.get_data()
|
||||
@ -202,7 +195,7 @@ class DetailServiceView(tabs.TabView):
|
||||
exceptions.handle(self.request,
|
||||
_('Unable to retrieve details for '
|
||||
'service "%s".') % service_id,
|
||||
redirect=redirect)
|
||||
redirect=redirect)
|
||||
self._service = service
|
||||
return self._service
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user