root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / ember / models / vm.js @ c908515d
History | View | Annotate | Download (2.2 kB)
1 |
/*TODO:
|
---|---|
2 |
Add tags to Vm model*/
|
3 |
|
4 |
|
5 |
var statussActionsVm = {
|
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 |
// the model for a Vm
|
31 |
App.Vm = DS.Model.extend({ |
32 |
name : DS.attr(),
|
33 |
status : DS.attr(),
|
34 |
os : DS.attr(),
|
35 |
link : DS.attr(),
|
36 |
created : DS.attr('date'), |
37 |
updated : DS.attr('date'), |
38 |
/*flavor : DS.attr('raw'),*/
|
39 |
networks : DS.hasMany('network', { async:true }), |
40 |
|
41 |
enabledActions: function() { |
42 |
return statussActionsVm[this.get('status')].enabledActions; |
43 |
}.property('status'),
|
44 |
}); |
45 |
|
46 |
|
47 |
App.Vm.FIXTURES = [ |
48 |
{ |
49 |
|
50 |
created: '2011-04-19T10:18:52.085737+00:00', |
51 |
id: 42, |
52 |
metadata: { foo: "bar"}, |
53 |
name: "My Server", |
54 |
os: 'windows', |
55 |
status: "running", |
56 |
link: 'http://www.in.gr', |
57 |
updated: "2011-05-29T14:07:07.037602+00:00", |
58 |
networks: [1,2], |
59 |
}, |
60 |
{ |
61 |
id: 2, |
62 |
name: 'My even cooler VM 2 that has a long name', |
63 |
status: 'error', |
64 |
os: 'unknown', |
65 |
link: 'http://www.in.gr', |
66 |
networks:[3], |
67 |
}, |
68 |
{ |
69 |
id: 3, |
70 |
name: 'My cool VM 3', |
71 |
status: 'building', |
72 |
os: 'windows', |
73 |
link: 'http://www.in.gr', |
74 |
}, |
75 |
{ |
76 |
id: 4, |
77 |
name: 'So awesome VM 4', |
78 |
status: 'running', |
79 |
os: 'fedora', |
80 |
link: 'www.france24.fr', |
81 |
}, |
82 |
{ |
83 |
id: 5, |
84 |
name: 'olga', |
85 |
status: 'rebooting', |
86 |
os: 'kubuntu', |
87 |
link: 'http://www.in.gr', |
88 |
}, |
89 |
{ |
90 |
id: 6, |
91 |
name: 'athina', |
92 |
status: 'starting', |
93 |
os: 'kubuntu', |
94 |
link: 'http://www.in.gr', |
95 |
}, |
96 |
{ |
97 |
id: 7, |
98 |
name: 'kpap', |
99 |
status: 'shutting', |
100 |
os: 'kubuntu', |
101 |
link: 'http://www.in.gr', |
102 |
}, |
103 |
]; |