Skip to content

Commit

Permalink
Merge pull request #111 from globocom/develop
Browse files Browse the repository at this point in the history
merge develop
  • Loading branch information
Laura authored Sep 18, 2020
2 parents 3a5d97d + f8c48ff commit 8ad9f46
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 22 deletions.
11 changes: 2 additions & 9 deletions CadVlan/Environment/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,6 @@ def __init__(self, env_logic, division_dc, group_l3, filters, ipv4, ipv6, envs,
),
error_messages=error_messages
)
# father_environment = forms.CharField(
# label=u'Father Environment',
# max_length=250,
# required=False,
# error_messages=error_messages,
# widget=forms.TextInput(
# attrs={'style': "width: 310px", 'autocomplete': "off"}
# )
# )

def clean_min_num_vlan_1(self):
max_num_vlan_1 = self.cleaned_data.get('max_num_vlan_1')
Expand Down Expand Up @@ -473,6 +464,8 @@ def __init__(self, net_type_list, *args, **kwargs):

def clean(self):

if self._errors:
return self._errors
if not self._errors:
ip_version = self.cleaned_data.get('ip_version', '')
prefix = int(self.cleaned_data.get('prefix', ''))
Expand Down
15 changes: 12 additions & 3 deletions CadVlan/Environment/views_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ def allocate_cidr(request, id_environment):
raise Exception("Escolha uma das opções abaixo.")

client.create_api_environment_cidr().post(cidr)
messages.add_message(request,
messages.SUCCESS,
environment_messages.get(
"success_configuration_insert"))

elif form.is_valid():
network = form.cleaned_data['network_validate']
Expand All @@ -404,11 +408,16 @@ def allocate_cidr(request, id_environment):
environment=int(id_environment))

client.create_api_environment_cidr().post([cidr])
messages.add_message(request,
messages.SUCCESS,
environment_messages.get(
"success_configuration_insert"))

messages.add_message(request,
messages.SUCCESS,
else:
messages.add_message(request,
messages.ERROR,
environment_messages.get(
"success_configuration_insert"))
"invalid_parameters"))

context["form"] = IpConfigForm(net_type_list)

Expand Down
36 changes: 28 additions & 8 deletions CadVlan/Rack/templates/datacenter/datacenter.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,45 @@ <h3 class="mbr-section-title display-2">Data Center</h3>
{% for dc in dc %}
<div class="form-group form-control-label">
<div class="table-responsive">
<table class="table table-hover accordion-toggle" data-toggle="collapse" data-target="#{{ dc.id }}">
<table class="table table-hover">
<thead>
<tr class="col-xs-12">
<td class="col-xs-12 col-md-8 text-xs-left">{{ dc.dcname }}</td>
<td class="col-xs-12 col-md-1 text-xs-left"></td>
<td class="col-xs-12 col-md-3 text-xs-left">{{ dc.address }}</td>
<td class="col-xs-12 col-md-9 text-xs-left accordion-toggle" data-toggle="collapse" data-target="#{{ dc.id }}">{{ dc.dcname }}</td>
<td class="col-xs-12 col-md-2 text-xs-left accordion-toggle" data-toggle="collapse" data-target="#{{ dc.id }}">{{ dc.address }}</td>
<td class="col-xs-12 col-md-1">
<a class="material-icons"
onclick="javascript:if(!confirm('Deseja remover este Datacenter?')){return false;}"
style="color:#0D84A5;font-size:15px;"
href="{% url datacenter.delete dc.id %}"
title="Deletar Datacenter">
delete
</a>
</td>
</tr>
</thead>
<tbody class="collapse" id="{{ dc.id }}">
{% for fabric in dc.fabric %}
<tr class="col-xs-12" onClick="event.stopPropagation();">
<td class="col-xs-12 col-md-1 text-xs-left"></td>
<td class="col-xs-12 col-md-8">{{ fabric.name }}</td>
<td class="col-xs-12 col-md-3">
<a class="material-icons" style="color:#0D84A5" href="{% url fabric fabric.id %}"
<td class="col-xs-12 col-md-2 text-xs-left"></td>
<td class="col-xs-12 col-md-6">{{ fabric.name }}</td>
<td class="col-xs-12 col-md-1">
<a class="material-icons"
style="color:#0D84A5;font-size:15px;"
href="{% url fabric fabric.id %}"
title="Editar este fabric">
edit
</a>
</td>
<td class="col-xs-12 col-md-1">
<a class="material-icons"
onclick="javascript:if(!confirm('Deseja remover este Fabric?')){return false;}"
style="color:#0D84A5;font-size:15px;"
href="{% url fabric.delete fabric.id %}"
title="Deletar este fabric">
delete
</a>
</td>
<td class="col-xs-12 col-md-2 text-xs-left"></td>
</tr>
{% endfor %}
</tbody>
Expand Down
33 changes: 32 additions & 1 deletion CadVlan/Rack/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,14 +757,14 @@ def deploy_rack_new (request, fabric_id, rack_id):
def datacenter(request):

