반응형
1. [Cloud] Openstack - Caracal 구축 개요
2. [Cloud] Openstack - 1-1. Controller Node (Preprocess, Environment, Keystone, Glance)
3. [Cloud] Openstack - 1-2. Controller Node (Placement, Nova, Neutron)
4. [Cloud] Openstack - 1-3. Controller Node (Cinder, Swift)
5. [Cloud] Openstack - 1-4. Controller Node (Horizon)
6. [Cloud] Openstack - 2. Compute Node
7. [Cloud] Openstack - 3. Block Node
8. [Cloud] Openstack - 4. Horizon Dashboard Console 개선 ←
위와 같이 콘솔 접속이 안된다. 이유는 호스트 주소가 controller라서 외부에서는 접속을 할 수 없다.
- 하지만 저 부분을 192.168.0.6과 같은 외부에서 접속할 수 있는 주소로 변경하면 된다.(물론 포트가 동일하다면)
해결 방안 적용
_detail_console.html을 수정하여 아예 변경된 주소로 제공하도록 변경
vi /usr/share/openstack-dashboard/openstack_dashboard/dashboards/project/instances/templates/instances/_detail_console.html
{% load i18n %}
<h3>{% trans "Instance Console" %}</h3>
{% if console_url %}
<p class='alert alert-info'>
{% if console_type != 'SERIAL' %}
{% blocktrans %}If console is not responding to keyboard input: click the grey status bar below.{% endblocktrans %}
{% endif %}
<a href="{{ console_url }}" style="text-decoration: underline">{% trans "Click here to show only console" %}</a><br />
{% trans "To exit the fullscreen mode, click the browser's back button." %}</p>
<iframe id="console_embed" src="{{ console_url }}" style="width:100%;height:100%"></iframe>
<script type="text/javascript">
var hostname = window.location.hostname;
var console_href_src = document.getElementById('console_embed').src;
var console_href_dst = "http://"+hostname+":6080/vnc_auto.html"+console_href_src.split('vnc_auto.html')[1];
document.getElementById('console_embed').src = console_href_dst;
var fix_height = function() {
$('iframe#console_embed').css({ height: $(document).height() + 'px' });
};
// there are two code paths to this particular block; handle them both
if (typeof($) != 'undefin ed') {
$(document).ready(fix_height);
} else {
addHorizonLoadEvent(fix_height);
}
</script>
{% else %}
<script type="text/javascript">
horizon.toast.add('error', '{% blocktrans %}Console is currently unavailable.{% endblocktrans %}');
</script>
<div class="well">{% blocktrans %}Unable to load console. Please reload page to try again.{% endblocktrans %}</div>
{% endif %}
해결 방안 상세 설명
- var hostname = window.location.hostname;
http://192.168.0.6:10081/horizon/project/instances/63c3bbd9-96e2-4bcd-86fb-5b71f61d5ef4/?tab=instance_details__console 여기서 ‘192.168.0.6’를 뽑아낸다.
http://controller:10081/horizon/project/instances/63c3bbd9-96e2-4bcd-86fb-5b71f61d5ef4/?tab=instance_details__console 여기서 ‘controller’를 뽑아낸다.
- var console_href_src = document.getElementById('console_embed').src;
콘솔 주소를 뽑아낸다.
- var console_href_dst = "http://"+hostname+":6080/vnc_auto.html"+console_href_src.split('vnc_auto.html')[1];
console_href_src.split('vnc_auto.html')[1] : vnc_auto.html 기준으로 자르고, 뒤에 부분을 선택
[0] | [1] |
[http://192.168.0.6:6080/] | [?path=%3Ftoken%3D496d9a85-1856-4363-b1a5-2855d7446bdd&title=ubuntu-server-20.04(63c3bbd9-96e2-4bcd-86fb-5b71f61d5ef4)] |
hostname(192.168.0.6 or controller)와 조합한다.
- document.getElementById('console_embed').src = console_href_dst;
console iframe 주소를 바꿔버린다.
반응형