* Added new images

* Fixes on Dashboard (advanced new sidevar disposition)
* Added Proxy element to DB (needs to finish this)
This commit is contained in:
Adolfo Gómez García 2017-01-20 04:58:05 +01:00
parent d3417a1c79
commit d1f4ce0884
15 changed files with 142 additions and 11 deletions

View File

@ -33,7 +33,7 @@
from __future__ import unicode_literals
from django.utils.translation import ugettext, ugettext_lazy as _
from uds.models import DeployedService, OSManager, Service, Image, ServicesPoolGroup, Account
from uds.models import DeployedService, OSManager, Service, Image, ServicesPoolGroup, Account, Proxy
from uds.models.CalendarAction import CALENDAR_ACTION_INITIAL, CALENDAR_ACTION_MAX, CALENDAR_ACTION_CACHE_L1, CALENDAR_ACTION_CACHE_L2, CALENDAR_ACTION_PUBLISH
from uds.core.ui.images import DEFAULT_THUMB_BASE64
from uds.core.util.State import State
@ -77,6 +77,7 @@ class ServicesPools(ModelHandler):
'osmanager_id',
'image_id',
'account_id',
'proxy_id',
'servicesPoolGroup_id',
'initial_srvs',
'cache_l1_srvs',
@ -131,11 +132,13 @@ class ServicesPools(ModelHandler):
'state': state,
'thumb': item.image.thumb64 if item.image is not None else DEFAULT_THUMB_BASE64,
'account': item.account.name if item.account is not None else '',
'proxy': item.proxy.name if item.proxy is not None else '',
'service_id': item.service.uuid,
'provider_id': item.service.provider.uuid,
'image_id': item.image.uuid if item.image is not None else None,
'servicesPoolGroup_id': poolGroupId,
'account_id': item.account.uuid if item.account is not None else None,
'proxy_id': item.proxy.uuid if item.proxy is not None else None,
'pool_group_name': poolGroupName,
'pool_group_thumb': poolGroupThumb,
'initial_srvs': item.initial_srvs,
@ -247,7 +250,17 @@ class ServicesPools(ModelHandler):
'tooltip': ugettext('If active, alternative transports for user will be shown'),
'type': gui.InputField.CHECKBOX_TYPE,
'order': 120,
}]:
}, {
'name': 'proxy_id',
'values': [gui.choiceItem(-1, '')] + gui.sortedChoices([gui.choiceItem(v.uuid, v.name) for v in Proxy.objects.all()]),
'label': ugettext('Proxy'),
'tooltip': ugettext('Proxy for services behind a firewall'),
'type': gui.InputField.CHOICE_TYPE,
'tab': ugettext('Connectivity'),
'order': 130,
},
]:
self.addField(g, f)
return g
@ -294,6 +307,7 @@ class ServicesPools(ModelHandler):
fields['max_srvs'] = max((int(fields['initial_srvs']), int(fields['cache_l1_srvs']), int(fields['max_srvs'])))
# *** ACCOUNT ***
accountId = fields['account_id']
fields['account_id'] = None
logger.debug('Account id: {}'.format(accountId))
@ -304,7 +318,19 @@ class ServicesPools(ModelHandler):
except Exception:
logger.exception('Getting account ID')
# *** PROXY ***
proxyId = fields['proxy_id']
fields['proxy_id'] = None
logger.debug('Proxy id: {}'.format(proxyId))
if proxyId != '-1':
try:
fields['proxy_id'] = Proxy.objects.get(uuid=processUuid(proxyId)).id
except Exception:
logger.exception('Getting proxy ID')
# **** IMAGE ***
imgId = fields['image_id']
fields['image_id'] = None
logger.debug('Image id: {}'.format(imgId))

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-01-17 08:45
# Generated by Django 1.10.5 on 2017-01-20 04:13
from __future__ import unicode_literals
import datetime
@ -45,6 +45,22 @@ class Migration(migrations.Migration):
'db_table': 'uds_acc_usage',
},
),
migrations.CreateModel(
name='Proxy',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('uuid', models.CharField(default=None, max_length=50, null=True, unique=True)),
('name', models.CharField(db_index=True, max_length=128)),
('comments', models.CharField(max_length=256)),
('host', models.CharField(max_length=256)),
('port', models.PositiveIntegerField(default=9090)),
('ssl', models.BooleanField(default=True)),
('tags', models.ManyToManyField(to='uds.Tag')),
],
options={
'db_table': 'uds_proxies',
},
),
migrations.AddField(
model_name='ticketstore',
name='owner',
@ -55,4 +71,9 @@ class Migration(migrations.Migration):
name='account',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='servicesPools', to='uds.Account'),
),
migrations.AddField(
model_name='deployedservice',
name='proxy',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='servicesPools', to='uds.Proxy'),
),
]

View File

