Revision a3ac649e

b/snf-cyclades-app/synnefo/ui/static/snf/js/models.js
773 773
            
774 774
            // handle progress message on instance change
775 775
            this.bind("change", _.bind(this.update_status_message, this));
776
            this.bind("change:task_state", _.bind(this.update_status, this));
776 777
            // force update of progress message
777 778
            this.update_status_message(true);
778 779
            
......
790 791
            if (!st) { return this.get("status")}
791 792
            return this.set({status:st});
792 793
        },
794
        
795
        update_status: function() {
796
            this.set_status(this.get('status'));
797
        },
793 798

  
794 799
        set_status: function(st) {
795 800
            var new_state = this.state_for_api_status(st);
......
802 807
            }
803 808
            
804 809
            // call it silently to avoid double change trigger
805
            this.set({'state': this.state_for_api_status(st)}, {silent: true});
810
            var state = this.state_for_api_status(st);
811
            this.set({'state': state}, {silent: true});
806 812
            
807 813
            // trigger transition
808 814
            if (transition && models.VM.TRANSITION_STATES.indexOf(new_state) == -1) { 
......
1206 1212
            return this.state_transition(this.state(), status);
1207 1213
        },
1208 1214
        
1209
        // vm state equals vm api status
1210
        state_is_status: function(state) {
1211
            return models.VM.STATUSES.indexOf(state) != -1;
1212
        },
1213
        
1214 1215
        // get transition state for the corresponging api status
1215 1216
        state_transition: function(state, new_status) {
1216 1217
            var statuses = models.VM.STATES_TRANSITIONS[state];
......
1477 1478
                                         "create", // create so that sync later uses POST to make the call
1478 1479
                                         {resize: {flavorRef:params.flavor}}, // payload
1479 1480
                                         function() {
1480
                                             success.apply(this, arguments)
1481
                                             self.state('RESIZE');
1482
                                             success.apply(this, arguments);
1481 1483
                                             snf.api.trigger("call");
1482 1484
                                         },  
1483 1485
                                         error, 'resize', params);
......
1568 1570
        'shutdown',
1569 1571
        'reboot',
1570 1572
        'console',
1571
        'destroy'
1573
        'destroy',
1574
        'resize'
1572 1575
    ]
1573 1576

  
1577
    models.VM.TASK_STATE_STATUS_MAP = {
1578
      'BULDING': 'BUILD',
1579
      'REBOOTING': 'REBOOT',
1580
      'STOPPING': 'SHUTDOWN',
1581
      'STARTING': 'START',
1582
      'RESIZING': 'RESIZE',
1583
      'CONNECTING': 'CONNECT',
1584
      'DISCONNECTING': 'DISCONNECT',
1585
      'DESTROYING': 'DESTROY'
1586
    }
1587

  
1574 1588
    models.VM.AVAILABLE_ACTIONS = {
1575
        'UNKNWON'       : ['destroy'],
1576
        'BUILD'         : ['destroy'],
1577
        'REBOOT'        : ['shutdown', 'destroy', 'console'],
1589
        'UNKNWON'       : [],
1590
        'BUILD'         : [],
1591
        'REBOOT'        : [],
1578 1592
        'STOPPED'       : ['start', 'destroy'],
1579 1593
        'ACTIVE'        : ['shutdown', 'destroy', 'reboot', 'console'],
1580 1594
        'ERROR'         : ['destroy'],
1581
        'DELETED'        : [],
1595
        'DELETED'       : [],
1582 1596
        'DESTROY'       : [],
1583
        'BUILD_INIT'    : ['destroy'],
1584
        'BUILD_COPY'    : ['destroy'],
1585
        'BUILD_FINAL'   : ['destroy'],
1586
        'SHUTDOWN'      : ['destroy'],
1597
        'SHUTDOWN'      : [],
1587 1598
        'START'         : [],
1588 1599
        'CONNECT'       : [],
1589
        'DISCONNECT'    : []
1600
        'DISCONNECT'    : [],
1601
        'RESIZE'        : []
1590 1602
    }
1591 1603

  
1592 1604
    // api status values
......
1597 1609
        'STOPPED',
1598 1610
        'ACTIVE',
1599 1611
        'ERROR',
1600
        'DELETED'
1612
        'DELETED',
1613
        'RESIZE'
1601 1614
    ]
1602 1615

  
1603 1616
    // api status values
......
1610 1623
    // vm states
1611 1624
    models.VM.STATES = models.VM.STATUSES.concat([
1612 1625
        'DESTROY',
1613
        'BUILD_INIT',
1614
        'BUILD_COPY',
1615
        'BUILD_FINAL',
1616 1626
        'SHUTDOWN',
1617 1627
        'START',
1618 1628
        'CONNECT',
1619 1629
        'DISCONNECT',
1620
        'FIREWALL'
1630
        'FIREWALL',
1631
        'RESIZE'
1621 1632
    ]);
1622 1633
    
1623 1634
    models.VM.STATES_TRANSITIONS = {
......
1628 1639
        'START': ['ERROR', 'ACTIVE', 'DESTROY'],
1629 1640
        'REBOOT': ['ERROR', 'ACTIVE', 'STOPPED', 'DESTROY'],
1630 1641
        'BUILD': ['ERROR', 'ACTIVE', 'DESTROY'],
1631
        'BUILD_COPY': ['ERROR', 'ACTIVE', 'BUILD_FINAL', 'DESTROY'],
1632
        'BUILD_FINAL': ['ERROR', 'ACTIVE', 'DESTROY'],
1633
        'BUILD_INIT': ['ERROR', 'ACTIVE', 'BUILD_COPY', 'BUILD_FINAL', 'DESTROY']
1642
        'RESIZE': ['ERROR', 'STOPPED']
1634 1643
    }
