]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/dc/ClusterEdit.js
1 /*jslint confusion: true*/
2 Ext
.define('PVE.ClusterCreateWindow', {
3 extend
: 'Proxmox.window.Edit',
4 xtype
: 'pveClusterCreateWindow',
6 title
: gettext('Create Cluster'),
10 url
: '/cluster/config',
13 subject
: gettext('Cluster'),
16 onlineHelp
: 'pvecm_create_cluster',
22 fieldLabel
: gettext('Cluster Name'),
28 xtype
: 'proxmoxNetworkSelector',
29 fieldLabel
: Ext
.String
.format(gettext('Link {0}'), 0),
30 emptyText
: gettext("Optional, defaults to IP resolved by node's hostname"),
33 valueField
: 'address',
34 displayField
: 'address',
38 xtype
: 'proxmoxNetworkSelector',
39 fieldLabel
: Ext
.String
.format(gettext('Link {0}'), 1),
40 emptyText
: gettext("Optional second link for redundancy"),
43 valueField
: 'address',
44 displayField
: 'address',
50 Ext
.define('PVE.ClusterInfoWindow', {
51 extend
: 'Ext.window.Window',
52 xtype
: 'pveClusterInfoWindow',
53 mixins
: ['Proxmox.Mixin.CBind'],
58 title
: gettext('Cluster Join Information'),
62 fingerprint
: undefined,
70 padding
: '10 10 10 10',
71 html
: gettext("Copy the Join Information here and use it on the node you want to add.")
77 padding
: '0 10 10 10',
81 fieldLabel
: gettext('IP Address'),
82 cbind
: { value
: '{joinInfo.ipAddress}' },
87 fieldLabel
: gettext('Fingerprint'),
88 cbind
: { value
: '{joinInfo.fingerprint}' },
93 inputId
: 'pveSerializedClusterInfo',
94 fieldLabel
: gettext('Join Information'),
96 cbind
: { joinInfo
: '{joinInfo}' },
99 afterrender: function(field
) {
100 if (!field
.joinInfo
) {
103 var jsons
= Ext
.JSON
.encode(field
.joinInfo
);
104 var base64s
= Ext
.util
.Base64
.encode(jsons
);
105 field
.setValue(base64s
);
117 handler: function(b
) {
118 var el
= document
.getElementById('pveSerializedClusterInfo');
120 document
.execCommand("copy");
122 text
: gettext('Copy Information')
127 Ext
.define('PVE.ClusterJoinNodeWindow', {
128 extend
: 'Proxmox.window.Edit',
129 xtype
: 'pveClusterJoinNodeWindow',
131 title
: gettext('Cluster Join'),
135 url
: '/cluster/config/join',
137 defaultFocus
: 'textarea[name=serializedinfo]',
140 submitText
: '{submittxt}',
142 showTaskViewer
: true,
144 onlineHelp
: 'pvecm_join_node_to_cluster',
154 ring1Possible
: false,
159 ring0EmptyText: function(get) {
160 if (get('info.ring0Needed')) {
161 return gettext("Cannot use default address safely");
163 return gettext("Default: IP resolved by node's hostname");
166 submittxt: function(get) {
167 let cn
= get('info.clusterName');
169 return Ext
.String
.format(gettext('Join {0}'), `'${cn}'`);
171 return gettext('Join');
177 xclass
: 'Ext.app.ViewController',
181 delete PVE
.Utils
.silenceAuthFailures
;
184 'proxmoxcheckbox[name=assistedEntry]': {
185 change
: 'onInputTypeChange'
187 'textarea[name=serializedinfo]': {
188 change
: 'recomputeSerializedInfo',
191 'proxmoxtextfield[name=ring1_addr]': {
192 enable
: 'ring1Needed'
195 disable
: 'resetField'
198 resetField: function(field
) {
201 ring1Needed: function(f
) {
202 var vm
= this.getViewModel();
203 f
.allowBlank
= !vm
.get('info.ring1Needed');
205 onInputTypeChange: function(field
, assistedInput
) {
206 var vm
= this.getViewModel();
207 if (!assistedInput
) {
208 vm
.set('info.ring1Possible', true);
211 recomputeSerializedInfo: function(field
, value
) {
212 var vm
= this.getViewModel();
213 var jsons
= Ext
.util
.Base64
.decode(value
);
214 var joinInfo
= Ext
.JSON
.decode(jsons
, true);
219 ring1Possible
: false,
225 if (!(joinInfo
&& joinInfo
.totem
)) {
228 var ring0Needed
= false;
229 if (joinInfo
.ring_addr
!== undefined) {
230 ring0Needed
= joinInfo
.ring_addr
[0] !== joinInfo
.ipAddress
;
234 ip
: joinInfo
.ipAddress
,
235 fp
: joinInfo
.fingerprint
,
236 ring0Needed
: ring0Needed
,
237 ring1Possible
: !!joinInfo
.totem
['interface']['1'],
238 ring1Needed
: !!joinInfo
.totem
['interface']['1'],
239 clusterName
: joinInfo
.totem
['cluster_name']
241 totem
= joinInfo
.totem
;
245 vm
.set('info', info
);
250 // joining may produce temporarily auth failures, ignore as long the task runs
251 PVE
.Utils
.silenceAuthFailures
= true;
255 taskDone: function(success
) {
256 delete PVE
.Utils
.silenceAuthFailures
;
258 // reload always (if user wasn't faster), but wait a bit for pveproxy
259 Ext
.defer(function() {
260 window
.location
.reload(true);
262 var txt
= gettext('Cluster join task finished, node certificate may have changed, reload GUI!');
263 // ensure user cannot do harm
264 Ext
.getBody().mask(txt
, ['pve-static-mask']);
265 // TaskView may hide above mask, so tell him directly
267 title
: gettext('Join Task Finished'),
275 xtype
: 'proxmoxcheckbox',
276 reference
: 'assistedEntry',
277 name
: 'assistedEntry',
282 'data-qtip': gettext('Select if join information should be extracted from pasted cluster information, deselect for manual entering')
284 boxLabel
: gettext('Assisted join: Paste encoded cluster join information and enter password.')
288 name
: 'serializedinfo',
291 fieldLabel
: gettext('Information'),
292 emptyText
: gettext('Paste encoded Cluster Information here'),
293 validator: function(val
) {
294 return val
=== '' || this.valid
||
295 gettext('Does not seem like a valid encoded Cluster Information!');
298 disabled
: '{!assistedEntry.checked}',
299 hidden
: '{!assistedEntry.checked}'
308 fieldLabel
: gettext('Peer Address'),
312 readOnly
: '{assistedEntry.checked}'
318 inputType
: 'password',
319 emptyText
: gettext("Peer's root password"),
320 fieldLabel
: gettext('Password'),
327 xtype
: 'proxmoxNetworkSelector',
328 fieldLabel
: Ext
.String
.format(gettext('Link {0}'), 0),
330 emptyText
: '{ring0EmptyText}',
331 allowBlank
: '{!info.ring0Needed}'
335 valueField
: 'address',
336 displayField
: 'address',
340 xtype
: 'proxmoxNetworkSelector',
341 fieldLabel
: Ext
.String
.format(gettext('Link {0}'), 1),
344 valueField
: 'address',
345 displayField
: 'address',
347 disabled
: '{!info.ring1Possible}',
348 allowBlank
: '{!info.ring1Needed}',
356 fieldLabel
: gettext('Fingerprint'),
360 readOnly
: '{assistedEntry.checked}'