try:
lists = dict()

auth = AuthSession(request.session)
client = auth.get_clientFactory()

dc = client.create_apirack().list()
dc_list = dc.get("dc")

lists = dict()
lists["dc"] = dc_list

except NetworkAPIClientError as e:
Expand Down Expand Up @@ -801,6 +801,22 @@ def new_datacenter(request):
return render_to_response(templates.DC_FORM, {'form': {}}, context_instance=RequestContext(request))


@log
@login_required
@has_perm([{"permission": EQUIPMENT_MANAGEMENT, "write": True}])
def remove_datacenter(request, dc_id):

auth = AuthSession(request.session)
client = auth.get_clientFactory()
try:
client.create_apirack().delete_datacenter(dc_id)
messages.add_message(request, messages.SUCCESS, "O datacenter foi removido com sucesso.")
except NetworkAPIClientError as e:
messages.add_message(request, messages.ERROR, "Não foi possivel remover o datacenter. Erro: %s" % e)
finally:
return HttpResponseRedirect(reverse("listdc"))


@log
@login_required
@csrf_protect
Expand Down Expand Up @@ -1568,3 +1584,18 @@ def fabric_bgp(request, fabric_id):
return render_to_response(templates.DCROOM_BGP_FORM, lists, context_instance=RequestContext(request))

return render_to_response(templates.DCROOM_BGP_FORM, lists, context_instance=RequestContext(request))

@log
@login_required
@has_perm([{"permission": EQUIPMENT_MANAGEMENT, "write": True}])
def remove_fabric(request, fabric_id):

auth = AuthSession(request.session)
client = auth.get_clientFactory()
try:
client.create_apirack().delete_fabric(fabric_id)
messages.add_message(request, messages.SUCCESS, "A sala do datacenter foi removida com sucesso.")
except NetworkAPIClientError as e:
messages.add_message(request, messages.ERROR, "Não foi possivel remover a sala de datacenter. Erro: %s" % e)
finally:
return HttpResponseRedirect(reverse("listdc"))
1 change: 1 addition & 0 deletions CadVlan/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
'invalid_prefix': u'O prefixo informado deve ser maior que o bloco da rede.',
'success_configuration_insert': u'Prefixo de ambiente incluído com sucesso.',
'success_configuration_remove': u'Prefixo de ambiente excluído com sucesso.',
'invalid_parameters': u'Parametros inválidos.',
}

equip_messages = {
Expand Down
2 changes: 2 additions & 0 deletions CadVlan/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,11 +834,13 @@
url('^rack/save/deploy[/]?$', 'rack_deploy', name='rack.deploy',),
url('^rack/deploy/(?P<fabric_id>\d+)/(?P<rack_id>\d+)[/]?$', 'deploy_rack_new', name='rack.deploy.new',),
url('^datacenter/cadastro[/]?$', 'new_datacenter', name='dc.cadastro',),
url('^datacenter/delete/(?P<dc_id>\d+)[/]?$', 'remove_datacenter', name='datacenter.delete', ),
url('^datacenter[/]?$', 'datacenter', name='listdc',),
url('^fabric/cadastro/(?P<dc_id>\d+)[/]?$', 'new_fabric', name='fabric.cadastro',),
url('^fabric/ambientes/(?P<fabric_id>\d+)[/]?$', 'fabric_ambiente', name='fabric.ambiente',),
url('^fabric/bgp/(?P<fabric_id>\d+)[/]?$', 'fabric_bgp', name='fabric.bgp',),
url('^fabric/(?P<fabric_id>\d+)[/]?$', 'fabric', name='fabric',),
url('^fabric/delete/(?P<fabric_id>\d+)[/]?$', 'remove_fabric', name='fabric.delete', ),
)


Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Django==1.4.15
GloboNetworkAPI==0.9.1
GloboNetworkAPI==0.9.2
py2-ipaddress==3.4.1
pycrypto==2.6
python-ldap==2.3.13
Expand Down

0 comments on commit 8ad9f46

Please sign in to comment.