]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/dc/ClusterEdit.js
1 Ext
.define('PVE.ClusterCreateWindow', {
2 extend
: 'Proxmox.window.Edit',
3 xtype
: 'pveClusterCreateWindow',
5 title
: gettext('Create Cluster'),
9 url
: '/cluster/config',
12 subject
: gettext('Cluster'),
15 onlineHelp
: 'pvecm_create_cluster',
21 fieldLabel
: gettext('Cluster Name'),
27 xtype
: 'fieldcontainer',
28 fieldLabel
: gettext("Cluster Network"),
31 xtype
: 'pveCorosyncLinkEditor',
32 infoText
: gettext("Multiple links are used as failover, lower numbers have higher priority."),
40 Ext
.define('PVE.ClusterInfoWindow', {
41 extend
: 'Ext.window.Window',
42 xtype
: 'pveClusterInfoWindow',
43 mixins
: ['Proxmox.Mixin.CBind'],
48 title
: gettext('Cluster Join Information'),
52 fingerprint
: undefined,
60 padding
: '10 10 10 10',
61 html
: gettext("Copy the Join Information here and use it on the node you want to add."),
67 padding
: '0 10 10 10',
71 fieldLabel
: gettext('IP Address'),
73 value
: '{joinInfo.ipAddress}',
79 fieldLabel
: gettext('Fingerprint'),
81 value
: '{joinInfo.fingerprint}',
87 inputId
: 'pveSerializedClusterInfo',
88 fieldLabel
: gettext('Join Information'),
91 joinInfo
: '{joinInfo}',
95 afterrender: function(field
) {
96 if (!field
.joinInfo
) {
99 var jsons
= Ext
.JSON
.encode(field
.joinInfo
);
100 var base64s
= Ext
.util
.Base64
.encode(jsons
);
101 field
.setValue(base64s
);
113 handler: function(b
) {
114 var el
= document
.getElementById('pveSerializedClusterInfo');
116 document
.execCommand("copy");
118 text
: gettext('Copy Information'),
123 Ext
.define('PVE.ClusterJoinNodeWindow', {
124 extend
: 'Proxmox.window.Edit',
125 xtype
: 'pveClusterJoinNodeWindow',
127 title
: gettext('Cluster Join'),
131 url
: '/cluster/config/join',
133 defaultFocus
: 'textarea[name=serializedinfo]',
136 submitText
: '{submittxt}',
138 showTaskViewer
: true,
140 onlineHelp
: 'pvecm_join_node_to_cluster',
150 hasAssistedInfo
: false,
153 submittxt: function(get) {
154 let cn
= get('info.clusterName');
156 return Ext
.String
.format(gettext('Join {0}'), `'${cn}'`);
158 return gettext('Join');
160 showClusterFields
: (get) => {
161 let manualMode
= !get('assistedEntry.checked');
162 return get('hasAssistedInfo') || manualMode
;
168 xclass
: 'Ext.app.ViewController',
172 delete PVE
.Utils
.silenceAuthFailures
;
175 'proxmoxcheckbox[name=assistedEntry]': {
176 change
: 'onInputTypeChange',
178 'textarea[name=serializedinfo]': {
179 change
: 'recomputeSerializedInfo',
180 enable
: 'resetField',
183 disable
: 'resetField',
186 resetField: function(field
) {
189 onInputTypeChange: function(field
, assistedInput
) {
190 let linkEditor
= this.lookup('linkEditor');
192 // this also clears all links
193 linkEditor
.setAllowNumberEdit(!assistedInput
);
195 if (!assistedInput
) {
196 linkEditor
.setInfoText();
197 linkEditor
.setDefaultLinks();
200 recomputeSerializedInfo: function(field
, value
) {
201 let vm
= this.getViewModel();
203 let assistedEntryBox
= this.lookup('assistedEntry');
205 if (!assistedEntryBox
.getValue()) {
206 // not in assisted entry mode, nothing to do
207 vm
.set('hasAssistedInfo', false);
211 let linkEditor
= this.lookup('linkEditor');
213 let jsons
= Ext
.util
.Base64
.decode(value
);
214 let joinInfo
= Ext
.JSON
.decode(jsons
, true);
222 if (!(joinInfo
&& joinInfo
.totem
)) {
224 linkEditor
.setLinks([]);
225 linkEditor
.setInfoText();
226 vm
.set('hasAssistedInfo', false);
228 let interfaces
= joinInfo
.totem
.interface;
229 let links
= Object
.values(interfaces
).map(iface
=> {
230 let linkNumber
= iface
.linknumber
;
232 if (joinInfo
.peerLinks
) {
233 peerLink
= joinInfo
.peerLinks
[linkNumber
];
238 text
: peerLink
? Ext
.String
.format(gettext("peer's link address: {0}"), peerLink
) : '',
243 linkEditor
.setInfoText();
244 if (links
.length
=== 1 && joinInfo
.ring_addr
!== undefined &&
245 joinInfo
.ring_addr
[0] === joinInfo
.ipAddress
247 links
[0].allowBlank
= true;
248 links
[0].emptyText
= gettext("IP resolved by node's hostname");
251 linkEditor
.setLinks(links
);
254 ip
: joinInfo
.ipAddress
,
255 fp
: joinInfo
.fingerprint
,
256 clusterName
: joinInfo
.totem
.cluster_name
,
259 vm
.set('hasAssistedInfo', true);
261 vm
.set('info', info
);
266 // joining may produce temporarily auth failures, ignore as long the task runs
267 PVE
.Utils
.silenceAuthFailures
= true;
271 taskDone: function(success
) {
272 delete PVE
.Utils
.silenceAuthFailures
;
274 // reload always (if user wasn't faster), but wait a bit for pveproxy
275 Ext
.defer(function() {
276 window
.location
.reload(true);
278 let txt
= gettext('Cluster join task finished, node certificate may have changed, reload GUI!');
279 // ensure user cannot do harm
280 Ext
.getBody().mask(txt
, ['pve-static-mask']);
281 // TaskView may hide above mask, so tell him directly
283 title
: gettext('Join Task Finished'),
291 xtype
: 'proxmoxcheckbox',
292 reference
: 'assistedEntry',
293 name
: 'assistedEntry',
294 itemId
: 'assistedEntry',
299 'data-qtip': gettext('Select if join information should be extracted from pasted cluster information, deselect for manual entering'),
301 boxLabel
: gettext('Assisted join: Paste encoded cluster join information and enter password.'),
305 name
: 'serializedinfo',
308 fieldLabel
: gettext('Information'),
309 emptyText
: gettext('Paste encoded Cluster Information here'),
310 validator: function(val
) {
311 return val
=== '' || this.valid
|| gettext('Does not seem like a valid encoded Cluster Information!');
314 disabled
: '{!assistedEntry.checked}',
315 hidden
: '{!assistedEntry.checked}',
327 hidden
: '{!showClusterFields}',
334 fieldLabel
: gettext('Peer Address'),
338 readOnly
: '{assistedEntry.checked}',
345 margin
: '0 0 10px 5px',
346 inputType
: 'password',
347 emptyText
: gettext("Peer's root password"),
348 fieldLabel
: gettext('Password'),
356 fieldLabel
: gettext('Fingerprint'),
360 readOnly
: '{assistedEntry.checked}',
361 hidden
: '{!showClusterFields}',
366 xtype
: 'fieldcontainer',
367 fieldLabel
: gettext("Cluster Network"),
369 hidden
: '{!showClusterFields}',
373 xtype
: 'pveCorosyncLinkEditor',
374 itemId
: 'linkEditor',
375 reference
: 'linkEditor',
376 allowNumberEdit
: false,