InPanel 1.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- inpanel/__init__.py +29 -0
- inpanel/acme.py +289 -0
- inpanel/aliyuncs.py +269 -0
- inpanel/app.py +514 -0
- inpanel/apt.py +223 -0
- inpanel/base.py +200 -0
- inpanel/config.py +139 -0
- inpanel/data/config.ini +29 -0
- inpanel/data/history +5 -0
- inpanel/data/runlogs.ini +12 -0
- inpanel/data/update_info.ini +4 -0
- inpanel/dnf.py +225 -0
- inpanel/lib/__init__.py +9 -0
- inpanel/lib/async_process.py +98 -0
- inpanel/lib/filelock.py +82 -0
- inpanel/lib/magic.py +233 -0
- inpanel/lib/pxssh.py +310 -0
- inpanel/lib/pyDes.py +867 -0
- inpanel/mod/__init__.py +0 -0
- inpanel/mod/apt.py +316 -0
- inpanel/mod/certificate.py +268 -0
- inpanel/mod/config.py +372 -0
- inpanel/mod/cron.py +315 -0
- inpanel/mod/disk.py +322 -0
- inpanel/mod/dnf.py +239 -0
- inpanel/mod/file.py +722 -0
- inpanel/mod/firewall.py +199 -0
- inpanel/mod/firewall_base.py +137 -0
- inpanel/mod/firewall_firewalld.py +170 -0
- inpanel/mod/firewall_iptables.py +176 -0
- inpanel/mod/firewall_macos.py +213 -0
- inpanel/mod/firewall_ufw.py +128 -0
- inpanel/mod/ftp.py +231 -0
- inpanel/mod/httpd.py +1205 -0
- inpanel/mod/lighttpd.py +26 -0
- inpanel/mod/login.py +98 -0
- inpanel/mod/mysql.py +577 -0
- inpanel/mod/named.py +26 -0
- inpanel/mod/nginx.py +2327 -0
- inpanel/mod/package.py +33 -0
- inpanel/mod/package_apt.py +62 -0
- inpanel/mod/package_base.py +77 -0
- inpanel/mod/package_dnf.py +62 -0
- inpanel/mod/package_map.py +366 -0
- inpanel/mod/package_yum.py +64 -0
- inpanel/mod/php.py +289 -0
- inpanel/mod/process.py +291 -0
- inpanel/mod/proftpd.py +26 -0
- inpanel/mod/pureftpd.py +26 -0
- inpanel/mod/query.py +108 -0
- inpanel/mod/server.py +1319 -0
- inpanel/mod/service.py +262 -0
- inpanel/mod/setting.py +228 -0
- inpanel/mod/shell.py +78 -0
- inpanel/mod/ssh.py +280 -0
- inpanel/mod/system.py +220 -0
- inpanel/mod/task.py +1337 -0
- inpanel/mod/ufw.py +14 -0
- inpanel/mod/user.py +306 -0
- inpanel/mod/vsftpd.py +67 -0
- inpanel/mod/yum.py +243 -0
- inpanel/plugins/__init__.py +10 -0
- inpanel/plugins/__pycache__/__init__.cpython-313.pyc +0 -0
- inpanel/plugins/acme/static/index.html +10 -0
- inpanel/plugins/acme/static/index.js +13 -0
- inpanel/plugins/shadowsocks-libev/__pycache__/info.cpython-313.pyc +0 -0
- inpanel/plugins/shadowsocks-libev/info.py +73 -0
- inpanel/plugins/shadowsocks-libev/static/index.html +70 -0
- inpanel/plugins/shadowsocks-libev/static/index.js +18 -0
- inpanel/public/css/global.css +138 -0
- inpanel/public/favicon.ico +0 -0
- inpanel/public/images/alipay.jpg +0 -0
- inpanel/public/images/loading.gif +0 -0
- inpanel/public/images/weixin.jpg +0 -0
- inpanel/public/index.html +94 -0
- inpanel/public/js/controllers/controllers.js +566 -0
- inpanel/public/js/controllers/database.js +590 -0
- inpanel/public/js/controllers/ecs.js +624 -0
- inpanel/public/js/controllers/file.js +940 -0
- inpanel/public/js/controllers/plugins.js +105 -0
- inpanel/public/js/controllers/service.js +1460 -0
- inpanel/public/js/controllers/site.js +1241 -0
- inpanel/public/js/controllers/utils.js +2319 -0
- inpanel/public/js/core.js +221 -0
- inpanel/public/js/directives.js +784 -0
- inpanel/public/js/filters.js +395 -0
- inpanel/public/js/services.js +257 -0
- inpanel/public/lib/angular/1.0.2/angular-resource.min.js +10 -0
- inpanel/public/lib/angular/1.0.2/angular.min.js +158 -0
- inpanel/public/lib/bootstrap/css/bootstrap-theme.css +587 -0
- inpanel/public/lib/bootstrap/css/bootstrap-theme.css.map +1 -0
- inpanel/public/lib/bootstrap/css/bootstrap-theme.min.css +6 -0
- inpanel/public/lib/bootstrap/css/bootstrap-theme.min.css.map +1 -0
- inpanel/public/lib/bootstrap/css/bootstrap.css +6757 -0
- inpanel/public/lib/bootstrap/css/bootstrap.css.map +1 -0
- inpanel/public/lib/bootstrap/css/bootstrap.min.css +6 -0
- inpanel/public/lib/bootstrap/css/bootstrap.min.css.map +1 -0
- inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
- inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.svg +288 -0
- inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
- inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
- inpanel/public/lib/bootstrap/fonts/glyphicons-halflings-regular.woff2 +0 -0
- inpanel/public/lib/bootstrap/img/glyphicons-halflings-white.png +0 -0
- inpanel/public/lib/bootstrap/img/glyphicons-halflings.png +0 -0
- inpanel/public/lib/bootstrap/js/bootstrap.js +2377 -0
- inpanel/public/lib/bootstrap/js/bootstrap.min.js +7 -0
- inpanel/public/lib/bootstrap/js/npm.js +13 -0
- inpanel/public/lib/codemirror/codemirror-compressed.js +1 -0
- inpanel/public/lib/codemirror/codemirror.css +173 -0
- inpanel/public/lib/jquery/jquery-1.12.4.min.js +5 -0
- inpanel/public/lib/md5/md5.js +379 -0
- inpanel/public/lib/md5/md5.min.js +1 -0
- inpanel/public/partials/database/index.html +172 -0
- inpanel/public/partials/database/mysql/dbedit.html +462 -0
- inpanel/public/partials/database/mysql/dbnew.html +348 -0
- inpanel/public/partials/database/mysql/useredit.html +310 -0
- inpanel/public/partials/database/mysql/usernew.html +97 -0
- inpanel/public/partials/directives/message.html +20 -0
- inpanel/public/partials/directives/navbar.html +25 -0
- inpanel/public/partials/directives/selector.html +57 -0
- inpanel/public/partials/directives/srvbase.html +72 -0
- inpanel/public/partials/directives/srvext.html +34 -0
- inpanel/public/partials/directives/srvfile.html +23 -0
- inpanel/public/partials/directives/srvinstall.html +34 -0
- inpanel/public/partials/directives/srvlog.html +23 -0
- inpanel/public/partials/directives/srvminiop.html +28 -0
- inpanel/public/partials/directives/srvuninstall.html +38 -0
- inpanel/public/partials/directives/srvupdate.html +30 -0
- inpanel/public/partials/ecs/account.html +156 -0
- inpanel/public/partials/ecs/ecs.html +198 -0
- inpanel/public/partials/ecs/index.html +40 -0
- inpanel/public/partials/ecs/setings.html +459 -0
- inpanel/public/partials/file/file.html +501 -0
- inpanel/public/partials/file/trash.html +95 -0
- inpanel/public/partials/ftp.html +36 -0
- inpanel/public/partials/log.html +83 -0
- inpanel/public/partials/login.html +79 -0
- inpanel/public/partials/logout.html +22 -0
- inpanel/public/partials/main.html +534 -0
- inpanel/public/partials/plugins/index.html +55 -0
- inpanel/public/partials/plugins/plugins.html +13 -0
- inpanel/public/partials/secure.html +13 -0
- inpanel/public/partials/service/apache.html +147 -0
- inpanel/public/partials/service/cron.html +71 -0
- inpanel/public/partials/service/index.html +293 -0
- inpanel/public/partials/service/iptables.html +40 -0
- inpanel/public/partials/service/lighttpd.html +63 -0
- inpanel/public/partials/service/mariadb.html +113 -0
- inpanel/public/partials/service/memcache.html +36 -0
- inpanel/public/partials/service/minio.html +44 -0
- inpanel/public/partials/service/mongodb.html +44 -0
- inpanel/public/partials/service/mysql.html +113 -0
- inpanel/public/partials/service/named.html +61 -0
- inpanel/public/partials/service/nginx.html +296 -0
- inpanel/public/partials/service/ntp.html +40 -0
- inpanel/public/partials/service/php.html +250 -0
- inpanel/public/partials/service/proftpd.html +59 -0
- inpanel/public/partials/service/pureftpd.html +59 -0
- inpanel/public/partials/service/redis.html +40 -0
- inpanel/public/partials/service/samba.html +58 -0
- inpanel/public/partials/service/sendmail.html +40 -0
- inpanel/public/partials/service/ssh.html +186 -0
- inpanel/public/partials/service/tomcat.html +65 -0
- inpanel/public/partials/service/vsftpd.html +195 -0
- inpanel/public/partials/setting.html +299 -0
- inpanel/public/partials/site/apache/site.html +277 -0
- inpanel/public/partials/site/index.html +344 -0
- inpanel/public/partials/site/nginx/site.html +558 -0
- inpanel/public/partials/sorry.html +19 -0
- inpanel/public/partials/storage/autofm.html +103 -0
- inpanel/public/partials/storage/backup.html +42 -0
- inpanel/public/partials/storage/index.html +360 -0
- inpanel/public/partials/storage/migrate.html +93 -0
- inpanel/public/partials/storage/movedata.html +98 -0
- inpanel/public/partials/storage/remote.html +77 -0
- inpanel/public/partials/utils/cron.html +486 -0
- inpanel/public/partials/utils/firewall.html +266 -0
- inpanel/public/partials/utils/index.html +193 -0
- inpanel/public/partials/utils/network.html +118 -0
- inpanel/public/partials/utils/process.html +239 -0
- inpanel/public/partials/utils/repository.html +373 -0
- inpanel/public/partials/utils/shell.html +28 -0
- inpanel/public/partials/utils/ssl.html +319 -0
- inpanel/public/partials/utils/time.html +109 -0
- inpanel/public/partials/utils/user.html +359 -0
- inpanel/public/robots.txt +2 -0
- inpanel/remote.py +109 -0
- inpanel/templates/file/preview.html +34 -0
- inpanel/templates/index.html +93 -0
- inpanel/utils.py +282 -0
- inpanel/web.py +1811 -0
- inpanel/yum.py +756 -0
- inpanel-1.2.1.dist-info/METADATA +399 -0
- inpanel-1.2.1.dist-info/RECORD +198 -0
- inpanel-1.2.1.dist-info/WHEEL +5 -0
- inpanel-1.2.1.dist-info/entry_points.txt +2 -0
- inpanel-1.2.1.dist-info/licenses/LICENSE +30 -0
- inpanel-1.2.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,624 @@
|
|
|
1
|
+
var ECSCtrl = [
|
|
2
|
+
'$scope', '$rootScope', '$location', 'Module', 'Message', 'Request',
|
|
3
|
+
function ($scope, $rootScope, $location, Module, Message, Request) {
|
|
4
|
+
var module = 'ecs';
|
|
5
|
+
Module.init(module, '云服务器管理');
|
|
6
|
+
$scope.loaded = false;
|
|
7
|
+
$scope.instances = [];
|
|
8
|
+
|
|
9
|
+
$scope.load = function () {
|
|
10
|
+
Request.get('/ecs/account?status=enable', function (data) {
|
|
11
|
+
if (data.code == 0) {
|
|
12
|
+
$scope.accounts = data.data;
|
|
13
|
+
if ($scope.accounts.length > 0) {
|
|
14
|
+
if (!$rootScope.$ecs.access_key_id)
|
|
15
|
+
$rootScope.$ecs.access_key_id = $scope.accounts[0].access_key_id;
|
|
16
|
+
$scope.loadinstances();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
$scope.loaded = true;
|
|
20
|
+
}, false, true);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
$scope.loadinstances = function (pagedir) {
|
|
24
|
+
$scope.instloading = true;
|
|
25
|
+
$scope.lastinstances = angular.copy($scope.instances);
|
|
26
|
+
$scope.instances = [];
|
|
27
|
+
$scope.errmsg = '';
|
|
28
|
+
if (pagedir) $rootScope.$ecs.page_number = parseInt($rootScope.$ecs.page_number) + parseInt(pagedir);
|
|
29
|
+
var query = 'access_key_id=' + $rootScope.$ecs.access_key_id + '&page_number=' + $rootScope.$ecs.page_number + '&page_size=' + $rootScope.$ecs.page_size;
|
|
30
|
+
Request.get('/ecs/instances?' + query, function (data) {
|
|
31
|
+
if (data.code == 0) {
|
|
32
|
+
data = data.data;
|
|
33
|
+
$scope.instances = data.instances;
|
|
34
|
+
if ($scope.instances.length > 0) {
|
|
35
|
+
$rootScope.$ecs.page_number = data.page_number;
|
|
36
|
+
$rootScope.$ecs.page_size = data.page_size;
|
|
37
|
+
} else {
|
|
38
|
+
// detect whether there has next page
|
|
39
|
+
if ($rootScope.$ecs.page_number > 1) {
|
|
40
|
+
Message.setError('这已经是最后一页了。');
|
|
41
|
+
$rootScope.$ecs.page_number--;
|
|
42
|
+
$scope.instances = $scope.lastinstances;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
Message.setError('');
|
|
47
|
+
$scope.errmsg = data.msg;
|
|
48
|
+
}
|
|
49
|
+
$scope.instloading = false;
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
$scope.chaccount = function () {
|
|
54
|
+
$rootScope.$ecs.page_number = 1;
|
|
55
|
+
$scope.loadinstances();
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
var ECSIndexCtrl = [
|
|
61
|
+
'$scope', '$rootScope', '$location', 'Module', 'Message', 'Request',
|
|
62
|
+
function ($scope, $rootScope, $location, Module, Message, Request) {
|
|
63
|
+
var module = 'ecs.index';
|
|
64
|
+
Module.init(module, '云服务器管理');
|
|
65
|
+
$scope.loaded = false;
|
|
66
|
+
$scope.instances = [];
|
|
67
|
+
|
|
68
|
+
$scope.load = function () {
|
|
69
|
+
$scope.loaded = true;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
var ECSSettingCtrl = [
|
|
75
|
+
'$scope', '$rootScope', '$routeParams', '$location', 'Module', 'Message', 'Request', 'Timeout', 'Backend',
|
|
76
|
+
function ($scope, $rootScope, $routeParams, $location, Module, Message, Request, Timeout, Backend) {
|
|
77
|
+
var section = $routeParams.section;
|
|
78
|
+
var section = decodeURIComponent(section);
|
|
79
|
+
fs = section.split(',');
|
|
80
|
+
$scope.instance_name = fs[0];
|
|
81
|
+
var access_key_id = fs[1];
|
|
82
|
+
|
|
83
|
+
var module = 'ecs.setting';
|
|
84
|
+
Module.init(module, '管理 ' + $scope.instance_name);
|
|
85
|
+
Module.initSection('base');
|
|
86
|
+
$scope.loaded = false;
|
|
87
|
+
var query = 'access_key_id=' + access_key_id + '&instance_name=' + $scope.instance_name;
|
|
88
|
+
|
|
89
|
+
$scope.load = function (quiet) {
|
|
90
|
+
Request.get('/ecs/instance?' + query, function (data) {
|
|
91
|
+
if (data.code == 0) {
|
|
92
|
+
$scope.instance = data.data;
|
|
93
|
+
if ($scope.images.length == 0) $scope.loadimages();
|
|
94
|
+
}
|
|
95
|
+
$scope.loaded = true;
|
|
96
|
+
if ($scope.instance) {
|
|
97
|
+
var s = $scope.instance.Status.toLowerCase();
|
|
98
|
+
if (s == 'pending' || s == 'starting' || s == 'stopping' || s == 'transferring' || s == 'resetting')
|
|
99
|
+
Timeout(function () {
|
|
100
|
+
$scope.load(true);
|
|
101
|
+
}, 1000, module);
|
|
102
|
+
if (s != 'pending' && s != 'starting' && s != 'startfailure' && s != 'released')
|
|
103
|
+
if ($scope.disks.length == 0) $scope.loaddisks();
|
|
104
|
+
}
|
|
105
|
+
}, false, Module.getSection() != 'base' || quiet);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
$scope.start = function () {
|
|
109
|
+
$scope.processing = true;
|
|
110
|
+
Message.setInfo('正在向云服务器发送启动指令,请稍候...');
|
|
111
|
+
Request.get('/ecs/startinstance', {
|
|
112
|
+
'access_key_id': access_key_id,
|
|
113
|
+
'instance_name=': $scope.instance_name
|
|
114
|
+
}, function (data) {
|
|
115
|
+
if (data.code == 0) {
|
|
116
|
+
$scope.instance.Status = data.data.InstanceStatus;
|
|
117
|
+
Timeout(function () {
|
|
118
|
+
$scope.load(true);
|
|
119
|
+
}, 1000, module);
|
|
120
|
+
}
|
|
121
|
+
$scope.processing = false;
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
$scope.stop = function () {
|
|
125
|
+
$scope.confirm_title = '关闭服务器操作确认';
|
|
126
|
+
$scope.confirm_body = '是否确定要关闭服务器?';
|
|
127
|
+
$scope.confirm_forcebutton = '强制关闭';
|
|
128
|
+
$scope.confirm_button = '确认关闭';
|
|
129
|
+
$scope.confirm = function () {
|
|
130
|
+
dostop();
|
|
131
|
+
};
|
|
132
|
+
$scope.confirm_force = function () {
|
|
133
|
+
dostop(true);
|
|
134
|
+
};
|
|
135
|
+
$('#confirm').modal();
|
|
136
|
+
};
|
|
137
|
+
var dostop = function (force) {
|
|
138
|
+
$scope.processing = true;
|
|
139
|
+
Message.setInfo('正在向云服务器发送关闭指令,请稍候...');
|
|
140
|
+
Request.post('/ecs/stopinstance', {
|
|
141
|
+
'access_key_id': access_key_id,
|
|
142
|
+
'instance_name': $scope.instance_name,
|
|
143
|
+
'force': force ? '&force=yes' : ''
|
|
144
|
+
}, function (data) {
|
|
145
|
+
if (data.code == 0) {
|
|
146
|
+
$scope.instance.Status = data.data.InstanceStatus;
|
|
147
|
+
Timeout(function () {
|
|
148
|
+
$scope.load(true);
|
|
149
|
+
}, 1000, module);
|
|
150
|
+
}
|
|
151
|
+
$scope.processing = false;
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
$scope.reboot = function () {
|
|
155
|
+
$scope.confirm_title = '重启服务器操作确认';
|
|
156
|
+
$scope.confirm_body = '是否确定要重启服务器?';
|
|
157
|
+
$scope.confirm_forcebutton = '强制重启';
|
|
158
|
+
$scope.confirm_button = '确认重启';
|
|
159
|
+
$scope.confirm = function () {
|
|
160
|
+
doreboot();
|
|
161
|
+
};
|
|
162
|
+
$scope.confirm_force = function () {
|
|
163
|
+
doreboot(true);
|
|
164
|
+
};
|
|
165
|
+
$('#confirm').modal();
|
|
166
|
+
};
|
|
167
|
+
var doreboot = function (force) {
|
|
168
|
+
$scope.processing = true;
|
|
169
|
+
Message.setInfo('正在向云服务器发送重启指令,请稍候...');
|
|
170
|
+
Request.post('/ecs/rebootinstance', {
|
|
171
|
+
'access_key_id': access_key_id,
|
|
172
|
+
'instance_name': $scope.instance_name,
|
|
173
|
+
'force': force ? '&force=yes' : ''
|
|
174
|
+
}, function (data) {
|
|
175
|
+
if (data.code == 0) {
|
|
176
|
+
$scope.instance.Status = data.data.InstanceStatus;
|
|
177
|
+
Timeout(function () {
|
|
178
|
+
$scope.load(true);
|
|
179
|
+
}, 1000, module);
|
|
180
|
+
}
|
|
181
|
+
$scope.processing = false;
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
$scope.imageloading = false;
|
|
186
|
+
$scope.images = [];
|
|
187
|
+
$scope.image_code = '';
|
|
188
|
+
$scope.image_total_number = 0;
|
|
189
|
+
$scope.image_page_number = 1;
|
|
190
|
+
$scope.image_page_size = 10;
|
|
191
|
+
$scope.loadimages = function (pagedir, quiet) {
|
|
192
|
+
$scope.imageloading = true;
|
|
193
|
+
if (pagedir) $scope.image_page_number = parseInt($scope.image_page_number) + parseInt(pagedir);
|
|
194
|
+
var query = 'access_key_id=' + access_key_id + '®ion_code=' + $scope.instance.RegionCode;
|
|
195
|
+
query += '&page_number=' + $scope.image_page_number + '&page_size=' + $scope.image_page_size;
|
|
196
|
+
Request.get('/ecs/images?' + query, function (data) {
|
|
197
|
+
if (data.code == 0) {
|
|
198
|
+
data = data.data;
|
|
199
|
+
$scope.images = data.images;
|
|
200
|
+
$scope.image_total_number = data.total_number;
|
|
201
|
+
$scope.image_page_number = data.page_number;
|
|
202
|
+
$scope.image_page_size = data.page_size;
|
|
203
|
+
if ($scope.images.length > 0)
|
|
204
|
+
$scope.image_code = $scope.images[0].ImageCode;
|
|
205
|
+
}
|
|
206
|
+
$scope.imageloading = false;
|
|
207
|
+
}, false, Module.getSection() != 'reset' || quiet);
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
$scope.reset = function (image) {
|
|
211
|
+
$scope.curimage = image;
|
|
212
|
+
$('#resetconfirm').modal();
|
|
213
|
+
};
|
|
214
|
+
$scope.doreset = function (force) {
|
|
215
|
+
$scope.processing = true;
|
|
216
|
+
Message.setInfo('正在向云服务器发送重置系统指令,请稍候...');
|
|
217
|
+
Request.post('/ecs/resetinstance', {
|
|
218
|
+
'access_key_id': access_key_id,
|
|
219
|
+
'instance_name': $scope.instance_name,
|
|
220
|
+
'image_code': $scope.curimage.ImageCode
|
|
221
|
+
}, function (data) {
|
|
222
|
+
if (data.code == 0) {
|
|
223
|
+
$scope.instance.Status = data.data.InstanceStatus;
|
|
224
|
+
Timeout(function () {
|
|
225
|
+
$scope.load(true);
|
|
226
|
+
}, 1000, module);
|
|
227
|
+
}
|
|
228
|
+
$scope.processing = false;
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
$scope.diskloading = false;
|
|
233
|
+
$scope.disks = [];
|
|
234
|
+
$scope.loaddisks = function () {
|
|
235
|
+
$scope.diskloading = true;
|
|
236
|
+
Request.get('/ecs/disks?' + query, function (data) {
|
|
237
|
+
if (data.code == 0) {
|
|
238
|
+
data = data.data;
|
|
239
|
+
$scope.disks = data.disks;
|
|
240
|
+
}
|
|
241
|
+
$scope.diskloading = false;
|
|
242
|
+
}, false, Module.getSection() != 'disks');
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
$scope.snaploading = false;
|
|
246
|
+
$scope.snapshots = [];
|
|
247
|
+
$scope.loadsnapshots = function (disk, quiet) {
|
|
248
|
+
$scope.snaploading = true;
|
|
249
|
+
if (disk) $scope.curdisk = disk;
|
|
250
|
+
Request.get('/ecs/snapshots?' + query + '&disk_code=' + $scope.curdisk.DiskCode, function (data) {
|
|
251
|
+
if (data.code == 0) {
|
|
252
|
+
data = data.data;
|
|
253
|
+
$scope.snapshots = data.snapshots;
|
|
254
|
+
}
|
|
255
|
+
$scope.snaploading = false;
|
|
256
|
+
}, false, Module.getSection() != 'disks' || quiet);
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
$scope.createsnapshot = function () {
|
|
260
|
+
var s = $scope.instance.Status.toLowerCase();
|
|
261
|
+
if (s != 'stopped' && s != 'running') {
|
|
262
|
+
Message.setError('只允许在云服务器停止或正常运行状态下创建快照!');
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
$scope.confirm_title = '创建快照操作确认';
|
|
266
|
+
$scope.confirm_body = '是否要立即创建一份快照?';
|
|
267
|
+
$scope.confirm_button = '立即创建';
|
|
268
|
+
$scope.confirm = function () {
|
|
269
|
+
docreatesnapshot();
|
|
270
|
+
};
|
|
271
|
+
$scope.confirm_forcebutton = false;
|
|
272
|
+
$scope.confirm_force = false;
|
|
273
|
+
$('#confirm').modal();
|
|
274
|
+
};
|
|
275
|
+
var docreatesnapshot = function () {
|
|
276
|
+
$scope.processing = true;
|
|
277
|
+
Message.setInfo('正在发送快照创建指令,请稍候...');
|
|
278
|
+
Request.post('/ecs/createsnapshot', {
|
|
279
|
+
'access_key_id': access_key_id,
|
|
280
|
+
'instance_name': $scope.instance_name,
|
|
281
|
+
'disk_code': $scope.curdisk.DiskCode
|
|
282
|
+
}, function (data) {
|
|
283
|
+
if (data.code == 0) {
|
|
284
|
+
$scope.loadsnapshots(false, true);
|
|
285
|
+
}
|
|
286
|
+
$scope.processing = false;
|
|
287
|
+
});
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
$scope.cancelsnapshot = function (snapshot) {
|
|
291
|
+
var s = $scope.instance.Status.toLowerCase();
|
|
292
|
+
if (s != 'stopped' && s != 'running') {
|
|
293
|
+
Message.setError('只允许在云服务器停止或正常运行状态下取消快照创建!');
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
$scope.cursnapshot = snapshot;
|
|
297
|
+
$scope.confirm_title = '取消快照创建操作确认';
|
|
298
|
+
$scope.confirm_body = '是否要取消正在创建的快照?';
|
|
299
|
+
$scope.confirm_button = '确认取消';
|
|
300
|
+
$scope.confirm = function () {
|
|
301
|
+
docancelsnapshot();
|
|
302
|
+
};
|
|
303
|
+
$scope.confirm_forcebutton = false;
|
|
304
|
+
$scope.confirm_force = false;
|
|
305
|
+
$('#confirm').modal();
|
|
306
|
+
};
|
|
307
|
+
var docancelsnapshot = function () {
|
|
308
|
+
$scope.processing = true;
|
|
309
|
+
Message.setInfo('正在发送快照取消指令,请稍候...');
|
|
310
|
+
Request.post('/ecs/cancelsnapshot', {
|
|
311
|
+
'access_key_id': access_key_id,
|
|
312
|
+
'instance_name': $scope.instance_name,
|
|
313
|
+
'snapshot_code': $scope.cursnapshot.SnapshotCode
|
|
314
|
+
}, function (data) {
|
|
315
|
+
if (data.code == 0) {
|
|
316
|
+
$scope.loadsnapshots(false, true);
|
|
317
|
+
}
|
|
318
|
+
$scope.processing = false;
|
|
319
|
+
});
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
$scope.deletesnapshot = function (snapshot) {
|
|
323
|
+
var s = $scope.instance.Status.toLowerCase();
|
|
324
|
+
if (s != 'stopped' && s != 'running') {
|
|
325
|
+
Message.setError('只允许在云服务器停止或正常运行状态下删除快照!');
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
$scope.cursnapshot = snapshot;
|
|
329
|
+
$scope.confirm_title = '删除快照操作确认';
|
|
330
|
+
$scope.confirm_body = '是否要删除这个快照?';
|
|
331
|
+
$scope.confirm_button = '确认删除';
|
|
332
|
+
$scope.confirm = function () {
|
|
333
|
+
dodeletesnapshot();
|
|
334
|
+
};
|
|
335
|
+
$scope.confirm_forcebutton = false;
|
|
336
|
+
$scope.confirm_force = false;
|
|
337
|
+
$('#confirm').modal();
|
|
338
|
+
};
|
|
339
|
+
var dodeletesnapshot = function () {
|
|
340
|
+
$scope.processing = true;
|
|
341
|
+
Message.setInfo('正在发送快照删除指令,请稍候...');
|
|
342
|
+
Request.post('/ecs/deletesnapshot', {
|
|
343
|
+
'access_key_id': access_key_id,
|
|
344
|
+
'instance_name': $scope.instance_name,
|
|
345
|
+
'disk_code': $scope.curdisk.DiskCode,
|
|
346
|
+
'snapshot_code': $scope.cursnapshot.SnapshotCode
|
|
347
|
+
}, function (data) {
|
|
348
|
+
if (data.code == 0) {
|
|
349
|
+
$scope.loadsnapshots(false, true);
|
|
350
|
+
}
|
|
351
|
+
$scope.processing = false;
|
|
352
|
+
});
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
$scope.rollbacksnapshot = function (snapshot) {
|
|
356
|
+
var s = $scope.instance.Status.toLowerCase();
|
|
357
|
+
if (s != 'stopped' && s != 'running') {
|
|
358
|
+
Message.setError('只允许在云服务器停止状态下回滚快照!');
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
$scope.cursnapshot = snapshot;
|
|
362
|
+
$scope.confirm_title = '回滚快照操作确认';
|
|
363
|
+
$scope.confirm_body = '是否要将磁盘回滚到这个快照版本?';
|
|
364
|
+
$scope.confirm_button = '确认回滚';
|
|
365
|
+
$scope.confirm = function () {
|
|
366
|
+
dorollbacksnapshot();
|
|
367
|
+
};
|
|
368
|
+
$scope.confirm_forcebutton = false;
|
|
369
|
+
$scope.confirm_force = false;
|
|
370
|
+
$('#confirm').modal();
|
|
371
|
+
};
|
|
372
|
+
var dorollbacksnapshot = function () {
|
|
373
|
+
$scope.processing = true;
|
|
374
|
+
Message.setInfo('正在发送快照回滚指令,请稍候...');
|
|
375
|
+
Request.post('/ecs/rollbacksnapshot', {
|
|
376
|
+
'access_key_id': access_key_id,
|
|
377
|
+
'instance_name': $scope.instance_name,
|
|
378
|
+
'disk_code': $scope.curdisk.DiskCode,
|
|
379
|
+
'snapshot_code': $scope.cursnapshot.SnapshotCode
|
|
380
|
+
}, function (data) {
|
|
381
|
+
if (data.code == 0) {
|
|
382
|
+
$scope.loadsnapshots(false, true);
|
|
383
|
+
}
|
|
384
|
+
$scope.processing = false;
|
|
385
|
+
});
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
$scope.loadinpanel = function (quiet) {
|
|
389
|
+
Request.get('/ecs/accessinfo?instance_name=' + $scope.instance_name, function (data) {
|
|
390
|
+
if (data.code == 0) {
|
|
391
|
+
$scope.accessinfo = data.data;
|
|
392
|
+
}
|
|
393
|
+
}, false, quiet);
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
$scope.saveinpanel = function () {
|
|
397
|
+
Request.post('/ecs/accessinfo', {
|
|
398
|
+
'instance_name': $scope.instance_name,
|
|
399
|
+
'accesskey': $scope.accessinfo.accesskey,
|
|
400
|
+
'accessnet': $scope.accessinfo.accessnet,
|
|
401
|
+
'accessport': $scope.accessinfo.accessport
|
|
402
|
+
}, function (data) {
|
|
403
|
+
if (data.code == 0) {
|
|
404
|
+
$scope.loadinpanel(true);
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
$scope.genaccesskey = function () {
|
|
410
|
+
var randstring = '';
|
|
411
|
+
for (var i = 0; i < 32; i++) {
|
|
412
|
+
randstring += String.fromCharCode(Math.floor(256 * Math.random()));
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// JS base64 REF: http://stackoverflow.com/questions/246801/how-can-you-encode-to-base64-using-javascript
|
|
416
|
+
var b64encode = function (input) {
|
|
417
|
+
var b64keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
418
|
+
var output = "";
|
|
419
|
+
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
|
420
|
+
var i = 0;
|
|
421
|
+
|
|
422
|
+
while (i < input.length) {
|
|
423
|
+
|
|
424
|
+
chr1 = input.charCodeAt(i++);
|
|
425
|
+
chr2 = input.charCodeAt(i++);
|
|
426
|
+
chr3 = input.charCodeAt(i++);
|
|
427
|
+
|
|
428
|
+
enc1 = chr1 >> 2;
|
|
429
|
+
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
|
430
|
+
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
|
431
|
+
enc4 = chr3 & 63;
|
|
432
|
+
|
|
433
|
+
if (isNaN(chr2)) {
|
|
434
|
+
enc3 = enc4 = 64;
|
|
435
|
+
} else if (isNaN(chr3)) {
|
|
436
|
+
enc4 = 64;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
output = output +
|
|
440
|
+
b64keyStr.charAt(enc1) + b64keyStr.charAt(enc2) +
|
|
441
|
+
b64keyStr.charAt(enc3) + b64keyStr.charAt(enc4);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
return output;
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
$scope.accessinfo.accesskey = b64encode(randstring);
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
$scope.inpanel_install = function () {
|
|
451
|
+
if (!$scope.ssh_ip) $scope.ssh_ip = $scope.instance.PublicIpAddress.AllocateIpAddress;
|
|
452
|
+
if (!$scope.ssh_port) $scope.ssh_port = '22';
|
|
453
|
+
if (!$scope.ssh_user) $scope.ssh_user = 'root';
|
|
454
|
+
$scope.sshconfirm_title = '安装/升级 InPanel 到此服务器上';
|
|
455
|
+
$scope.sshconfirm_button = '安装或升级';
|
|
456
|
+
$scope.sshconfirm = doinstallinpanel;
|
|
457
|
+
$('#sshconfirm').modal();
|
|
458
|
+
};
|
|
459
|
+
var doinstallinpanel = function () {
|
|
460
|
+
$scope.processing = true;
|
|
461
|
+
Message.setInfo('正在安装 InPanel 到远程服务器,请稍候...');
|
|
462
|
+
Backend.call(
|
|
463
|
+
$scope,
|
|
464
|
+
module,
|
|
465
|
+
'/api/backend/inpanel_install',
|
|
466
|
+
'/api/backend/inpanel_install_' + $scope.ssh_ip, {
|
|
467
|
+
'ssh_ip': $scope.ssh_ip,
|
|
468
|
+
'ssh_port': $scope.ssh_port,
|
|
469
|
+
'ssh_user': $scope.ssh_user,
|
|
470
|
+
'ssh_password': $scope.ssh_password,
|
|
471
|
+
'instance_name': $scope.instance_name,
|
|
472
|
+
'accessnet': $scope.ssh_ip == $scope.instance.PublicIpAddress.AllocateIpAddress ? 'public' : 'inner'
|
|
473
|
+
}, {
|
|
474
|
+
'success': function (data) {
|
|
475
|
+
$scope.loadinpanel(true);
|
|
476
|
+
$scope.processing = false;
|
|
477
|
+
},
|
|
478
|
+
'error': function () {
|
|
479
|
+
$scope.processing = false;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
);
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
$scope.inpanel_uninstall = function () {
|
|
486
|
+
if (!$scope.ssh_ip) $scope.ssh_ip = $scope.instance.PublicIpAddress.AllocateIpAddress;
|
|
487
|
+
if (!$scope.ssh_port) $scope.ssh_port = '22';
|
|
488
|
+
if (!$scope.ssh_user) $scope.ssh_user = 'root';
|
|
489
|
+
$scope.sshconfirm_title = '在此服务器上卸载 InPanel';
|
|
490
|
+
$scope.sshconfirm_button = '开始卸载';
|
|
491
|
+
$scope.sshconfirm = douninstallinpanel;
|
|
492
|
+
$('#sshconfirm').modal();
|
|
493
|
+
};
|
|
494
|
+
var douninstallinpanel = function () {
|
|
495
|
+
$scope.processing = true;
|
|
496
|
+
Message.setInfo('正在从远程服务器卸载 InPanel,请稍候...');
|
|
497
|
+
Backend.call(
|
|
498
|
+
$scope,
|
|
499
|
+
module,
|
|
500
|
+
'/api/backend/inpanel_uninstall',
|
|
501
|
+
'/api/backend/inpanel_uninstall_' + $scope.ssh_ip, {
|
|
502
|
+
'ssh_ip': $scope.ssh_ip,
|
|
503
|
+
'ssh_port': $scope.ssh_port,
|
|
504
|
+
'ssh_user': $scope.ssh_user,
|
|
505
|
+
'ssh_password': $scope.ssh_password,
|
|
506
|
+
'instance_name': $scope.instance_name
|
|
507
|
+
}, {
|
|
508
|
+
'success': function (data) {
|
|
509
|
+
$scope.loadinpanel(true);
|
|
510
|
+
$scope.processing = false;
|
|
511
|
+
},
|
|
512
|
+
'error': function () {
|
|
513
|
+
$scope.processing = false;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
);
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
$scope.syncaccesskey = function () {
|
|
520
|
+
if (!$scope.ssh_ip) $scope.ssh_ip = $scope.instance.PublicIpAddress.AllocateIpAddress;
|
|
521
|
+
if (!$scope.ssh_port) $scope.ssh_port = '22';
|
|
522
|
+
if (!$scope.ssh_user) $scope.ssh_user = 'root';
|
|
523
|
+
$scope.sshconfirm_title = '同步密钥到远程服务器';
|
|
524
|
+
$scope.sshconfirm_button = '开始同步';
|
|
525
|
+
$scope.sshconfirm = doupdateinpanel;
|
|
526
|
+
$('#sshconfirm').modal();
|
|
527
|
+
};
|
|
528
|
+
var doupdateinpanel = function () {
|
|
529
|
+
$scope.processing = true;
|
|
530
|
+
Message.setInfo('正在同步密钥到远程,请稍候...');
|
|
531
|
+
Backend.call(
|
|
532
|
+
$scope,
|
|
533
|
+
module,
|
|
534
|
+
'/api/backend/inpanel_config',
|
|
535
|
+
'/api/backend/inpanel_config_' + $scope.ssh_ip, {
|
|
536
|
+
'ssh_ip': $scope.ssh_ip,
|
|
537
|
+
'ssh_port': $scope.ssh_port,
|
|
538
|
+
'ssh_user': $scope.ssh_user,
|
|
539
|
+
'ssh_password': $scope.ssh_password,
|
|
540
|
+
'instance_name': $scope.instance_name
|
|
541
|
+
}, {
|
|
542
|
+
'success': function (data) {
|
|
543
|
+
$scope.loadinpanel(true);
|
|
544
|
+
$scope.processing = false;
|
|
545
|
+
},
|
|
546
|
+
'error': function () {
|
|
547
|
+
$scope.processing = false;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
);
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
];
|
|
554
|
+
|
|
555
|
+
var ECSAccountCtrl = [
|
|
556
|
+
'$scope', '$rootScope', '$location', 'Module', 'Request',
|
|
557
|
+
function ($scope, $rootScope, $location, Module, Request) {
|
|
558
|
+
var module = 'ecs.account';
|
|
559
|
+
Module.init(module, '帐号管理');
|
|
560
|
+
$scope.accounts = [];
|
|
561
|
+
$scope.loaded = false;
|
|
562
|
+
|
|
563
|
+
$scope.load = function (quiet) {
|
|
564
|
+
Request.get('/ecs/account', function (data) {
|
|
565
|
+
if (data.code == 0) {
|
|
566
|
+
$scope.accounts = data.data;
|
|
567
|
+
}
|
|
568
|
+
$scope.loaded = true;
|
|
569
|
+
}, false, quiet);
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
$scope.addconfirm = function (account) {
|
|
573
|
+
$scope.newaccount = {
|
|
574
|
+
'name': '',
|
|
575
|
+
'access_key_id': '',
|
|
576
|
+
'access_key_secret': '',
|
|
577
|
+
'status': true
|
|
578
|
+
};
|
|
579
|
+
$('#addconfirm').modal();
|
|
580
|
+
};
|
|
581
|
+
$scope.add = function () {
|
|
582
|
+
Request.post('/ecs/account', {
|
|
583
|
+
'action': 'add',
|
|
584
|
+
'name': $scope.newaccount.name,
|
|
585
|
+
'access_key_id': $scope.newaccount.access_key_id,
|
|
586
|
+
'access_key_secret': $scope.newaccount.access_key_secret,
|
|
587
|
+
'status': $scope.newaccount.status
|
|
588
|
+
}, function () {
|
|
589
|
+
$scope.load(true);
|
|
590
|
+
});
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
$scope.editconfirm = function (account) {
|
|
594
|
+
$scope.curaccount = account;
|
|
595
|
+
$scope.curaccount.old_access_key_id = account.access_key_id;
|
|
596
|
+
$('#editconfirm').modal();
|
|
597
|
+
};
|
|
598
|
+
$scope.update = function () {
|
|
599
|
+
Request.post('/ecs/account', {
|
|
600
|
+
'action': 'update',
|
|
601
|
+
'old_access_key_id': $scope.curaccount.old_access_key_id,
|
|
602
|
+
'name': $scope.curaccount.name,
|
|
603
|
+
'access_key_id': $scope.curaccount.access_key_id,
|
|
604
|
+
'access_key_secret': $scope.curaccount.access_key_secret,
|
|
605
|
+
'status': $scope.curaccount.status
|
|
606
|
+
}, function () {
|
|
607
|
+
$scope.load(true);
|
|
608
|
+
});
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
$scope.removeconfirm = function (account) {
|
|
612
|
+
$scope.curaccount = account;
|
|
613
|
+
$('#removeconfirm').modal();
|
|
614
|
+
};
|
|
615
|
+
$scope.remove = function () {
|
|
616
|
+
Request.post('/ecs/account', {
|
|
617
|
+
'action': 'delete',
|
|
618
|
+
'access_key_id': $scope.curaccount.access_key_id
|
|
619
|
+
}, function () {
|
|
620
|
+
$scope.load(true);
|
|
621
|
+
});
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
];
|