]> git.proxmox.com Git - pve-container.git/blob - src/PVE/API2/LXC.pm
update_lxc_config: remove unused parameter
[pve-container.git] / src / PVE / API2 / LXC.pm
1 package PVE::API2::LXC;
2
3 use strict;
4 use warnings;
5
6 use PVE::SafeSyslog;
7 use PVE::Tools qw(extract_param run_command);
8 use PVE::Exception qw(raise raise_param_exc);
9 use PVE::INotify;
10 use PVE::Cluster qw(cfs_read_file);
11 use PVE::AccessControl;
12 use PVE::Firewall;
13 use PVE::Storage;
14 use PVE::RESTHandler;
15 use PVE::RPCEnvironment;
16 use PVE::LXC;
17 use PVE::LXC::Create;
18 use PVE::LXC::Migrate;
19 use PVE::API2::LXC::Config;
20 use PVE::API2::LXC::Status;
21 use PVE::API2::LXC::Snapshot;
22 use PVE::HA::Env::PVE2;
23 use PVE::HA::Config;
24 use PVE::JSONSchema qw(get_standard_option);
25 use base qw(PVE::RESTHandler);
26
27 use Data::Dumper; # fixme: remove
28
29 __PACKAGE__->register_method ({
30 subclass => "PVE::API2::LXC::Config",
31 path => '{vmid}/config',
32 });
33
34 __PACKAGE__->register_method ({
35 subclass => "PVE::API2::LXC::Status",
36 path => '{vmid}/status',
37 });
38
39 __PACKAGE__->register_method ({
40 subclass => "PVE::API2::LXC::Snapshot",
41 path => '{vmid}/snapshot',
42 });
43
44 __PACKAGE__->register_method ({
45 subclass => "PVE::API2::Firewall::CT",
46 path => '{vmid}/firewall',
47 });
48
49 __PACKAGE__->register_method({
50 name => 'vmlist',
51 path => '',
52 method => 'GET',
53 description => "LXC container index (per node).",
54 permissions => {
55 description => "Only list CTs where you have VM.Audit permissons on /vms/<vmid>.",
56 user => 'all',
57 },
58 proxyto => 'node',
59 protected => 1, # /proc files are only readable by root
60 parameters => {
61 additionalProperties => 0,
62 properties => {
63 node => get_standard_option('pve-node'),
64 },
65 },
66 returns => {
67 type => 'array',
68 items => {
69 type => "object",
70 properties => {},
71 },
72 links => [ { rel => 'child', href => "{vmid}" } ],
73 },
74 code => sub {
75 my ($param) = @_;
76
77 my $rpcenv = PVE::RPCEnvironment::get();
78 my $authuser = $rpcenv->get_user();
79
80 my $vmstatus = PVE::LXC::vmstatus();
81
82 my $res = [];
83 foreach my $vmid (keys %$vmstatus) {
84 next if !$rpcenv->check($authuser, "/vms/$vmid", [ 'VM.Audit' ], 1);
85
86 my $data = $vmstatus->{$vmid};
87 $data->{vmid} = $vmid;
88 push @$res, $data;
89 }
90
91 return $res;
92
93 }});
94
95 __PACKAGE__->register_method({
96 name => 'create_vm',
97 path => '',
98 method => 'POST',
99 description => "Create or restore a container.",
100 permissions => {
101 user => 'all', # check inside
102 description => "You need 'VM.Allocate' permissions on /vms/{vmid} or on the VM pool /pool/{pool}. " .
103 "For restore, it is enough if the user has 'VM.Backup' permission and the VM already exists. " .
104 "You also need 'Datastore.AllocateSpace' permissions on the storage.",
105 },
106 protected => 1,
107 proxyto => 'node',
108 parameters => {
109 additionalProperties => 0,
110 properties => PVE::LXC::Config->json_config_properties({
111 node => get_standard_option('pve-node'),
112 vmid => get_standard_option('pve-vmid', { completion => \&PVE::Cluster::complete_next_vmid }),
113 ostemplate => {
114 description => "The OS template or backup file.",
115 type => 'string',
116 maxLength => 255,
117 completion => \&PVE::LXC::complete_os_templates,
118 },
119 password => {
120 optional => 1,
121 type => 'string',
122 description => "Sets root password inside container.",
123 minLength => 5,
124 },
125 storage => get_standard_option('pve-storage-id', {
126 description => "Default Storage.",
127 default => 'local',
128 optional => 1,
129 completion => \&PVE::Storage::complete_storage_enabled,
130 }),
131 force => {
132 optional => 1,
133 type => 'boolean',
134 description => "Allow to overwrite existing container.",
135 },
136 restore => {
137 optional => 1,
138 type => 'boolean',
139 description => "Mark this as restore task.",
140 },
141 pool => {
142 optional => 1,
143 type => 'string', format => 'pve-poolid',
144 description => "Add the VM to the specified pool.",
145 },
146 'ignore-unpack-errors' => {
147 optional => 1,
148 type => 'boolean',
149 description => "Ignore errors when extracting the template.",
150 },
151 'ssh-public-keys' => {
152 optional => 1,
153 type => 'string',
154 description => "Setup public SSH keys (one key per line, " .
155 "OpenSSH format).",
156 },
157 }),
158 },
159 returns => {
160 type => 'string',
161 },
162 code => sub {
163 my ($param) = @_;
164
165 my $rpcenv = PVE::RPCEnvironment::get();
166
167 my $authuser = $rpcenv->get_user();
168
169 my $node = extract_param($param, 'node');
170
171 my $vmid = extract_param($param, 'vmid');
172
173 my $ignore_unpack_errors = extract_param($param, 'ignore-unpack-errors');
174
175 my $basecfg_fn = PVE::LXC::Config->config_file($vmid);
176
177 my $same_container_exists = -f $basecfg_fn;
178
179 # 'unprivileged' is read-only, so we can't pass it to update_pct_config
180 my $unprivileged = extract_param($param, 'unprivileged');
181
182 my $restore = extract_param($param, 'restore');
183
184 if ($restore) {
185 # fixme: limit allowed parameters
186
187 }
188
189 my $force = extract_param($param, 'force');
190
191 if (!($same_container_exists && $restore && $force)) {
192 PVE::Cluster::check_vmid_unused($vmid);
193 } else {
194 my $conf = PVE::LXC::Config->load_config($vmid);
195 PVE::LXC::Config->check_protection($conf, "unable to restore CT $vmid");
196 }
197
198 my $password = extract_param($param, 'password');
199
200 my $ssh_keys = extract_param($param, 'ssh-public-keys');
201 PVE::Tools::validate_ssh_public_keys($ssh_keys) if defined($ssh_keys);
202
203 my $pool = extract_param($param, 'pool');
204
205 if (defined($pool)) {
206 $rpcenv->check_pool_exist($pool);
207 $rpcenv->check_perm_modify($authuser, "/pool/$pool");
208 }
209
210 if ($rpcenv->check($authuser, "/vms/$vmid", ['VM.Allocate'], 1)) {
211 # OK
212 } elsif ($pool && $rpcenv->check($authuser, "/pool/$pool", ['VM.Allocate'], 1)) {
213 # OK
214 } elsif ($restore && $force && $same_container_exists &&
215 $rpcenv->check($authuser, "/vms/$vmid", ['VM.Backup'], 1)) {
216 # OK: user has VM.Backup permissions, and want to restore an existing VM
217 } else {
218 raise_perm_exc();
219 }
220
221 PVE::LXC::check_ct_modify_config_perm($rpcenv, $authuser, $vmid, $pool, $param, []);
222
223 my $storage = extract_param($param, 'storage') // 'local';
224
225 my $storage_cfg = cfs_read_file("storage.cfg");
226
227 my $ostemplate = extract_param($param, 'ostemplate');
228
229 my $archive;
230
231 if ($ostemplate eq '-') {
232 die "pipe requires cli environment\n"
233 if $rpcenv->{type} ne 'cli';
234 die "pipe can only be used with restore tasks\n"
235 if !$restore;
236 $archive = '-';
237 die "restore from pipe requires rootfs parameter\n" if !defined($param->{rootfs});
238 } else {
239 $rpcenv->check_volume_access($authuser, $storage_cfg, $vmid, $ostemplate);
240 $archive = PVE::Storage::abs_filesystem_path($storage_cfg, $ostemplate);
241 }
242
243 my $check_and_activate_storage = sub {
244 my ($sid) = @_;
245
246 my $scfg = PVE::Storage::storage_check_node($storage_cfg, $sid, $node);
247
248 raise_param_exc({ storage => "storage '$sid' does not support container directories"})
249 if !$scfg->{content}->{rootdir};
250
251 $rpcenv->check($authuser, "/storage/$sid", ['Datastore.AllocateSpace']);
252
253 PVE::Storage::activate_storage($storage_cfg, $sid);
254 };
255
256 my $conf = {};
257
258 my $no_disk_param = {};
259 my $mp_param = {};
260 my $storage_only_mode = 1;
261 foreach my $opt (keys %$param) {
262 my $value = $param->{$opt};
263 if ($opt eq 'rootfs' || $opt =~ m/^mp\d+$/) {
264 # allow to use simple numbers (add default storage in that case)
265 if ($value =~ m/^\d+(\.\d+)?$/) {
266 $mp_param->{$opt} = "$storage:$value";
267 } else {
268 $mp_param->{$opt} = $value;
269 }
270 $storage_only_mode = 0;
271 } elsif ($opt =~ m/^unused\d+$/) {
272 warn "ignoring '$opt', cannot create/restore with unused volume\n";
273 delete $param->{$opt};
274 } else {
275 $no_disk_param->{$opt} = $value;
276 }
277 }
278
279 die "mountpoints configured, but 'rootfs' not set - aborting\n"
280 if !$storage_only_mode && !defined($mp_param->{rootfs});
281
282 # check storage access, activate storage
283 my $delayed_mp_param = {};
284 PVE::LXC::Config->foreach_mountpoint($mp_param, sub {
285 my ($ms, $mountpoint) = @_;
286
287 my $volid = $mountpoint->{volume};
288 my $mp = $mountpoint->{mp};
289
290 if ($mountpoint->{type} ne 'volume') { # bind or device
291 die "Only root can pass arbitrary filesystem paths.\n"
292 if $authuser ne 'root@pam';
293 } else {
294 my ($sid, $volname) = PVE::Storage::parse_volume_id($volid);
295 &$check_and_activate_storage($sid);
296 }
297 });
298
299 # check/activate default storage
300 &$check_and_activate_storage($storage) if !defined($mp_param->{rootfs});
301
302 PVE::LXC::Config->update_pct_config($vmid, $conf, 0, $no_disk_param);
303
304 $conf->{unprivileged} = 1 if $unprivileged;
305
306 my $check_vmid_usage = sub {
307 if ($force) {
308 die "can't overwrite running container\n"
309 if PVE::LXC::check_running($vmid);
310 } else {
311 PVE::Cluster::check_vmid_unused($vmid);
312 }
313 };
314
315 my $code = sub {
316 &$check_vmid_usage(); # final check after locking
317 my $old_conf;
318
319 my $config_fn = PVE::LXC::Config->config_file($vmid);
320 if (-f $config_fn) {
321 die "container exists" if !$restore; # just to be sure
322 $old_conf = PVE::LXC::Config->load_config($vmid);
323 } else {
324 eval {
325 # try to create empty config on local node, we have an flock
326 PVE::LXC::Config->write_config($vmid, {});
327 };
328
329 # another node was faster, abort
330 die "Could not reserve ID $vmid, already taken\n" if $@;
331 }
332
333 PVE::Cluster::check_cfs_quorum();
334 my $vollist = [];
335
336 eval {
337 if ($storage_only_mode) {
338 if ($restore) {
339 (undef, $mp_param) = PVE::LXC::Create::recover_config($archive);
340 die "rootfs configuration could not be recovered, please check and specify manually!\n"
341 if !defined($mp_param->{rootfs});
342 PVE::LXC::Config->foreach_mountpoint($mp_param, sub {
343 my ($ms, $mountpoint) = @_;
344 my $type = $mountpoint->{type};
345 if ($type eq 'volume') {
346 die "unable to detect disk size - please specify $ms (size)\n"
347 if !defined($mountpoint->{size});
348 my $disksize = $mountpoint->{size} / (1024 * 1024 * 1024); # create_disks expects GB as unit size
349 delete $mountpoint->{size};
350 $mountpoint->{volume} = "$storage:$disksize";
351 $mp_param->{$ms} = PVE::LXC::Config->print_ct_mountpoint($mountpoint, $ms eq 'rootfs');
352 } else {
353 my $type = $mountpoint->{type};
354 die "restoring rootfs to $type mount is only possible by specifying -rootfs manually!\n"
355 if ($ms eq 'rootfs');
356
357 if ($mountpoint->{backup}) {
358 warn "WARNING - unsupported configuration!\n";
359 warn "backup was enabled for $type mountpoint $ms ('$mountpoint->{mp}')\n";
360 warn "mountpoint configuration will be restored after archive extraction!\n";
361 warn "contained files will be restored to wrong directory!\n";
362 }
363 $delayed_mp_param->{$ms} = PVE::LXC::Config->print_ct_mountpoint($mountpoint, $ms eq 'rootfs');
364 }
365 });
366 } else {
367 $mp_param->{rootfs} = "$storage:4"; # defaults to 4GB
368 }
369 }
370
371 $vollist = PVE::LXC::create_disks($storage_cfg, $vmid, $mp_param, $conf);
372
373 if (defined($old_conf)) {
374 # destroy old container volumes
375 PVE::LXC::destroy_lxc_container($storage_cfg, $vmid, $old_conf, {});
376 }
377
378 eval {
379 my $rootdir = PVE::LXC::mount_all($vmid, $storage_cfg, $conf, 1);
380 PVE::LXC::Create::restore_archive($archive, $rootdir, $conf, $ignore_unpack_errors);
381
382 if ($restore) {
383 PVE::LXC::Create::restore_configuration($vmid, $rootdir, $conf);
384 } else {
385 my $lxc_setup = PVE::LXC::Setup->new($conf, $rootdir); # detect OS
386 PVE::LXC::Config->write_config($vmid, $conf); # safe config (after OS detection)
387 $lxc_setup->post_create_hook($password, $ssh_keys);
388 }
389 };
390 my $err = $@;
391 PVE::LXC::umount_all($vmid, $storage_cfg, $conf, $err ? 1 : 0);
392 PVE::Storage::deactivate_volumes($storage_cfg, PVE::LXC::Config->get_vm_volumes($conf));
393 die $err if $err;
394 # set some defaults
395 $conf->{hostname} ||= "CT$vmid";
396 $conf->{memory} ||= 512;
397 $conf->{swap} //= 512;
398 foreach my $mp (keys %$delayed_mp_param) {
399 $conf->{$mp} = $delayed_mp_param->{$mp};
400 }
401 PVE::LXC::Config->write_config($vmid, $conf);
402 };
403 if (my $err = $@) {
404 PVE::LXC::destroy_disks($storage_cfg, $vollist);
405 PVE::LXC::destroy_config($vmid);
406 die $err;
407 }
408 PVE::AccessControl::add_vm_to_pool($vmid, $pool) if $pool;
409 };
410
411 my $realcmd = sub { PVE::LXC::Config->lock_config($vmid, $code); };
412
413 &$check_vmid_usage(); # first check before locking
414
415 return $rpcenv->fork_worker($restore ? 'vzrestore' : 'vzcreate',
416 $vmid, $authuser, $realcmd);
417
418 }});
419
420 __PACKAGE__->register_method({
421 name => 'vmdiridx',
422 path => '{vmid}',
423 method => 'GET',
424 proxyto => 'node',
425 description => "Directory index",
426 permissions => {
427 user => 'all',
428 },
429 parameters => {
430 additionalProperties => 0,
431 properties => {
432 node => get_standard_option('pve-node'),
433 vmid => get_standard_option('pve-vmid'),
434 },
435 },
436 returns => {
437 type => 'array',
438 items => {
439 type => "object",
440 properties => {
441 subdir => { type => 'string' },
442 },
443 },
444 links => [ { rel => 'child', href => "{subdir}" } ],
445 },
446 code => sub {
447 my ($param) = @_;
448
449 # test if VM exists
450 my $conf = PVE::LXC::Config->load_config($param->{vmid});
451
452 my $res = [
453 { subdir => 'config' },
454 { subdir => 'status' },
455 { subdir => 'vncproxy' },
456 { subdir => 'vncwebsocket' },
457 { subdir => 'spiceproxy' },
458 { subdir => 'migrate' },
459 { subdir => 'clone' },
460 # { subdir => 'initlog' },
461 { subdir => 'rrd' },
462 { subdir => 'rrddata' },
463 { subdir => 'firewall' },
464 { subdir => 'snapshot' },
465 { subdir => 'resize' },
466 ];
467
468 return $res;
469 }});
470
471
472 __PACKAGE__->register_method({
473 name => 'rrd',
474 path => '{vmid}/rrd',
475 method => 'GET',
476 protected => 1, # fixme: can we avoid that?
477 permissions => {
478 check => ['perm', '/vms/{vmid}', [ 'VM.Audit' ]],
479 },
480 description => "Read VM RRD statistics (returns PNG)",
481 parameters => {
482 additionalProperties => 0,
483 properties => {
484 node => get_standard_option('pve-node'),
485 vmid => get_standard_option('pve-vmid'),
486 timeframe => {
487 description => "Specify the time frame you are interested in.",
488 type => 'string',
489 enum => [ 'hour', 'day', 'week', 'month', 'year' ],
490 },
491 ds => {
492 description => "The list of datasources you want to display.",
493 type => 'string', format => 'pve-configid-list',
494 },
495 cf => {
496 description => "The RRD consolidation function",
497 type => 'string',
498 enum => [ 'AVERAGE', 'MAX' ],
499 optional => 1,
500 },
501 },
502 },
503 returns => {
504 type => "object",
505 properties => {
506 filename => { type => 'string' },
507 },
508 },
509 code => sub {
510 my ($param) = @_;
511
512 return PVE::Cluster::create_rrd_graph(
513 "pve2-vm/$param->{vmid}", $param->{timeframe},
514 $param->{ds}, $param->{cf});
515
516 }});
517
518 __PACKAGE__->register_method({
519 name => 'rrddata',
520 path => '{vmid}/rrddata',
521 method => 'GET',
522 protected => 1, # fixme: can we avoid that?
523 permissions => {
524 check => ['perm', '/vms/{vmid}', [ 'VM.Audit' ]],
525 },
526 description => "Read VM RRD statistics",
527 parameters => {
528 additionalProperties => 0,
529 properties => {
530 node => get_standard_option('pve-node'),
531 vmid => get_standard_option('pve-vmid'),
532 timeframe => {
533 description => "Specify the time frame you are interested in.",
534 type => 'string',
535 enum => [ 'hour', 'day', 'week', 'month', 'year' ],
536 },
537 cf => {
538 description => "The RRD consolidation function",
539 type => 'string',
540 enum => [ 'AVERAGE', 'MAX' ],
541 optional => 1,
542 },
543 },
544 },
545 returns => {
546 type => "array",
547 items => {
548 type => "object",
549 properties => {},
550 },
551 },
552 code => sub {
553 my ($param) = @_;
554
555 return PVE::Cluster::create_rrd_data(
556 "pve2-vm/$param->{vmid}", $param->{timeframe}, $param->{cf});
557 }});
558
559 __PACKAGE__->register_method({
560 name => 'destroy_vm',
561 path => '{vmid}',
562 method => 'DELETE',
563 protected => 1,
564 proxyto => 'node',
565 description => "Destroy the container (also delete all uses files).",
566 permissions => {
567 check => [ 'perm', '/vms/{vmid}', ['VM.Allocate']],
568 },
569 parameters => {
570 additionalProperties => 0,
571 properties => {
572 node => get_standard_option('pve-node'),
573 vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid_stopped }),
574 },
575 },
576 returns => {
577 type => 'string',
578 },
579 code => sub {
580 my ($param) = @_;
581
582 my $rpcenv = PVE::RPCEnvironment::get();
583
584 my $authuser = $rpcenv->get_user();
585
586 my $vmid = $param->{vmid};
587
588 # test if container exists
589 my $conf = PVE::LXC::Config->load_config($vmid);
590
591 my $storage_cfg = cfs_read_file("storage.cfg");
592
593 PVE::LXC::Config->check_protection($conf, "can't remove CT $vmid");
594
595 die "unable to remove CT $vmid - used in HA resources\n"
596 if PVE::HA::Config::vm_is_ha_managed($vmid);
597
598 my $running_error_msg = "unable to destroy CT $vmid - container is running\n";
599
600 die $running_error_msg if PVE::LXC::check_running($vmid); # check early
601
602 my $code = sub {
603 # reload config after lock
604 $conf = PVE::LXC::Config->load_config($vmid);
605 PVE::LXC::Config->check_lock($conf);
606
607 die $running_error_msg if PVE::LXC::check_running($vmid);
608
609 PVE::LXC::destroy_lxc_container($storage_cfg, $vmid, $conf);
610 PVE::AccessControl::remove_vm_access($vmid);
611 PVE::Firewall::remove_vmfw_conf($vmid);
612 };
613
614 my $realcmd = sub { PVE::LXC::Config->lock_config($vmid, $code); };
615
616 return $rpcenv->fork_worker('vzdestroy', $vmid, $authuser, $realcmd);
617 }});
618
619 my $sslcert;
620
621 __PACKAGE__->register_method ({
622 name => 'vncproxy',
623 path => '{vmid}/vncproxy',
624 method => 'POST',
625 protected => 1,
626 permissions => {
627 check => ['perm', '/vms/{vmid}', [ 'VM.Console' ]],
628 },
629 description => "Creates a TCP VNC proxy connections.",
630 parameters => {
631 additionalProperties => 0,
632 properties => {
633 node => get_standard_option('pve-node'),
634 vmid => get_standard_option('pve-vmid'),
635 websocket => {
636 optional => 1,
637 type => 'boolean',
638 description => "use websocket instead of standard VNC.",
639 },
640 },
641 },
642 returns => {
643 additionalProperties => 0,
644 properties => {
645 user => { type => 'string' },
646 ticket => { type => 'string' },
647 cert => { type => 'string' },
648 port => { type => 'integer' },
649 upid => { type => 'string' },
650 },
651 },
652 code => sub {
653 my ($param) = @_;
654
655 my $rpcenv = PVE::RPCEnvironment::get();
656
657 my $authuser = $rpcenv->get_user();
658
659 my $vmid = $param->{vmid};
660 my $node = $param->{node};
661
662 my $authpath = "/vms/$vmid";
663
664 my $ticket = PVE::AccessControl::assemble_vnc_ticket($authuser, $authpath);
665
666 $sslcert = PVE::Tools::file_get_contents("/etc/pve/pve-root-ca.pem", 8192)
667 if !$sslcert;
668
669 my ($remip, $family);
670
671 if ($node ne PVE::INotify::nodename()) {
672 ($remip, $family) = PVE::Cluster::remote_node_ip($node);
673 } else {
674 $family = PVE::Tools::get_host_address_family($node);
675 }
676
677 my $port = PVE::Tools::next_vnc_port($family);
678
679 # NOTE: vncterm VNC traffic is already TLS encrypted,
680 # so we select the fastest chipher here (or 'none'?)
681 my $remcmd = $remip ?
682 ['/usr/bin/ssh', '-t', $remip] : [];
683
684 my $conf = PVE::LXC::Config->load_config($vmid, $node);
685 my $concmd = PVE::LXC::get_console_command($vmid, $conf);
686
687 my $shcmd = [ '/usr/bin/dtach', '-A',
688 "/var/run/dtach/vzctlconsole$vmid",
689 '-r', 'winch', '-z', @$concmd];
690
691 my $realcmd = sub {
692 my $upid = shift;
693
694 syslog ('info', "starting lxc vnc proxy $upid\n");
695
696 my $timeout = 10;
697
698 my $cmd = ['/usr/bin/vncterm', '-rfbport', $port,
699 '-timeout', $timeout, '-authpath', $authpath,
700 '-perm', 'VM.Console'];
701
702 if ($param->{websocket}) {
703 $ENV{PVE_VNC_TICKET} = $ticket; # pass ticket to vncterm
704 push @$cmd, '-notls', '-listen', 'localhost';
705 }
706
707 push @$cmd, '-c', @$remcmd, @$shcmd;
708
709 run_command($cmd);
710
711 return;
712 };
713
714 my $upid = $rpcenv->fork_worker('vncproxy', $vmid, $authuser, $realcmd);
715
716 PVE::Tools::wait_for_vnc_port($port);
717
718 return {
719 user => $authuser,
720 ticket => $ticket,
721 port => $port,
722 upid => $upid,
723 cert => $sslcert,
724 };
725 }});
726
727 __PACKAGE__->register_method({
728 name => 'vncwebsocket',
729 path => '{vmid}/vncwebsocket',
730 method => 'GET',
731 permissions => {
732 description => "You also need to pass a valid ticket (vncticket).",
733 check => ['perm', '/vms/{vmid}', [ 'VM.Console' ]],
734 },
735 description => "Opens a weksocket for VNC traffic.",
736 parameters => {
737 additionalProperties => 0,
738 properties => {
739 node => get_standard_option('pve-node'),
740 vmid => get_standard_option('pve-vmid'),
741 vncticket => {
742 description => "Ticket from previous call to vncproxy.",
743 type => 'string',
744 maxLength => 512,
745 },
746 port => {
747 description => "Port number returned by previous vncproxy call.",
748 type => 'integer',
749 minimum => 5900,
750 maximum => 5999,
751 },
752 },
753 },
754 returns => {
755 type => "object",
756 properties => {
757 port => { type => 'string' },
758 },
759 },
760 code => sub {
761 my ($param) = @_;
762
763 my $rpcenv = PVE::RPCEnvironment::get();
764
765 my $authuser = $rpcenv->get_user();
766
767 my $authpath = "/vms/$param->{vmid}";
768
769 PVE::AccessControl::verify_vnc_ticket($param->{vncticket}, $authuser, $authpath);
770
771 my $port = $param->{port};
772
773 return { port => $port };
774 }});
775
776 __PACKAGE__->register_method ({
777 name => 'spiceproxy',
778 path => '{vmid}/spiceproxy',
779 method => 'POST',
780 protected => 1,
781 proxyto => 'node',
782 permissions => {
783 check => ['perm', '/vms/{vmid}', [ 'VM.Console' ]],
784 },
785 description => "Returns a SPICE configuration to connect to the CT.",
786 parameters => {
787 additionalProperties => 0,
788 properties => {
789 node => get_standard_option('pve-node'),
790 vmid => get_standard_option('pve-vmid'),
791 proxy => get_standard_option('spice-proxy', { optional => 1 }),
792 },
793 },
794 returns => get_standard_option('remote-viewer-config'),
795 code => sub {
796 my ($param) = @_;
797
798 my $vmid = $param->{vmid};
799 my $node = $param->{node};
800 my $proxy = $param->{proxy};
801
802 my $authpath = "/vms/$vmid";
803 my $permissions = 'VM.Console';
804
805 my $conf = PVE::LXC::Config->load_config($vmid);
806
807 die "CT $vmid not running\n" if !PVE::LXC::check_running($vmid);
808
809 my $concmd = PVE::LXC::get_console_command($vmid, $conf);
810
811 my $shcmd = ['/usr/bin/dtach', '-A',
812 "/var/run/dtach/vzctlconsole$vmid",
813 '-r', 'winch', '-z', @$concmd];
814
815 my $title = "CT $vmid";
816
817 return PVE::API2Tools::run_spiceterm($authpath, $permissions, $vmid, $node, $proxy, $title, $shcmd);
818 }});
819
820
821 __PACKAGE__->register_method({
822 name => 'migrate_vm',
823 path => '{vmid}/migrate',
824 method => 'POST',
825 protected => 1,
826 proxyto => 'node',
827 description => "Migrate the container to another node. Creates a new migration task.",
828 permissions => {
829 check => ['perm', '/vms/{vmid}', [ 'VM.Migrate' ]],
830 },
831 parameters => {
832 additionalProperties => 0,
833 properties => {
834 node => get_standard_option('pve-node'),
835 vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid }),
836 target => get_standard_option('pve-node', {
837 description => "Target node.",
838 completion => \&PVE::Cluster::complete_migration_target,
839 }),
840 online => {
841 type => 'boolean',
842 description => "Use online/live migration.",
843 optional => 1,
844 },
845 force => {
846 type => 'boolean',
847 description => "Force migration despite local bind / device" .
848 " mounts. WARNING: identical bind / device mounts need to ".
849 " be available on the target node.",
850 optional => 1,
851 },
852 },
853 },
854 returns => {
855 type => 'string',
856 description => "the task ID.",
857 },
858 code => sub {
859 my ($param) = @_;
860
861 my $rpcenv = PVE::RPCEnvironment::get();
862
863 my $authuser = $rpcenv->get_user();
864
865 my $target = extract_param($param, 'target');
866
867 my $localnode = PVE::INotify::nodename();
868 raise_param_exc({ target => "target is local node."}) if $target eq $localnode;
869
870 PVE::Cluster::check_cfs_quorum();
871
872 PVE::Cluster::check_node_exists($target);
873
874 my $targetip = PVE::Cluster::remote_node_ip($target);
875
876 my $vmid = extract_param($param, 'vmid');
877
878 # test if VM exists
879 PVE::LXC::Config->load_config($vmid);
880
881 # try to detect errors early
882 if (PVE::LXC::check_running($vmid)) {
883 die "can't migrate running container without --online\n"
884 if !$param->{online};
885 }
886
887 if (PVE::HA::Config::vm_is_ha_managed($vmid) && $rpcenv->{type} ne 'ha') {
888
889 my $hacmd = sub {
890 my $upid = shift;
891
892 my $service = "ct:$vmid";
893
894 my $cmd = ['ha-manager', 'migrate', $service, $target];
895
896 print "Executing HA migrate for CT $vmid to node $target\n";
897
898 PVE::Tools::run_command($cmd);
899
900 return;
901 };
902
903 return $rpcenv->fork_worker('hamigrate', $vmid, $authuser, $hacmd);
904
905 } else {
906
907 my $realcmd = sub {
908 my $upid = shift;
909
910 PVE::LXC::Migrate->migrate($target, $targetip, $vmid, $param);
911
912 return;
913 };
914
915 return $rpcenv->fork_worker('vzmigrate', $vmid, $authuser, $realcmd);
916 }
917 }});
918
919 __PACKAGE__->register_method({
920 name => 'vm_feature',
921 path => '{vmid}/feature',
922 method => 'GET',
923 proxyto => 'node',
924 protected => 1,
925 description => "Check if feature for virtual machine is available.",
926 permissions => {
927 check => ['perm', '/vms/{vmid}', [ 'VM.Audit' ]],
928 },
929 parameters => {
930 additionalProperties => 0,
931 properties => {
932 node => get_standard_option('pve-node'),
933 vmid => get_standard_option('pve-vmid'),
934 feature => {
935 description => "Feature to check.",
936 type => 'string',
937 enum => [ 'snapshot' ],
938 },
939 snapname => get_standard_option('pve-lxc-snapshot-name', {
940 optional => 1,
941 }),
942 },
943 },
944 returns => {
945 type => "object",
946 properties => {
947 hasFeature => { type => 'boolean' },
948 #nodes => {
949 #type => 'array',
950 #items => { type => 'string' },
951 #}
952 },
953 },
954 code => sub {
955 my ($param) = @_;
956
957 my $node = extract_param($param, 'node');
958
959 my $vmid = extract_param($param, 'vmid');
960
961 my $snapname = extract_param($param, 'snapname');
962
963 my $feature = extract_param($param, 'feature');
964
965 my $conf = PVE::LXC::Config->load_config($vmid);
966
967 if($snapname){
968 my $snap = $conf->{snapshots}->{$snapname};
969 die "snapshot '$snapname' does not exist\n" if !defined($snap);
970 $conf = $snap;
971 }
972 my $storage_cfg = PVE::Storage::config();
973 #Maybe include later
974 #my $nodelist = PVE::LXC::shared_nodes($conf, $storage_cfg);
975 my $hasFeature = PVE::LXC::Config->has_feature($feature, $conf, $storage_cfg, $snapname);
976
977 return {
978 hasFeature => $hasFeature,
979 #nodes => [ keys %$nodelist ],
980 };
981 }});
982
983 __PACKAGE__->register_method({
984 name => 'template',
985 path => '{vmid}/template',
986 method => 'POST',
987 protected => 1,
988 proxyto => 'node',
989 description => "Create a Template.",
990 permissions => {
991 description => "You need 'VM.Allocate' permissions on /vms/{vmid}",
992 check => [ 'perm', '/vms/{vmid}', ['VM.Allocate']],
993 },
994 parameters => {
995 additionalProperties => 0,
996 properties => {
997 node => get_standard_option('pve-node'),
998 vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid_stopped }),
999 experimental => {
1000 type => 'boolean',
1001 description => "The template feature is experimental, set this " .
1002 "flag if you know what you are doing.",
1003 default => 0,
1004 },
1005 },
1006 },
1007 returns => { type => 'null'},
1008 code => sub {
1009 my ($param) = @_;
1010
1011 my $rpcenv = PVE::RPCEnvironment::get();
1012
1013 my $authuser = $rpcenv->get_user();
1014
1015 my $node = extract_param($param, 'node');
1016
1017 my $vmid = extract_param($param, 'vmid');
1018
1019 my $updatefn = sub {
1020
1021 my $conf = PVE::LXC::Config->load_config($vmid);
1022 PVE::LXC::Config->check_lock($conf);
1023
1024 die "unable to create template, because CT contains snapshots\n"
1025 if $conf->{snapshots} && scalar(keys %{$conf->{snapshots}});
1026
1027 die "you can't convert a template to a template\n"
1028 if PVE::LXC::Config->is_template($conf);
1029
1030 die "you can't convert a CT to template if the CT is running\n"
1031 if PVE::LXC::check_running($vmid);
1032
1033 my $realcmd = sub {
1034 PVE::LXC::template_create($vmid, $conf);
1035 };
1036
1037 $conf->{template} = 1;
1038
1039 PVE::LXC::Config->write_config($vmid, $conf);
1040 # and remove lxc config
1041 PVE::LXC::update_lxc_config($vmid, $conf);
1042
1043 return $rpcenv->fork_worker('vztemplate', $vmid, $authuser, $realcmd);
1044 };
1045
1046 PVE::LXC::Config->lock_config($vmid, $updatefn);
1047
1048 return undef;
1049 }});
1050
1051 __PACKAGE__->register_method({
1052 name => 'clone_vm',
1053 path => '{vmid}/clone',
1054 method => 'POST',
1055 protected => 1,
1056 proxyto => 'node',
1057 description => "Create a container clone/copy",
1058 permissions => {
1059 description => "You need 'VM.Clone' permissions on /vms/{vmid}, " .
1060 "and 'VM.Allocate' permissions " .
1061 "on /vms/{newid} (or on the VM pool /pool/{pool}). You also need " .
1062 "'Datastore.AllocateSpace' on any used storage.",
1063 check =>
1064 [ 'and',
1065 ['perm', '/vms/{vmid}', [ 'VM.Clone' ]],
1066 [ 'or',
1067 [ 'perm', '/vms/{newid}', ['VM.Allocate']],
1068 [ 'perm', '/pool/{pool}', ['VM.Allocate'], require_param => 'pool'],
1069 ],
1070 ]
1071 },
1072 parameters => {
1073 additionalProperties => 0,
1074 properties => {
1075 node => get_standard_option('pve-node'),
1076 vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid }),
1077 newid => get_standard_option('pve-vmid', {
1078 completion => \&PVE::Cluster::complete_next_vmid,
1079 description => 'VMID for the clone.' }),
1080 hostname => {
1081 optional => 1,
1082 type => 'string', format => 'dns-name',
1083 description => "Set a hostname for the new CT.",
1084 },
1085 description => {
1086 optional => 1,
1087 type => 'string',
1088 description => "Description for the new CT.",
1089 },
1090 pool => {
1091 optional => 1,
1092 type => 'string', format => 'pve-poolid',
1093 description => "Add the new CT to the specified pool.",
1094 },
1095 snapname => get_standard_option('pve-lxc-snapshot-name', {
1096 optional => 1,
1097 }),
1098 storage => get_standard_option('pve-storage-id', {
1099 description => "Target storage for full clone.",
1100 requires => 'full',
1101 optional => 1,
1102 }),
1103 full => {
1104 optional => 1,
1105 type => 'boolean',
1106 description => "Create a full copy of all disk. This is always done when " .
1107 "you clone a normal CT. For CT templates, we try to create a linked clone by default.",
1108 default => 0,
1109 },
1110 experimental => {
1111 type => 'boolean',
1112 description => "The clone feature is experimental, set this " .
1113 "flag if you know what you are doing.",
1114 default => 0,
1115 },
1116 # target => get_standard_option('pve-node', {
1117 # description => "Target node. Only allowed if the original VM is on shared storage.",
1118 # optional => 1,
1119 # }),
1120 },
1121 },
1122 returns => {
1123 type => 'string',
1124 },
1125 code => sub {
1126 my ($param) = @_;
1127
1128 my $rpcenv = PVE::RPCEnvironment::get();
1129
1130 my $authuser = $rpcenv->get_user();
1131
1132 my $node = extract_param($param, 'node');
1133
1134 my $vmid = extract_param($param, 'vmid');
1135
1136 my $newid = extract_param($param, 'newid');
1137
1138 my $pool = extract_param($param, 'pool');
1139
1140 if (defined($pool)) {
1141 $rpcenv->check_pool_exist($pool);
1142 }
1143
1144 my $snapname = extract_param($param, 'snapname');
1145
1146 my $storage = extract_param($param, 'storage');
1147
1148 my $localnode = PVE::INotify::nodename();
1149
1150 my $storecfg = PVE::Storage::config();
1151
1152 if ($storage) {
1153 # check if storage is enabled on local node
1154 PVE::Storage::storage_check_enabled($storecfg, $storage);
1155 }
1156
1157 PVE::Cluster::check_cfs_quorum();
1158
1159 my $running = PVE::LXC::check_running($vmid) || 0;
1160
1161 my $clonefn = sub {
1162
1163 # do all tests after lock
1164 # we also try to do all tests before we fork the worker
1165 my $conf = PVE::LXC::Config->load_config($vmid);
1166
1167 PVE::LXC::Config->check_lock($conf);
1168
1169 my $verify_running = PVE::LXC::check_running($vmid) || 0;
1170
1171 die "unexpected state change\n" if $verify_running != $running;
1172
1173 die "snapshot '$snapname' does not exist\n"
1174 if $snapname && !defined( $conf->{snapshots}->{$snapname});
1175
1176 my $oldconf = $snapname ? $conf->{snapshots}->{$snapname} : $conf;
1177
1178 my $conffile = PVE::LXC::Config->config_file($newid);
1179 die "unable to create CT $newid: config file already exists\n"
1180 if -f $conffile;
1181
1182 my $newconf = { lock => 'clone' };
1183 my $mountpoints = {};
1184 my $fullclone = {};
1185 my $vollist = [];
1186
1187 foreach my $opt (keys %$oldconf) {
1188 my $value = $oldconf->{$opt};
1189
1190 # no need to copy unused images, because VMID(owner) changes anyways
1191 next if $opt =~ m/^unused\d+$/;
1192
1193 if (($opt eq 'rootfs') || ($opt =~ m/^mp\d+$/)) {
1194 my $mp = $opt eq 'rootfs' ?
1195 PVE::LXC::Config->parse_ct_rootfs($value) :
1196 PVE::LXC::Config->parse_ct_mountpoint($value);
1197
1198 if ($mp->{type} eq 'volume') {
1199 my $volid = $mp->{volume};
1200 if ($param->{full}) {
1201 die "fixme: full clone not implemented";
1202
1203 die "Full clone feature for '$volid' is not available\n"
1204 if !PVE::Storage::volume_has_feature($storecfg, 'copy', $volid, $snapname, $running);
1205 $fullclone->{$opt} = 1;
1206 } else {
1207 # not full means clone instead of copy
1208 die "Linked clone feature for '$volid' is not available\n"
1209 if !PVE::Storage::volume_has_feature($storecfg, 'clone', $volid, $snapname, $running);
1210 }
1211
1212 $mountpoints->{$opt} = $mp;
1213 push @$vollist, $volid;
1214
1215 } else {
1216 # TODO: allow bind mounts?
1217 die "unable to clone mountpint '$opt' (type $mp->{type})\n";
1218 }
1219
1220 } else {
1221 # copy everything else
1222 $newconf->{$opt} = $value;
1223 }
1224 }
1225
1226 delete $newconf->{template};
1227 if ($param->{hostname}) {
1228 $newconf->{hostname} = $param->{hostname};
1229 }
1230
1231 if ($param->{description}) {
1232 $newconf->{description} = $param->{description};
1233 }
1234
1235 # create empty/temp config - this fails if CT already exists on other node
1236 PVE::Tools::file_set_contents($conffile, "# ctclone temporary file\nlock: clone\n");
1237
1238 my $realcmd = sub {
1239 my $upid = shift;
1240
1241 my $newvollist = [];
1242
1243 eval {
1244 local $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = $SIG{HUP} = sub { die "interrupted by signal\n"; };
1245
1246 PVE::Storage::activate_volumes($storecfg, $vollist, $snapname);
1247
1248 foreach my $opt (keys %$mountpoints) {
1249 my $mp = $mountpoints->{$opt};
1250 my $volid = $mp->{volume};
1251
1252 if ($fullclone->{$opt}) {
1253 die "fixme: full clone not implemented\n";
1254 } else {
1255 print "create linked clone of mountpoint $opt ($volid)\n";
1256 my $newvolid = PVE::Storage::vdisk_clone($storecfg, $volid, $newid, $snapname);
1257 push @$newvollist, $newvolid;
1258 $mp->{volume} = $newvolid;
1259
1260 $newconf->{$opt} = PVE::LXC::Config->print_ct_mountpoint($mp, $opt eq 'rootfs');
1261 PVE::LXC::Config->write_config($newid, $newconf);
1262 }
1263 }
1264
1265 delete $newconf->{lock};
1266 PVE::LXC::Config->write_config($newid, $newconf);
1267
1268 PVE::AccessControl::add_vm_to_pool($newid, $pool) if $pool;
1269 };
1270 if (my $err = $@) {
1271 unlink $conffile;
1272
1273 sleep 1; # some storage like rbd need to wait before release volume - really?
1274
1275 foreach my $volid (@$newvollist) {
1276 eval { PVE::Storage::vdisk_free($storecfg, $volid); };
1277 warn $@ if $@;
1278 }
1279 die "clone failed: $err";
1280 }
1281
1282 return;
1283 };
1284
1285 PVE::Firewall::clone_vmfw_conf($vmid, $newid);
1286
1287 return $rpcenv->fork_worker('vzclone', $vmid, $authuser, $realcmd);
1288
1289 };
1290
1291 return PVE::LXC::Config->lock_config($vmid, $clonefn);
1292 }});
1293
1294
1295 __PACKAGE__->register_method({
1296 name => 'resize_vm',
1297 path => '{vmid}/resize',
1298 method => 'PUT',
1299 protected => 1,
1300 proxyto => 'node',
1301 description => "Resize a container mountpoint.",
1302 permissions => {
1303 check => ['perm', '/vms/{vmid}', ['VM.Config.Disk'], any => 1],
1304 },
1305 parameters => {
1306 additionalProperties => 0,
1307 properties => {
1308 node => get_standard_option('pve-node'),
1309 vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid }),
1310 disk => {
1311 type => 'string',
1312 description => "The disk you want to resize.",
1313 enum => [PVE::LXC::Config->mountpoint_names()],
1314 },
1315 size => {
1316 type => 'string',
1317 pattern => '\+?\d+(\.\d+)?[KMGT]?',
1318 description => "The new size. With the '+' sign the value is added to the actual size of the volume and without it, the value is taken as an absolute one. Shrinking disk size is not supported.",
1319 },
1320 digest => {
1321 type => 'string',
1322 description => 'Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications.',
1323 maxLength => 40,
1324 optional => 1,
1325 }
1326 },
1327 },
1328 returns => {
1329 type => 'string',
1330 description => "the task ID.",
1331 },
1332 code => sub {
1333 my ($param) = @_;
1334
1335 my $rpcenv = PVE::RPCEnvironment::get();
1336
1337 my $authuser = $rpcenv->get_user();
1338
1339 my $node = extract_param($param, 'node');
1340
1341 my $vmid = extract_param($param, 'vmid');
1342
1343 my $digest = extract_param($param, 'digest');
1344
1345 my $sizestr = extract_param($param, 'size');
1346 my $ext = ($sizestr =~ s/^\+//);
1347 my $newsize = PVE::JSONSchema::parse_size($sizestr);
1348 die "invalid size string" if !defined($newsize);
1349
1350 die "no options specified\n" if !scalar(keys %$param);
1351
1352 PVE::LXC::check_ct_modify_config_perm($rpcenv, $authuser, $vmid, undef, $param, []);
1353
1354 my $storage_cfg = cfs_read_file("storage.cfg");
1355
1356 my $code = sub {
1357
1358 my $conf = PVE::LXC::Config->load_config($vmid);
1359 PVE::LXC::Config->check_lock($conf);
1360
1361 PVE::Tools::assert_if_modified($digest, $conf->{digest});
1362
1363 my $running = PVE::LXC::check_running($vmid);
1364
1365 my $disk = $param->{disk};
1366 my $mp = $disk eq 'rootfs' ? PVE::LXC::Config->parse_ct_rootfs($conf->{$disk}) :
1367 PVE::LXC::Config->parse_ct_mountpoint($conf->{$disk});
1368
1369 my $volid = $mp->{volume};
1370
1371 my (undef, undef, $owner, undef, undef, undef, $format) =
1372 PVE::Storage::parse_volname($storage_cfg, $volid);
1373
1374 die "can't resize mountpoint owned by another container ($owner)"
1375 if $vmid != $owner;
1376
1377 die "can't resize volume: $disk if snapshot exists\n"
1378 if %{$conf->{snapshots}} && $format eq 'qcow2';
1379
1380 my ($storeid, $volname) = PVE::Storage::parse_volume_id($volid);
1381
1382 $rpcenv->check($authuser, "/storage/$storeid", ['Datastore.AllocateSpace']);
1383
1384 PVE::Storage::activate_volumes($storage_cfg, [$volid]);
1385
1386 my $size = PVE::Storage::volume_size_info($storage_cfg, $volid, 5);
1387 $newsize += $size if $ext;
1388 $newsize = int($newsize);
1389
1390 die "unable to shrink disk size\n" if $newsize < $size;
1391
1392 return if $size == $newsize;
1393
1394 PVE::Cluster::log_msg('info', $authuser, "update CT $vmid: resize --disk $disk --size $sizestr");
1395 my $realcmd = sub {
1396 # Note: PVE::Storage::volume_resize doesn't do anything if $running=1, so
1397 # we pass 0 here (parameter only makes sense for qemu)
1398 PVE::Storage::volume_resize($storage_cfg, $volid, $newsize, 0);
1399
1400 $mp->{size} = $newsize;
1401 $conf->{$disk} = PVE::LXC::Config->print_ct_mountpoint($mp, $disk eq 'rootfs');
1402
1403 PVE::LXC::Config->write_config($vmid, $conf);
1404
1405 if ($format eq 'raw') {
1406 my $path = PVE::Storage::path($storage_cfg, $volid, undef);
1407 if ($running) {
1408
1409 $mp->{mp} = '/';
1410 my $use_loopdev = (PVE::LXC::mountpoint_mount_path($mp, $storage_cfg))[1];
1411 $path = PVE::LXC::query_loopdev($path) if $use_loopdev;
1412 die "internal error: CT running but mountpoint not attached to a loop device"
1413 if !$path;
1414 PVE::Tools::run_command(['losetup', '--set-capacity', $path]) if $use_loopdev;
1415
1416 # In order for resize2fs to know that we need online-resizing a mountpoint needs
1417 # to be visible to it in its namespace.
1418 # To not interfere with the rest of the system we unshare the current mount namespace,
1419 # mount over /tmp and then run resize2fs.
1420
1421 # interestingly we don't need to e2fsck on mounted systems...
1422 my $quoted = PVE::Tools::shellquote($path);
1423 my $cmd = "mount --make-rprivate / && mount $quoted /tmp && resize2fs $quoted";
1424 eval {
1425 PVE::Tools::run_command(['unshare', '-m', '--', 'sh', '-c', $cmd]);
1426 };
1427 warn "Failed to update the container's filesystem: $@\n" if $@;
1428 } else {
1429 eval {
1430 PVE::Tools::run_command(['e2fsck', '-f', '-y', $path]);
1431 PVE::Tools::run_command(['resize2fs', $path]);
1432 };
1433 warn "Failed to update the container's filesystem: $@\n" if $@;
1434 }
1435 }
1436 };
1437
1438 return $rpcenv->fork_worker('resize', $vmid, $authuser, $realcmd);
1439 };
1440
1441 return PVE::LXC::Config->lock_config($vmid, $code);;
1442 }});
1443
1444 1;