Skip to content

Commit

Permalink
Merge pull request #114 from globocom/develop
Browse files Browse the repository at this point in the history
split foreman and spn/oob deploy
  • Loading branch information
Laura authored Oct 28, 2020
2 parents 8ad9f46 + b731832 commit f4549e4
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
27 changes: 26 additions & 1 deletion CadVlan/Rack/templates/datacenter/fabric.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
{% extends "menu.html" %}
{% block header %}
<script type="text/javascript">

$(document).ready(function() {

var obj_btn_sav = $("#btn_deploy");

obj_btn_sav.click(function () {
if (confirm('Confirme o deploy nos Switchs de Produção.')) {
}
});
});
</script>
{% endblock %}
{% block content %}
<section class="mbr-section mbr-after-navbar" id="form1-5" style="background-color: rgb(255, 255, 255); padding-top: 120px; padding-bottom: 120px;">
<div class="mbr-section mbr-section__container mbr-section__container--middle">
Expand Down Expand Up @@ -135,8 +149,19 @@ <h1 class="mbr-section-title display-3 text-xs-center">
<td class="col-xs-12 col-md-1" style="padding: 1px 1px">
<a class="btn btn-social-bottom btn-responsive"
style="vertical-align: bottom;"
href="{% url rack.deploy.new rack.dcroom rack.id %}"
href="{% url rack.foreman.new rack.dcroom rack.id %}"
title="Integração com o Foreman">
<i class="material-icons" style="color:#FFD17C;font-size:15px">
engineering
</i>
</a>
</td>
<td class="col-xs-12 col-md-1" style="padding: 1px 1px">
<a class="btn btn-social-bottom btn-responsive"
id="btn_deploy"
style="vertical-align: bottom;"
href="{% url rack.deploy.new rack.dcroom rack.id %}"
title="Deploy de configuração nos Switchs">
<i class="material-icons" style="color:#FFD17C;font-size:15px">
launch
</i>
Expand Down
17 changes: 17 additions & 0 deletions CadVlan/Rack/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,23 @@ def deploy_rack_new (request, fabric_id, rack_id):
return HttpResponseRedirect(reverse('fabric', args=[fabric_id]))


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


auth = AuthSession(request.session)
client = auth.get_clientFactory()
try:
client.create_apirack().rack_foreman(rack_id)
messages.add_message(request, messages.SUCCESS, rack_messages.get("sucess_aplicar_config"))
except NetworkAPIClientError as e:
messages.add_message(request, messages.ERROR, "Erro ao registrar no Foremanr. Erro: %s" % e)

return HttpResponseRedirect(reverse('fabric', args=[fabric_id]))


@log
@login_required
@csrf_protect
Expand Down
1 change: 1 addition & 0 deletions CadVlan/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
'can_not_aplicar_config': u'A configuracao não pode ser aplicada nos equipamentos do rack.',
'sucess_alocar_config': u'Os ambientes, vlans e redes do rack %s foram alocadas com sucesso.',
'can_not_alocar_config': u'Os ambientes, vlans e redes do rack %s não puderam ser alocadas.',
'sucess-foreman': u'O ambiente foi registrado no Foreman.'
}

equip_access_messages = {
Expand Down
1 change: 1 addition & 0 deletions CadVlan/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@
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', ),
url('^rack/foreman/(?P<fabric_id>\d+)/(?P<rack_id>\d+)[/]?$', 'rack_foreman', name='rack.foreman.new', ),
)


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.2
GloboNetworkAPI==0.9.3
py2-ipaddress==3.4.1
pycrypto==2.6
python-ldap==2.3.13
Expand Down

0 comments on commit f4549e4

Please sign in to comment.