root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / ember / models / vm.js @ e4a6c3b8
History | View | Annotate | Download (1.7 kB)
1 |
/*TODO:
|
---|---|
2 |
Add tags to Vm model*/
|
3 |
|
4 |
|
5 |
var statesActionsVm = {
|
6 |
'off' : {
|
7 |
enabledActions : ['start', 'destroy'], |
8 |
}, |
9 |
'error' : {
|
10 |
enabledActions : ['destroy'], |
11 |
}, |
12 |
'building' : {
|
13 |
enabledActions : [],
|
14 |
}, |
15 |
'running' : {
|
16 |
enabledActions : ['reboot', 'shutdown', 'destroy'], |
17 |
}, |
18 |
'rebooting' : {
|
19 |
enabledActions : ['destroy'], |
20 |
}, |
21 |
'starting' : {
|
22 |
enabledActions : ['destroy'], |
23 |
}, |
24 |
'shutting' : {
|
25 |
enabledActions : ['destroy'], |
26 |
}, |
27 |
}; |
28 |
|
29 |
|
30 |
|
31 |
// the model for a Vm
|
32 |
App.Vm = DS.Model.extend({ |
33 |
name : DS.attr(),
|
34 |
state : DS.attr(),
|
35 |
os : DS.attr(),
|
36 |
link : DS.attr(),
|
37 |
networks : DS.hasMany('network', { async:true }), |
38 |
|
39 |
enabledActions: function() { |
40 |
return statesActionsVm[this.get('state')].enabledActions; |
41 |
}.property('state'),
|
42 |
}); |
43 |
|
44 |
|
45 |
App.Vm.FIXTURES = [ |
46 |
{ |
47 |
id: 1, |
48 |
name: 'My cool VM 1', |
49 |
state: 'off', |
50 |
os: 'kubuntu', |
51 |
link: 'http://www.in.gr', |
52 |
networks:[1,2], |
53 |
}, |
54 |
{ |
55 |
id: 2, |
56 |
name: 'My even cooler VM 2 that has a long name', |
57 |
state: 'error', |
58 |
os: 'unknown', |
59 |
link: 'http://www.in.gr', |
60 |
networks:[3], |
61 |
}, |
62 |
{ |
63 |
id: 3, |
64 |
name: 'My cool VM 3', |
65 |
state: 'building', |
66 |
os: 'windows', |
67 |
link: 'http://www.in.gr', |
68 |
}, |
69 |
{ |
70 |
id: 4, |
71 |
name: 'So awesome VM 4', |
72 |
state: 'running', |
73 |
os: 'fedora', |
74 |
link: 'www.france24.fr', |
75 |
}, |
76 |
{ |
77 |
id: 5, |
78 |
name: 'olga', |
79 |
state: 'rebooting', |
80 |
os: 'kubuntu', |
81 |
link: 'http://www.in.gr', |
82 |
}, |
83 |
{ |
84 |
id: 6, |
85 |
name: 'athina', |
86 |
state: 'starting', |
87 |
os: 'kubuntu', |
88 |
link: 'http://www.in.gr', |
89 |
}, |
90 |
{ |
91 |
id: 7, |
92 |
name: 'kpap', |
93 |
state: 'shutting', |
94 |
os: 'kubuntu', |
95 |
link: 'http://www.in.gr', |
96 |
}, |
97 |
] |