]>
git.proxmox.com Git - pve-cluster.git/blob - data/PVE/DataCenterConfig.pm
1 package PVE
:: DataCenterConfig
;
10 my $migration_format = {
14 enum
=> [ 'secure' , 'insecure' ],
15 description
=> "Migration traffic is encrypted using an SSH tunnel by " .
16 "default. On secure, completely private networks this can be " .
17 "disabled to increase performance." ,
22 type
=> 'string' , format
=> 'CIDR' ,
23 format_description
=> 'CIDR' ,
24 description
=> "CIDR of the (sub) network that is used for migration."
31 enum
=> [ 'freeze' , 'failover' , 'conditional' , 'migrate' ],
32 description
=> "The policy for HA services on node shutdown. 'freeze' disables " .
33 "auto-recovery, 'failover' ensures recovery, 'conditional' recovers on " .
34 "poweroff and freezes on reboot. 'migrate' will migrate running services " .
35 "to other nodes, if possible. With 'freeze' or 'failover', HA Services will " .
36 "always get stopped first on shutdown." ,
37 verbose_description
=> "Describes the policy for handling HA services on poweroff " .
38 "or reboot of a node. Freeze will always freeze services which are still located " .
39 "on the node on shutdown, those services won't be recovered by the HA manager. " .
40 "Failover will not mark the services as frozen and thus the services will get " .
41 "recovered to other nodes, if the shutdown node does not come up again quickly " .
42 "(< 1min). 'conditional' chooses automatically depending on the type of shutdown, " .
43 "i.e., on a reboot the service will be frozen but on a poweroff the service will " .
44 "stay as is, and thus get recovered after about 2 minutes. " .
45 "Migrate will try to move all running services to another node when a reboot or " .
46 "shutdown was triggered. The poweroff process will only continue once no running services " .
47 "are located on the node anymore. If the node comes up again, the service will " .
48 "be moved back to the previously powered-off node, at least if no other migration, " .
49 "reloaction or recovery took place." ,
50 default => 'conditional' ,
57 description
=> "U2F AppId URL override. Defaults to the origin." ,
58 format_description
=> 'APPID' ,
63 description
=> "U2F Origin override. Mostly useful for single nodes with a single URL." ,
64 format_description
=> 'URL' ,
70 PVE
:: JSONSchema
:: register_format
( 'mac-prefix' , \
& pve_verify_mac_prefix
);
71 sub pve_verify_mac_prefix
{
72 my ( $mac_prefix, $noerr ) = @_ ;
74 if ( $mac_prefix !~ m/^[a-f0-9][02468ace](?::[a-f0-9]{2}){0,2}:?$/i ) {
75 return undef if $noerr ;
76 die "value is not a valid unicast MAC address prefix \n " ;
81 my $datacenter_schema = {
83 additionalProperties
=> 0 ,
88 description
=> "Default keybord layout for vnc server." ,
89 enum
=> PVE
:: Tools
:: kvmkeymaplist
(),
94 description
=> "Default GUI language." ,
122 description
=> "Specify external http proxy which is used for downloads (example: 'http://username:password\ @host :port/')" ,
123 pattern
=> "http://.*" ,
125 migration_unsecure
=> {
128 description
=> "Migration is secure using SSH tunnel by default. " .
129 "For secure private networks you can disable it to speed up " .
130 "migration. Deprecated, use the 'migration' property instead!" ,
134 type
=> 'string' , format
=> $migration_format,
135 description
=> "For cluster wide migration settings." ,
140 description
=> "Select the default Console viewer. You can either use the builtin java applet (VNC; deprecated and maps to html5), an external virt-viewer comtatible application (SPICE), an HTML5 based vnc viewer (noVNC), or an HTML5 based console client (xtermjs). If the selected viewer is not available (e.g. SPICE not activated for the VM), the fallback is noVNC." ,
141 enum
=> [ 'applet' , 'vv' , 'html5' , 'xtermjs' ],
146 format
=> 'email-opt' ,
147 description
=> "Specify email address to send notification from (default is root @\$hostname )" ,
153 description
=> "Defines how many workers (per node) are maximal started " .
154 " on actions like 'stopall VMs' or task from the ha-manager." ,
159 default => 'watchdog' ,
160 enum
=> [ 'watchdog' , 'hardware' , 'both' ],
161 description
=> "Set the fencing mode of the HA cluster. Hardware mode " .
162 "needs a valid configuration of fence devices in /etc/pve/ha/fence.cfg." .
163 " With both all two modes are used." .
164 " \n\n WARNING: 'hardware' and 'both' are EXPERIMENTAL & WIP" ,
168 type
=> 'string' , format
=> $ha_format,
169 description
=> "Cluster wide HA settings." ,
174 format
=> 'mac-prefix' ,
175 description
=> 'Prefix for autogenerated MAC addresses.' ,
177 bwlimit
=> PVE
:: JSONSchema
:: get_standard_option
( 'bwlimit' ),
181 format
=> $u2f_format,
182 description
=> 'u2f' ,
186 description
=> "Datacenter description. Shown in the web-interface datacenter notes panel."
187 . " This is saved as comment inside the configuration file." ,
188 maxLength
=> 64 * 1024 ,
194 # make schema accessible from outside (for documentation)
195 sub get_datacenter_schema
{ return $datacenter_schema };
197 sub parse_datacenter_config
{
198 my ( $filename, $raw ) = @_ ;
200 # description may be comment or key-value pair (or both)
202 my @lines = split ( /\n/ , $raw );
203 foreach my $line ( @lines ) {
204 if ( $line =~ /^\#(.*)\s*$/ ) {
205 $comment .= PVE
:: Tools
:: decode_text
( $1 ) . " \n " ;
209 # parse_config ignores lines with # => use $raw
210 my $res = PVE
:: JSONSchema
:: parse_config
( $datacenter_schema, $filename, $raw // '' );
212 $res ->{ description
} = $comment ;
215 if ( my $migration = $res ->{ migration
}) {
216 $res ->{ migration
} = PVE
:: JSONSchema
:: parse_property_string
( $migration_format, $migration );
219 if ( my $ha = $res ->{ ha
}) {
220 $res ->{ ha
} = PVE
:: JSONSchema
:: parse_property_string
( $ha_format, $ha );
223 if ( my $u2f = $res ->{ u2f
}) {
224 $res ->{ u2f
} = PVE
:: JSONSchema
:: parse_property_string
( $u2f_format, $u2f );
227 # for backwards compatibility only, new migration property has precedence
228 if ( defined ( $res ->{ migration_unsecure
})) {
229 if ( defined ( $res ->{ migration
}->{ type
})) {
230 warn "deprecated setting 'migration_unsecure' and new 'migration: type' " .
231 "set at same time! Ignore 'migration_unsecure' \n " ;
233 $res ->{ migration
}->{ type
} = ( $res ->{ migration_unsecure
}) ?
'insecure' : 'secure' ;
237 # for backwards compatibility only, applet maps to html5
238 if ( defined ( $res ->{ console
}) && $res ->{ console
} eq 'applet' ) {
239 $res ->{ console
} = 'html5' ;
245 sub write_datacenter_config
{
246 my ( $filename, $cfg ) = @_ ;
248 # map deprecated setting to new one
249 if ( defined ( $cfg ->{ migration_unsecure
}) && ! defined ( $cfg ->{ migration
})) {
250 my $migration_unsecure = delete $cfg ->{ migration_unsecure
};
251 $cfg ->{ migration
}->{ type
} = ( $migration_unsecure ) ?
'insecure' : 'secure' ;
254 # map deprecated applet setting to html5
255 if ( defined ( $cfg ->{ console
}) && $cfg ->{ console
} eq 'applet' ) {
256 $cfg ->{ console
} = 'html5' ;
259 if ( ref ( $cfg ->{ migration
})) {
260 my $migration = $cfg ->{ migration
};
261 $cfg ->{ migration
} = PVE
:: JSONSchema
:: print_property_string
( $migration, $migration_format );
264 if ( ref ( $cfg ->{ ha
})) {
266 $cfg ->{ ha
} = PVE
:: JSONSchema
:: print_property_string
( $ha, $ha_format );
269 if ( ref ( $cfg ->{ u2f
})) {
270 my $u2f = $cfg ->{ u2f
};
271 $cfg ->{ u2f
} = PVE
:: JSONSchema
:: print_property_string
( $u2f, $u2f_format );
275 # add description as comment to top of file
276 my $description = $cfg ->{ description
} || '' ;
277 foreach my $line ( split ( /\n/ , $description )) {
278 $comment .= '#' . PVE
:: Tools
:: encode_text
( $line ) . " \n " ;
280 delete $cfg ->{ description
}; # add only as comment, no additional key-value pair
281 my $dump = PVE
:: JSONSchema
:: dump_config
( $datacenter_schema, $filename, $cfg );
283 return $comment . " \n " . $dump ;
286 PVE
:: Cluster
:: cfs_register_file
( 'datacenter.cfg' ,
287 \
& parse_datacenter_config
,
288 \
& write_datacenter_config
);