]>
git.proxmox.com Git - pve-cluster.git/blob - data/PVE/DataCenterConfig.pm
77cc73cee2b75c3f97d3023c5beaab88503f1443
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' ],
32 description
=> "The policy for HA services on node shutdown. 'freeze' disables auto-recovery, 'failover' ensures recovery, 'conditional' recovers on poweroff and freezes on reboot. Running HA Services will always get stopped first on shutdown." ,
33 verbose_description
=> "Describes the policy for handling HA services on poweroff or reboot of a node. Freeze will always freeze services which are still located on the node on shutdown, those services won't be recovered by the HA manager. Failover will not mark the services as frozen and thus the services will get recovered to other nodes, if the shutdown node does not come up again quickly (< 1min). 'conditional' chooses automatically depending on the type of shutdown, i.e., on a reboot the service will be frozen but on a poweroff the service will stay as is, and thus get recovered after about 2 minutes." ,
34 default => 'conditional' ,
41 description
=> "U2F AppId URL override. Defaults to the origin." ,
42 format_description
=> 'APPID' ,
47 description
=> "U2F Origin override. Mostly useful for single nodes with a single URL." ,
48 format_description
=> 'URL' ,
54 PVE
:: JSONSchema
:: register_format
( 'mac-prefix' , \
& pve_verify_mac_prefix
);
55 sub pve_verify_mac_prefix
{
56 my ( $mac_prefix, $noerr ) = @_ ;
58 if ( $mac_prefix !~ m/^[a-f0-9][02468ace](?::[a-f0-9]{2}){0,2}:?$/i ) {
59 return undef if $noerr ;
60 die "value is not a valid unicast MAC address prefix \n " ;
65 my $datacenter_schema = {
67 additionalProperties
=> 0 ,
72 description
=> "Default keybord layout for vnc server." ,
73 enum
=> PVE
:: Tools
:: kvmkeymaplist
(),
78 description
=> "Default GUI language." ,
106 description
=> "Specify external http proxy which is used for downloads (example: 'http://username:password\ @host :port/')" ,
107 pattern
=> "http://.*" ,
109 migration_unsecure
=> {
112 description
=> "Migration is secure using SSH tunnel by default. " .
113 "For secure private networks you can disable it to speed up " .
114 "migration. Deprecated, use the 'migration' property instead!" ,
118 type
=> 'string' , format
=> $migration_format,
119 description
=> "For cluster wide migration settings." ,
124 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." ,
125 enum
=> [ 'applet' , 'vv' , 'html5' , 'xtermjs' ],
130 format
=> 'email-opt' ,
131 description
=> "Specify email address to send notification from (default is root @\$hostname )" ,
137 description
=> "Defines how many workers (per node) are maximal started " .
138 " on actions like 'stopall VMs' or task from the ha-manager." ,
143 default => 'watchdog' ,
144 enum
=> [ 'watchdog' , 'hardware' , 'both' ],
145 description
=> "Set the fencing mode of the HA cluster. Hardware mode " .
146 "needs a valid configuration of fence devices in /etc/pve/ha/fence.cfg." .
147 " With both all two modes are used." .
148 " \n\n WARNING: 'hardware' and 'both' are EXPERIMENTAL & WIP" ,
152 type
=> 'string' , format
=> $ha_format,
153 description
=> "Cluster wide HA settings." ,
158 format
=> 'mac-prefix' ,
159 description
=> 'Prefix for autogenerated MAC addresses.' ,
161 bwlimit
=> PVE
:: JSONSchema
:: get_standard_option
( 'bwlimit' ),
165 format
=> $u2f_format,
166 description
=> 'u2f' ,
171 # make schema accessible from outside (for documentation)
172 sub get_datacenter_schema
{ return $datacenter_schema };
174 sub parse_datacenter_config
{
175 my ( $filename, $raw ) = @_ ;
177 my $res = PVE
:: JSONSchema
:: parse_config
( $datacenter_schema, $filename, $raw // '' );
179 if ( my $migration = $res ->{ migration
}) {
180 $res ->{ migration
} = PVE
:: JSONSchema
:: parse_property_string
( $migration_format, $migration );
183 if ( my $ha = $res ->{ ha
}) {
184 $res ->{ ha
} = PVE
:: JSONSchema
:: parse_property_string
( $ha_format, $ha );
187 if ( my $u2f = $res ->{ u2f
}) {
188 $res ->{ u2f
} = PVE
:: JSONSchema
:: parse_property_string
( $u2f_format, $u2f );
191 # for backwards compatibility only, new migration property has precedence
192 if ( defined ( $res ->{ migration_unsecure
})) {
193 if ( defined ( $res ->{ migration
}->{ type
})) {
194 warn "deprecated setting 'migration_unsecure' and new 'migration: type' " .
195 "set at same time! Ignore 'migration_unsecure' \n " ;
197 $res ->{ migration
}->{ type
} = ( $res ->{ migration_unsecure
}) ?
'insecure' : 'secure' ;
201 # for backwards compatibility only, applet maps to html5
202 if ( defined ( $res ->{ console
}) && $res ->{ console
} eq 'applet' ) {
203 $res ->{ console
} = 'html5' ;
209 sub write_datacenter_config
{
210 my ( $filename, $cfg ) = @_ ;
212 # map deprecated setting to new one
213 if ( defined ( $cfg ->{ migration_unsecure
}) && ! defined ( $cfg ->{ migration
})) {
214 my $migration_unsecure = delete $cfg ->{ migration_unsecure
};
215 $cfg ->{ migration
}->{ type
} = ( $migration_unsecure ) ?
'insecure' : 'secure' ;
218 # map deprecated applet setting to html5
219 if ( defined ( $cfg ->{ console
}) && $cfg ->{ console
} eq 'applet' ) {
220 $cfg ->{ console
} = 'html5' ;
223 if ( ref ( $cfg ->{ migration
})) {
224 my $migration = $cfg ->{ migration
};
225 $cfg ->{ migration
} = PVE
:: JSONSchema
:: print_property_string
( $migration, $migration_format );
228 if ( ref ( $cfg ->{ ha
})) {
230 $cfg ->{ ha
} = PVE
:: JSONSchema
:: print_property_string
( $ha, $ha_format );
233 if ( ref ( $cfg ->{ u2f
})) {
234 my $u2f = $cfg ->{ u2f
};
235 $cfg ->{ u2f
} = PVE
:: JSONSchema
:: print_property_string
( $u2f, $u2f_format );
238 return PVE
:: JSONSchema
:: dump_config
( $datacenter_schema, $filename, $cfg );
241 PVE
:: Cluster
:: cfs_register_file
( 'datacenter.cfg' ,
242 \
& parse_datacenter_config
,
243 \
& write_datacenter_config
);