1635 1644

  
1636 1645
    models.VM.TRANSITION_STATES = [
......
1638 1647
        'SHUTDOWN',
1639 1648
        'START',
1640 1649
        'REBOOT',
1641
        'BUILD'
1650
        'BUILD',
1651
        'RESIZE'
1642 1652
    ]
1643 1653

  
1644 1654
    models.VM.ACTIVE_STATES = [
1645 1655
        'BUILD', 'REBOOT', 'ACTIVE',
1646
        'BUILD_INIT', 'BUILD_COPY', 'BUILD_FINAL',
1647 1656
        'SHUTDOWN', 'CONNECT', 'DISCONNECT'
1648 1657
    ]
1649 1658

  
1650 1659
    models.VM.BUILDING_STATES = [
1651
        'BUILD', 'BUILD_INIT', 'BUILD_COPY', 'BUILD_FINAL'
1660
        'BUILD'
1652 1661
    ]
1653 1662

  
1654 1663
    models.Networks = models.Collection.extend({
......
2063 2072
                    return false;
2064 2073
                }
2065 2074
            }
2075
            
2076
            if ('SNF:task_state' in data) { 
2077
                data['task_state'] = data['SNF:task_state'];
2078
                if (data['task_state']) {
2079
                    var status = models.VM.TASK_STATE_STATUS_MAP[data['task_state']];
2080
                    if (status) { data['status'] = status }
2081
                }
2082
            }
2066 2083

  
2067 2084
            // OS attribute
2068 2085
            if (this.has_meta(data)) {
b/snf-cyclades-app/synnefo/ui/static/snf/js/ui/web/ui_icon_view.js
861 861
        'STOPPED':          ['state', 'terminated-state'],
862 862
        'ACTIVE':           ['state', 'running-state'],
863 863
        'ERROR':            ['state', 'error-state'],
864
        'DELETED':           ['state', 'destroying-state'],
864
        'DELETED':          ['state', 'destroying-state'],
865 865
        'DESTROY':          ['state', 'destroying-state'],
866
        'BUILD_INIT':       ['state', 'build-state'], 
867
        'BUILD_COPY':       ['state', 'build-state'],
868
        'BUILD_FINAL':      ['state', 'build-state'],
869 866
        'SHUTDOWN':         ['state', 'shutting-state'],
870 867
        'START':            ['state', 'starting-state'],
871 868
        'CONNECT':          ['state', 'connecting-state'],
872
        'DISCONNECT':       ['state', 'disconnecting-state']
869
        'DISCONNECT':       ['state', 'disconnecting-state'],
870
        'RESIZE':           ['state', 'rebooting-state']
873 871
    };
874 872

  
875 873
})(this);
b/snf-cyclades-app/synnefo/ui/static/snf/js/ui/web/ui_list_view.js
524 524
        'ERROR':            ['error-state'],
525 525
        'DELETED':          ['destroying-state'],
526 526
        'DESTROY':          ['destroying-state'],
527
        'BUILD_INIT':       ['build-state'], 
528
        'BUILD_COPY':       ['build-state'],
529
        'BUILD_FINAL':      ['build-state'],
530 527
        'SHUTDOWN':         ['shutting-state'],
531 528
        'START':            ['starting-state'],
532 529
        'CONNECT':          ['connecting-state'],
533
        'DISCONNECT':       ['disconnecting-state']
530
        'DISCONNECT':       ['disconnecting-state'],
531
        'RESIZE':           ['rebooting-state']
534 532
    };
535 533

  
536 534
})(this);
b/snf-cyclades-app/synnefo/ui/static/snf/js/ui/web/ui_single_view.js
391 391
        'STOPPED':          ['state', 'terminated-state'],
392 392
        'ACTIVE':           ['state', 'running-state'],
393 393
        'ERROR':            ['state', 'error-state'],
394
        'DELETED':           ['state', 'destroying-state'],
394
        'DELETED':          ['state', 'destroying-state'],
395 395
        'DESTROY':          ['state', 'destroying-state'],
396
        'BUILD_INIT':       ['state', 'build-state'], 
397
        'BUILD_COPY':       ['state', 'build-state'],
398
        'BUILD_FINAL':      ['state', 'build-state'],
399 396
        'SHUTDOWN':         ['state', 'shutting-state'],
400 397
        'START':            ['state', 'starting-state'],
401 398
        'CONNECT':          ['state', 'connecting-state'],
402
        'DISCONNECT':       ['state', 'disconnecting-state']
399
        'DISCONNECT':       ['state', 'disconnecting-state'],
400
        'RESIZE':           ['state', 'rebooting-state']
403 401
    };
404 402

  
405 403
})(this);
b/snf-cyclades-app/synnefo/ui/templates/home.html
118 118
            'ERROR':  '{% trans "Error" %}',
119 119
            'DELETE': '',
120 120
            'DESTROY': '{% trans "Destroying..." %}',
121
            'BUILD_INIT':  '{% trans "Building..." %}',
122
            'BUILD_COPY':  '{% trans "Building..." %}',
123
            'BUILD_FINAL':  '{% trans "Building..." %}',
124 121
            'SHUTDOWN': '{% trans "Shutting down..." %}',
125 122
            'START': '{% trans "Starting..." %}',
126 123
            'CONNECT': '{% trans "Connecting..." %}',
127
            'DISCONNECT': '{% trans "Disconnecting..." %}'
124
            'DISCONNECT': '{% trans "Disconnecting..." %}',
125
            'RESIZE': '{% trans "Resizing..." %}'
128 126
        }
129 127

  
130 128

  

Also available in: Unified diff