Commit a64ebad3 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

ui: Warn user when vm has no public ip v4

in vm connect overlay
parent d5c798ac
......@@ -4748,6 +4748,12 @@ table.list-machines .wave {
font-size: 0.8em;
}
.overlay .v6-warn .important {
display: block;
margin: 4px 0;
font-weight: bold;
}
.overlay .overlay-content .important {
color: #800000;
}
......
......@@ -720,7 +720,7 @@
['status', 'state'], function() {
return !_.contains(['ACTIVE', 'STOPPED'], this.get('status'));
}
],
]
},
initialize: function(params) {
......@@ -770,6 +770,42 @@
}, this));
},
has_public_ip: function() {
return this.ports.filter(function(port) {
return port.get("network") &&
port.get("network").get("is_public") &&
port.get("ips").length > 0;
}).length > 0;
},
has_public_ipv6: function() {
return this.has_ip_version("v6", true);
},
has_public_ipv4: function() {
return this.has_ip_version("v4", true);
},
has_ip_version: function(ver, public) {
var found = false;
this.ports.each(function(port) {
if (found) { return }
if (public !== undefined) {
if (port.get("network") &&
port.get("network").get("is_public") != public) {
return
}
}
port.get('ips').each(function(ip) {
if (found) { return }
if (ip.get("type") == ver) {
found = true
}
})
}, this)
return found;
},
status: function(st) {
if (!st) { return this.get("status")}
......
......@@ -66,9 +66,20 @@
this.error = this.$("div.error");
this.info = this.$("div.connection-info");
this.no_public = this.$("div.no-public-ip");
this.description = this.info.find(".description p");
this.connect = this.info.find(".connect p");
this.subinfo = this.info.find(".subinfo");
this.v6_warn = this.info.find(".v6-warn");
var self = this;
this.no_public.find("a").click(function(e) {
e.preventDefault();
self.hide();
window.setTimeout(function() {
synnefo.router.ips_view();
}, 200)
});
},
beforeOpen: function() {
......@@ -79,10 +90,18 @@
this.$(".clipboard").empty();
try { delete this.clip; } catch (err) {};
},
show_no_public_ip: function() {
this.error.hide();
this.info.hide();
this.no_public.removeClass("hidden").show();
},
handle_success: function(data) {
this.error.hide();
this.info.show();
this.v6_warn.hide();
this.no_public.hide();
this.description.html(data.info);
if (data.ssh) {
this.connect.html(data.link.title);
......@@ -98,6 +117,12 @@
this.clip = new snf.util.ClipHelper(this.$(".clipboard"), ssh_msg);
} else {
}
if (!this.vm.has_public_ipv4()) {
this.v6_warn.removeClass("hidden").show();
} else {
this.v6_warn.hide();
}
},
handle_error: function() {
......@@ -121,8 +146,12 @@
this.error.hide();
this.info.hide();
this.vm.get_connection_info($.client.os, this.handle_success, this.handle_error)
if (!this.vm.has_public_ip()) {
this.show_no_public_ip();
} else {
this.vm.get_connection_info($.client.os, this.handle_success, this.handle_error)
}
}
});
......
{% load i18n %}
<div id="vm-connect-overlay-content" class="hidden vm-connect overlay-content">
<div class="no-public-ip hidden description">
You need to have a public IP in order to connect.
You can attach a public IP to your machine from the
<a href="#">IPs pane view.</a>
</div>
<div class="error hidden description">
<p>{% trans "Cannot retrieve machine connection infromation" %}</p>
</div>
......@@ -21,6 +26,12 @@
minutes to connect to them.
</span>
</p>
<p class="hidden v6-warn">
<span class="important">
This machine does not have a public IPv4 address. You need to
have IPv6 connectivity in order to reach this machine.
</span>
</p>
</div>
</div>
</div>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment