]>
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 default => 'conditional' ,
52 description
=> "U2F AppId URL override. Defaults to the origin." ,
53 format_description
=> 'APPID' ,
58 description
=> "U2F Origin override. Mostly useful for single nodes with a single URL." ,
59 format_description
=> 'URL' ,
65 PVE
:: JSONSchema
:: register_format
( 'mac-prefix' , \
& pve_verify_mac_prefix
);
66 sub pve_verify_mac_prefix
{
67 my ( $mac_prefix, $noerr ) = @_ ;
69 if ( $mac_prefix !~ m/^[a-f0-9][02468ace](?::[a-f0-9]{2}){0,2}:?$/i ) {
70 return undef if $noerr ;
71 die "value is not a valid unicast MAC address prefix \n " ;
76 my $datacenter_schema = {
78 additionalProperties
=> 0 ,
83 description
=> "Default keybord layout for vnc server." ,
84 enum
=> PVE
:: Tools
:: kvmkeymaplist
(),
89 description
=> "Default GUI language." ,
117 description
=> "Specify external http proxy which is used for downloads (example: 'http://username:password\ @host :port/')" ,
118 pattern
=> "http://.*" ,
120 migration_unsecure
=> {
123 description
=> "Migration is secure using SSH tunnel by default. " .
124 "For secure private networks you can disable it to speed up " .
125 "migration. Deprecated, use the 'migration' property instead!" ,
129 type
=> 'string' , format
=> $migration_format,
130 description
=> "For cluster wide migration settings." ,
135 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." ,
136 enum
=> [ 'applet' , 'vv' , 'html5' , 'xtermjs' ],
141 format
=> 'email-opt' ,
142 description
=> "Specify email address to send notification from (default is root @\$hostname )" ,
148 description
=> "Defines how many workers (per node) are maximal started " .
149 " on actions like 'stopall VMs' or task from the ha-manager." ,
154 default => 'watchdog' ,
155 enum
=> [ 'watchdog' , 'hardware' , 'both' ],
156 description
=> "Set the fencing mode of the HA cluster. Hardware mode " .
157 "needs a valid configuration of fence devices in /etc/pve/ha/fence.cfg." .
158 " With both all two modes are used." .
159 " \n\n WARNING: 'hardware' and 'both' are EXPERIMENTAL & WIP" ,
163 type
=> 'string' , format
=> $ha_format,
164 description
=> "Cluster wide HA settings." ,
169 format
=> 'mac-prefix' ,
170 description
=> 'Prefix for autogenerated MAC addresses.' ,
172 bwlimit
=> PVE
:: JSONSchema
:: get_standard_option
( 'bwlimit' ),
176 format
=> $u2f_format,
177 description
=> 'u2f' ,
182 # make schema accessible from outside (for documentation)
183 sub get_datacenter_schema
{ return $datacenter_schema };
185 sub parse_datacenter_config
{
186 my ( $filename, $raw ) = @_ ;
188 my $res = PVE
:: JSONSchema
:: parse_config
( $datacenter_schema, $filename, $raw // '' );
190 if ( my $migration = $res ->{ migration
}) {
191 $res ->{ migration
} = PVE
:: JSONSchema
:: parse_property_string
( $migration_format, $migration );
194 if ( my $ha = $res ->{ ha
}) {
195 $res ->{ ha
} = PVE
:: JSONSchema
:: parse_property_string
( $ha_format, $ha );
198 if ( my $u2f = $res ->{ u2f
}) {
199 $res ->{ u2f
} = PVE
:: JSONSchema
:: parse_property_string
( $u2f_format, $u2f );
202 # for backwards compatibility only, new migration property has precedence
203 if ( defined ( $res ->{ migration_unsecure
})) {
204 if ( defined ( $res ->{ migration
}->{ type
})) {
205 warn "deprecated setting 'migration_unsecure' and new 'migration: type' " .
206 "set at same time! Ignore 'migration_unsecure' \n " ;
208 $res ->{ migration
}->{ type
} = ( $res ->{ migration_unsecure
}) ?
'insecure' : 'secure' ;
212 # for backwards compatibility only, applet maps to html5
213 if ( defined ( $res ->{ console
}) && $res ->{ console
} eq 'applet' ) {
214 $res ->{ console
} = 'html5' ;
220 sub write_datacenter_config
{
221 my ( $filename, $cfg ) = @_ ;
223 # map deprecated setting to new one
224 if ( defined ( $cfg ->{ migration_unsecure
}) && ! defined ( $cfg ->{ migration
})) {
225 my $migration_unsecure = delete $cfg ->{ migration_unsecure
};
226 $cfg ->{ migration
}->{ type
} = ( $migration_unsecure ) ?
'insecure' : 'secure' ;
229 # map deprecated applet setting to html5
230 if ( defined ( $cfg ->{ console
}) && $cfg ->{ console
} eq 'applet' ) {
231 $cfg ->{ console
} = 'html5' ;
234 if ( ref ( $cfg ->{ migration
})) {
235 my $migration = $cfg ->{ migration
};
236 $cfg ->{ migration
} = PVE
:: JSONSchema
:: print_property_string
( $migration, $migration_format );
239 if ( ref ( $cfg ->{ ha
})) {
241 $cfg ->{ ha
} = PVE
:: JSONSchema
:: print_property_string
( $ha, $ha_format );
244 if ( ref ( $cfg ->{ u2f
})) {
245 my $u2f = $cfg ->{ u2f
};
246 $cfg ->{ u2f
} = PVE
:: JSONSchema
:: print_property_string
( $u2f, $u2f_format );
249 return PVE
:: JSONSchema
:: dump_config
( $datacenter_schema, $filename, $cfg );
252 PVE
:: Cluster
:: cfs_register_file
( 'datacenter.cfg' ,
253 \
& parse_datacenter_config
,
254 \
& write_datacenter_config
);