Added progress bar to Web UI. Fixed pep8 errors.

This commit is contained in:
Timur Nurlygayanov 2013-03-12 19:18:08 +04:00
parent a93f6f9fbd
commit bb7c3577dc
6 changed files with 139 additions and 92 deletions

View File

@ -51,43 +51,66 @@ def datacenters_get(request, datacenter_id):
def datacenters_list(request):
return windcclient(request).environments.list()
def datacenters_deploy(request, datacenter_id):
session_id = windcclient(request).sessions.list(datacenter_id)[0].id
sessions = windcclient(request).sessions.list(datacenter_id)
for session in sessions:
if session.state == 'open':
session_id = session.id
if not session_id:
return "Sorry, nothing to deploy."
return windcclient(request).sessions.deploy(datacenter_id, session_id)
def services_create(request, datacenter, parameters):
LOG.critical("////////////////////////////////")
LOG.critical(parameters)
LOG.critical("////////////////////////////////")
session_id = windcclient(request).sessions.list(datacenter)[0].id
if parameters['service_type'] == 'active directory':
res = windcclient(request).activeDirectories.create(datacenter, session_id, parameters)
def datacenters_get_status(request, datacenter_id):
sessions = windcclient(request).sessions.list(datacenter_id)
for session in sessions:
if session.state == 'deployed':
windcclient(request).sessions.delete(datacenter_id, session.id)
sessions = windcclient(request).sessions.list(datacenter_id)
if sessions:
session = sessions[0]
else:
res = windcclient(request).webServers.create(datacenter, session_id, parameters)
session = windcclient(request).sessions.configure(datacenter_id)
return session.state
def services_create(request, datacenter, parameters):
session_id = windcclient(request).sessions.list(datacenter)[0].id
if parameters['service_type'] == 'Active Directory':
res = windcclient(request).activeDirectories.create(datacenter,
session_id,
parameters)
else:
res = windcclient(request).webServers.create(datacenter,
session_id,
parameters)
return res
def services_list(request, datacenter_id):
session_id = request.user.token.token['id']
services = []
session_id = None
sessions = windcclient(request).sessions.list(datacenter_id)
for s in sessions:
if s.state == 'open':
windcclient(request).sessions.delete(datacenter_id, s.id)
session_id = windcclient(request).sessions.configure(datacenter_id).id
services = windcclient(request).activeDirectories.list(datacenter_id, session_id)
if s.state in ['open', 'deployed', 'deploying']:
session_id = s.id
if session_id is None:
session_id = windcclient(request).sessions.configure(datacenter_id).id
services = windcclient(request).activeDirectories.list(datacenter_id,
session_id)
services += windcclient(request).webServers.list(datacenter_id, session_id)
return services
def services_get(request, datacenter, service_id):
LOG.critical("********************************")
LOG.debug(parameters)
LOG.critical("********************************")
return windcclient(request).services.get(datacenter, service_id)

View File

@ -38,9 +38,9 @@ LOG = logging.getLogger(__name__)
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')
])
class WizardFormConfiguration(forms.Form):
@ -59,34 +59,32 @@ class WizardFormADConfiguration(forms.Form):
initial=1)
adm_password = forms.CharField(widget=forms.PasswordInput,
label=_("Administrator password"), required=False)
label=_("Administrator password"),
required=False)
recovery_password = forms.CharField(widget=forms.PasswordInput,
label=_("Recovery password"), required=False)
label=_("Recovery password"),
required=False)
class WizardFormIISConfiguration(forms.Form):
iis_name = forms.CharField(label=_("IIS Server Name"),
required=False)
adm_password = forms.CharField(widget=forms.PasswordInput,
label=_("Administrator password"), required=False)
iis_count = forms.IntegerField(label=_("IIS Servers Count"),
required=True,
min_value=1,
max_value=100,
initial=1)
adm_password = forms.CharField(widget=forms.PasswordInput,
label=_("Administrator password"),
required=False)
iis_domain = forms.CharField(label=_("Member of the Domain"),
required=False)
domain_user_name = forms.CharField(label=_("Domain User Name"),
required=False)
domain_user_password = forms.CharField(widget=forms.PasswordInput,
label=_("Domain User Password"), required=False)
label=_("Domain User Password"),
required=False)
class UpdateWinDC(forms.SelfHandlingForm):
tenant_id = forms.CharField(widget=forms.HiddenInput)

View File

@ -102,8 +102,8 @@ class DeleteService(tables.BatchAction):
##############
api.windc.services_delete(request, datacenter_id, service_id)
class DeployDataCenter(tables.BatchAction):
name = "deploy"
action_present = _("Deploy")
@ -143,53 +143,62 @@ class ShowDataCenterServices(tables.LinkAction):
class UpdateRow(tables.Row):
ajax = True
def get_data(self, request, instance_id):
instance = api.nova.server_get(request, instance_id)
instance.full_flavor = api.nova.flavor_get(request,
instance.flavor["id"])
return instance
def get_data(self, request, datacenter_id):
datacenter = api.windc.datacenters_get(request, datacenter_id)
datacenter.status = api.windc.datacenters_get_status(request,
datacenter_id)
return datacenter
STATUS_DISPLAY_CHOICES = (
('deploying', 'Deploy in progress'),
('open', 'Ready to deploy')
)
def get_datacenter_status(datacenter):
return datacenter.status
class WinDCTable(tables.DataTable):
STATUS_CHOICES = (
(None, True),
("Ready to deploy", False),
("deploying", True),
("deployed", True),
("ready", True),
("error", False),
)
name = tables.Column("name",
link=("horizon:project:windc:services"),
verbose_name=_("Name"))
status = tables.Column(get_datacenter_status, verbose_name=_('Status'),
status=True,
status_choices=STATUS_CHOICES,
display_choices=STATUS_DISPLAY_CHOICES)
class Meta:
name = "windc"
verbose_name = _("Windows Data Centers")
row_class = UpdateRow
table_actions = (CreateDataCenter,)
status_columns = ['status']
row_actions = (ShowDataCenterServices, DeleteDataCenter,
DeployDataCenter)
STATUS_DISPLAY_CHOICES = (
("create", "Deploy"),
)
class WinServicesTable(tables.DataTable):
STATUS_CHOICES = (
(None, True),
("deployed", True),
("active", True),
("error", False),
)
name = tables.Column('dc_name', verbose_name=_('Name'),
name = tables.Column('name', verbose_name=_('Name'),
link=("horizon:project:windc:service_details"),)
_type = tables.Column('type', verbose_name=_('Type'))
status = tables.Column('status', verbose_name=_('Status'),
status=True,
status_choices=STATUS_CHOICES,
display_choices=STATUS_DISPLAY_CHOICES)
_type = tables.Column('service_type', verbose_name=_('Type'))
class Meta:
name = "services"
verbose_name = _("Services")
row_class = UpdateRow
status_columns = ['status']
table_actions = (CreateService,)
row_actions = (EditService, DeleteService)

View File

@ -27,15 +27,14 @@
</div>
<div class="right">
{% if wizard.steps.prev %}
{% if service_type == 'active directory' %}
<H3>Active Directory Service</H3>
<H3>{{ service_type }} Service</H3>
{% if service_type == 'Active Directory' %}
<p>{% trans "Now you can set the parameters for Active Directory Service." %}</p>
<p>{% trans "You can create few Active Directory instances, in this case will be created one Main Active Directory server and few Secondary Active Directory servers." %}</p>
<p>{% trans "The DNS service will be automatically created on each Active Directory servers." %}</p>
{% else %}
<H3>Internet Information Services</H3>
<p>{% trans "Now you can set parameters for IIS Service." %}</p>
<p>{% trans "The IIS Service - it is the server with complex IIS infrastructure, which included to the domain infrasructure." %}</p>
<p>{% trans "The IIS Service - it is the server with complex Internet Information Services infrastructure, which included to the domain infrasructure." %}</p>
<p>{% trans "Please, set the complex password for local administrator account." %}</p>
<p>{% trans "Also, you can add this IIS server to the existing domain and configure credentials for domain user." %}</p>
{% endif %}

View File

@ -28,7 +28,7 @@ VIEW_MOD = 'openstack_dashboard.dashboards.project.windc.views'
urlpatterns = patterns(VIEW_MOD,
url(r'^$', IndexView.as_view(), name='index'),
url(r'^create$',
url(r'^create$',
Wizard.as_view([WizardFormServiceType, WizardFormConfiguration]),
name='create'),
url(r'^create_dc$', CreateWinDCView.as_view(), name='create_dc'),

View File

@ -58,35 +58,50 @@ class Wizard(ModalFormMixin, SessionWizardView, generic.FormView):
link = self.request.__dict__['META']['HTTP_REFERER']
datacenter_id = re.search('windc/(\S+)', link).group(0)[6:-1]
url = "/project/windc/%s/" % datacenter_id
service_type = form_list[0].data.get('0-service', '')
parameters = {'service_type': service_type}
if service_type == 'active directory':
if service_type == 'Active Directory':
parameters['configuration'] = 'standalone'
parameters['name'] = str(form_list[1].data.get('1-dc_name', 'noname'))
parameters['adminPassword'] = str(form_list[1].data.get('1-adm_password', ''))
parameters['name'] = str(form_list[1].data.get('1-dc_name',
'noname'))
parameters['adminPassword'] = \
str(form_list[1].data.get('1-adm_password', ''))
dc_count = int(form_list[1].data.get('1-dc_count', 1))
recovery_password = str(form_list[1].data.get('1-recovery_password', ''))
recovery_password = \
str(form_list[1].data.get('1-recovery_password', ''))
parameters['units'] = []
parameters['units'].append({'isMaster': True, 'recoveryPassword': recovery_password,
parameters['units'].append({'isMaster': True,
'recoveryPassword': recovery_password,
'location': 'west-dc'})
for dc in range(dc_count-1):
parameters['units'].append({'isMaster': False, 'recoveryPassword': recovery_password,
'location': 'west-dc'})
elif service_type == 'iis':
parameters['name'] = str(form_list[1].data.get('1-iis_name', 'noname'))
for dc in range(dc_count - 1):
parameters['units'].append({'isMaster': False,
'recoveryPassword': recovery_password,
'location': 'west-dc'})
elif service_type == 'IIS':
password = form_list[1].data.get('1-adm_password', '')
domain = form_list[1].data.get('1-iis_domain', '')
dc_user = form_list[1].data.get('1-domain_user_name', '')
dc_pass = form_list[1].data.get('1-domain_user_password', '')
parameters['name'] = str(form_list[1].data.get('1-iis_name',
'noname'))
parameters['credentials'] = {'username': 'Administrator',
'password': str(form_list[1].data.get('1-adm_password', ''))}
parameters['domain'] = {'name': str(form_list[1].data.get('1-iis_domain', '')),
'username': str(form_list[1].data.get('1-domain_user_name', '')),
'password': str(form_list[1].data.get('1-domain_user_password', ''))}
'password': password}
parameters['domain'] = {'name': str(domain),
'username': str(dc_user),
'password': str(dc_pass)}
parameters['location'] = 'west-dc'
parameters['units'] = []
parameters['units'].append({'id': '1',
'endpoint': [{'host': '10.0.0.1'}],
'location': 'west-dc'})
service = api.windc.services_create(self.request,
datacenter_id,
parameters)
parameters)
message = "The %s service successfully created." % service_type
messages.success(self.request, message)
@ -98,17 +113,17 @@ class Wizard(ModalFormMixin, SessionWizardView, generic.FormView):
if data:
service_type = data.get('0-service', '')
self.service_type = service_type
if service_type == 'active directory':
if service_type == 'Active Directory':
self.form_list['1'] = WizardFormADConfiguration
elif service_type == 'iis':
elif service_type == 'IIS':
self.form_list['1'] = WizardFormIISConfiguration
return form
def get_form_step_data(self, form):
LOG.debug(form.data)
return form.data
def get_context_data(self, form, **kwargs):
context = super(Wizard, self).get_context_data(form=form, **kwargs)
if self.steps.index > 0:
@ -121,9 +136,12 @@ class IndexView(tables.DataTableView):
template_name = 'project/windc/index.html'
def get_data(self):
# Gather our datacenters
try:
data_centers = api.windc.datacenters_list(self.request)
for dc in data_centers:
# get the information about session status for each dc
dc.status = api.windc.datacenters_get_status(self.request,
dc.id)
except:
data_centers = []
exceptions.handle(self.request,