Revision c935b4ea

b/snf-cyclades-app/synnefo/ui/static/snf/js/neutron.js
56 56
          //TODO: Also check network status
57 57
          return !this.is_public() && _.contains(['ACTIVE'], this.get('status'));
58 58
        }],
59
        'remove': [['status', 'is_public'], function() {
60
          //TODO: Also check network status
59
        'remove': [['status', 'is_public', 'ports'], function() {
60
          if (this.ports && this.ports.length) {
61
            return false
62
          }
61 63
          return !this.is_public() && _.contains(['ACTIVE'], this.get('status'));
62 64
        }]
63 65
      },
......
152 154
        this.ports.bind("add", function() {
153 155
          this.pending_connections--;
154 156
          this.update_connecting_status();
157
          this.update_actions();
155 158
        }, this);
159

  
156 160
        this.ports.bind("remove", function() {
157 161
          this.pending_disconnects--;
158 162
          this.update_connecting_status();
163
          this.update_actions();
159 164
        }, this);
160 165
        this.set({ports: this.ports});
161 166

  
......
165 170
            return m.can_connect();
166 171
          }
167 172
        });
173
        this.update_actions();
168 174
      },
169 175
      
176
      update_actions: function() {
177
        if (this.ports.length) {
178
          this.set({can_remove: false})
179
        } else {
180
          this.set({can_remove: true})
181
        }
182
      },
183

  
170 184
      update_connecting_status: function() {
171 185
        if (this.pending_connections <= 0) {
172 186
          this.pending_connections = 0;
......
328 342
          }
329 343
          var status_ok = _.contains(['DOWN', 'ACTIVE', 'CONNECTED'], 
330 344
                                     this.get('status'));
331
          var vm_status_ok = this.get('vm') && !this.get('vm').get('busy');
345
          var vm_status_ok = this.get('vm') && this.get('vm').can_connect();
332 346
          return status_ok && vm_status_ok
333 347
        }]
334 348
      },

Also available in: Unified diff