@ -0,0 +1,67 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2012 Virtual Cable S.L.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
'''
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
'''
from __future__ import unicode_literals
__updated__ = '2017-01-20'
from django.db import models
from uds.models.UUIDModel import UUIDModel
from uds.models.Tag import TaggingMixin
from uds.models.Util import getSqlDatetime
from django.db.models import signals
import logging
logger = logging.getLogger(__name__)
class Proxy(UUIDModel, TaggingMixin):
'''
Proxy DB model
'''
name = models.CharField(max_length=128, unique=False, db_index=True)
comments = models.CharField(max_length=256)
host = models.CharField(max_length=256)
port = models.PositiveIntegerField(default=9090)
ssl = models.BooleanField(default=True)
class Meta:
'''
Meta class to declare the name of the table at database
'''
db_table = 'uds_proxies'
app_label = 'uds'
def __unicode__(self):
return 'Proxy {} on {}:{} '.format(self.name, self.host, self.port)

View File

@ -52,6 +52,7 @@ from uds.models.Image import Image
from uds.models.ServicesPoolGroup import ServicesPoolGroup
from uds.models.Calendar import Calendar
from uds.models.Account import Account
from uds.models.Proxy import Proxy
from uds.models.Util import NEVER
from uds.models.Util import getSqlDatetime
@ -62,7 +63,7 @@ from datetime import datetime, timedelta
import logging
import pickle
__updated__ = '2016-09-16'
__updated__ = '2017-01-20'
logger = logging.getLogger(__name__)
@ -94,6 +95,8 @@ class DeployedService(UUIDModel, TaggingMixin):
# Usage accounting
account = models.ForeignKey(Account, null=True, blank=True, related_name='servicesPools')
# Proxy for this pool
proxy = models.ForeignKey(Proxy, null=True, blank=True, related_name='servicesPools')
initial_srvs = models.PositiveIntegerField(default=0)
cache_l1_srvs = models.PositiveIntegerField(default=0)

View File

@ -106,13 +106,16 @@ from .CalendarAction import CalendarAction
from .Account import Account
from .AccountUsage import AccountUsage
# Proxies
from .Proxy import Proxy
# Tagging
from .Tag import Tag
# Utility
from .DBFile import DBFile
__updated__ = '2016-09-16'
__updated__ = '2017-01-20'
logger = logging.getLogger(__name__)

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 652 B

After

Width:  |  Height:  |  Size: 710 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 934 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -22,11 +22,18 @@
<li><a class="lnk-service_providers" href="#"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/providers.png"/> <span class="menu-lnk">{% trans 'Services' %}</span></a></li>
<li><a class="lnk-authenticators" href="#"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/authenticators.png"/> <span class="menu-lnk">{% trans 'Authenticators' %}</span></a></li>
<li><a class="lnk-osmanagers" href="#"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/osmanagers.png"/> <span class="menu-lnk">Os Managers</span></a></li>
<li><a class="lnk-connectivity" href="#"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/transports.png"/> <span class="menu-lnk">{% trans 'Connectivity' %}</span></a></li>
<li><a class="lnk-deployed_services" href=""><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/pools.png"/> <span class="menu-lnk">{% trans 'Pools' %}</span></a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/connectivity.png"/> <span class="menu-lnk">{% trans 'Connectivity' %} <b class="caret"></b></span></a>
<ul class="dropdown-menu">
<li><a class="lnk-connectivity" href="#"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/transports.png"/> <span class="menu-lnk">{% trans 'Transports' %}</span></a></li>
<li><a class="lnk-connectivity" href="#"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/proxy.png"/> <span class="menu-lnk">{% trans 'Proxies' %}</span></a></li>
</ul>
</li>
<li><a class="lnk-deployed_services" href=""><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/pools.png"/> <span class="menu-lnk">{% trans 'Service Pools' %}</span></a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/pools.png"/> <span class="menu-lnk">{% trans 'Service Pools' %} <b class="caret"></b></span></a>
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/miscellaneous.png"/> <span class="menu-lnk">{% trans 'Pools Config' %} <b class="caret"></b></span></a>
<ul class="dropdown-menu">
{% if admin %}
<li><a class="lnk-spoolsgroup" href="#"><img class="icon" src="{{ STATIC_URL }}/adm/img/icons/groups.png"/> <span class="menu-lnk">{% trans 'Groups' %}</span></a></li>

View File

@ -248,7 +248,7 @@ body {
> li > a {
color: inherit;
padding: $font-size-base/2;
padding: $font-size-base/2 $font-size-base/2 $font-size-base/2 32px;
&:hover, &.active, &:focus {
color: #fff;

2
server/templates/admin/copy.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
cp dist/css/main.css ../../src/uds/static/adm/css/uds.css

View File

@ -111,13 +111,15 @@ func proxyRequest(w http.ResponseWriter, r *http.Request) {
client := &http.Client{
Timeout: time.Duration(5) * time.Second,
}
resp, err := client.Do(req)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, "Error in POST: %s", err)
return
}
defer resp.Body.Close()
defer resp.Body.Close() // Ensures closes response
w.WriteHeader(resp.StatusCode)
b, _ := ioutil.ReadAll(resp.Body)
w.Write(b)