Revision 3cac4a52

b/snf-cyclades-app/synnefo/ui/static/snf/css/main.css
4748 4748
    font-size: 0.8em;
4749 4749
}
4750 4750

  
4751
.overlay .v6-warn .important {
4752
  display: block;
4753
  margin: 4px 0;
4754
  font-weight: bold;
4755
}
4756

  
4751 4757
.overlay .overlay-content .important {
4752 4758
    color: #800000;
4753 4759
}
b/snf-cyclades-app/synnefo/ui/static/snf/js/models.js
720 720
            ['status', 'state'], function() {
721 721
              return !_.contains(['ACTIVE', 'STOPPED'], this.get('status'));
722 722
            }
723
          ],
723
          ]
724 724
        },
725 725

  
726 726
        initialize: function(params) {
......
770 770
            }, this));
771 771

  
772 772
        },
773
          
774
        has_public_ip: function() {
775
          return this.ports.filter(function(port) {
776
            return port.get("network") && 
777
                   port.get("network").get("is_public") && 
778
                   port.get("ips").length > 0;
779
          }).length > 0;
780
        },
781

  
782
        has_public_ipv6: function() {
783
          return this.has_ip_version("v6", true);
784
        },
785

  
786
        has_public_ipv4: function() {
787
          return this.has_ip_version("v4", true);
788
        },
789
        
790
        has_ip_version: function(ver, public) {
791
          var found = false;
792
          this.ports.each(function(port) {
793
            if (found) { return }
794
            if (public !== undefined) {
795
              if (port.get("network") && 
796
                  port.get("network").get("is_public") != public) {
797
                return
798
              }
799
            }
800
            port.get('ips').each(function(ip) {
801
              if (found) { return }
802
              if (ip.get("type") == ver) {
803
                found = true
804
              }
805
            })
806
          }, this)
807
          return found;
808
        },
773 809

  
774 810
        status: function(st) {
775 811
            if (!st) { return this.get("status")}
b/snf-cyclades-app/synnefo/ui/static/snf/js/ui/web/ui_connect_view.js
66 66

  
67 67
            this.error = this.$("div.error");
68 68
            this.info = this.$("div.connection-info");
69
            this.no_public = this.$("div.no-public-ip");
69 70
            this.description = this.info.find(".description p");
70 71
            this.connect = this.info.find(".connect p");
71 72
            this.subinfo = this.info.find(".subinfo");
73
            this.v6_warn = this.info.find(".v6-warn");
74

  
75
            var self = this;
76
            this.no_public.find("a").click(function(e) {
77
              e.preventDefault();
78
              self.hide();
79
              window.setTimeout(function() {
80
                synnefo.router.ips_view();
81
              }, 200)
82
            });
72 83
        },
73 84

  
74 85
        beforeOpen: function() {
......
79 90
            this.$(".clipboard").empty();
80 91
            try { delete this.clip; } catch (err) {};
81 92
        },
93
        
94
        show_no_public_ip: function() {
95
            this.error.hide();
96
            this.info.hide();
97
            this.no_public.removeClass("hidden").show();
98
        },
82 99

  
83 100
        handle_success: function(data) {
84 101
            this.error.hide();
85 102
            this.info.show();
103
            this.v6_warn.hide();
104
            this.no_public.hide();
86 105
            this.description.html(data.info);
87 106
            if (data.ssh) {
88 107
                this.connect.html(data.link.title);
......
98 117
                this.clip = new snf.util.ClipHelper(this.$(".clipboard"), ssh_msg);
99 118
            } else {
100 119
            }
120

  
121
            if (!this.vm.has_public_ipv4()) {
122
              this.v6_warn.removeClass("hidden").show();
123
            } else {
124
              this.v6_warn.hide();
125
            }
101 126
        },
102 127

  
103 128
        handle_error: function() {
......
121 146
            
122 147
            this.error.hide();
123 148
            this.info.hide();
124

  
125
            this.vm.get_connection_info($.client.os, this.handle_success, this.handle_error)
149
              
150
            if (!this.vm.has_public_ip()) {
151
              this.show_no_public_ip();
152
            } else {
153
              this.vm.get_connection_info($.client.os, this.handle_success, this.handle_error)
154
            }
126 155
        }
127 156

  
128 157
    });
b/snf-cyclades-app/synnefo/ui/templates/partials/vm_connect.html
1 1
{% load i18n %}
2 2
<div id="vm-connect-overlay-content" class="hidden vm-connect overlay-content">
3
    <div class="no-public-ip hidden description">
4
      You need to have a public IP in order to connect. 
5
      You can attach a public IP to your machine from the 
6
      <a href="#">IPs pane view.</a>
7
    </div>
3 8
    <div class="error hidden description">
4 9
        <p>{% trans "Cannot retrieve machine connection infromation" %}</p>
5 10
    </div>
......
21 26
            minutes to connect to them.
22 27
          </span>
23 28
          </p>
29
          <p class="hidden v6-warn">
30
            <span class="important">
31
              This machine does not have a public IPv4 address.  You need to
32
              have IPv6 connectivity in order to reach this machine.
33
            </span>
34
          </p>
24 35
        </div>
25 36
    </div>
26 37
</div>

Also available in: Unified diff