]>
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
: 'fieldcontainer',
29 fieldLabel
: gettext("Cluster Network"),
32 xtype
: 'pveCorosyncLinkEditor',
33 infoText
: gettext("Multiple links are used as failover, lower numbers have higher priority."),
41 Ext
.define('PVE.ClusterInfoWindow', {
42 extend
: 'Ext.window.Window',
43 xtype
: 'pveClusterInfoWindow',
44 mixins
: ['Proxmox.Mixin.CBind'],
49 title
: gettext('Cluster Join Information'),
53 fingerprint
: undefined,
61 padding
: '10 10 10 10',
62 html
: gettext("Copy the Join Information here and use it on the node you want to add.")
68 padding
: '0 10 10 10',
72 fieldLabel
: gettext('IP Address'),
74 value
: '{joinInfo.ipAddress}',
80 fieldLabel
: gettext('Fingerprint'),
82 value
: '{joinInfo.fingerprint}',
88 inputId
: 'pveSerializedClusterInfo',
89 fieldLabel
: gettext('Join Information'),
92 joinInfo
: '{joinInfo}',
96 afterrender: function(field
) {
97 if (!field
.joinInfo
) {
100 var jsons
= Ext
.JSON
.encode(field
.joinInfo
);
101 var base64s
= Ext
.util
.Base64
.encode(jsons
);
102 field
.setValue(base64s
);
114 handler: function(b
) {
115 var el
= document
.getElementById('pveSerializedClusterInfo');
117 document
.execCommand("copy");
119 text
: gettext('Copy Information')
124 Ext
.define('PVE.ClusterJoinNodeWindow', {
125 extend
: 'Proxmox.window.Edit',
126 xtype
: 'pveClusterJoinNodeWindow',
128 title
: gettext('Cluster Join'),
132 url
: '/cluster/config/join',
134 defaultFocus
: 'textarea[name=serializedinfo]',
137 submitText
: '{submittxt}',
139 showTaskViewer
: true,
141 onlineHelp
: 'pvecm_join_node_to_cluster',
153 submittxt: function(get) {
154 let cn
= get('info.clusterName');
156 return Ext
.String
.format(gettext('Join {0}'), `'${cn}'`);
158 return gettext('Join');
164 xclass
: 'Ext.app.ViewController',
168 delete PVE
.Utils
.silenceAuthFailures
;
171 'proxmoxcheckbox[name=assistedEntry]': {
172 change
: 'onInputTypeChange'
174 'textarea[name=serializedinfo]': {
175 change
: 'recomputeSerializedInfo',
179 disable
: 'resetField'
182 resetField: function(field
) {
185 onInputTypeChange: function(field
, assistedInput
) {
186 let linkEditor
= this.lookup('linkEditor');
188 // this also clears all links
189 linkEditor
.setAllowNumberEdit(!assistedInput
);
191 if (!assistedInput
) {
192 linkEditor
.setInfoText();
193 linkEditor
.setDefaultLinks();
196 recomputeSerializedInfo: function(field
, value
) {
197 let vm
= this.getViewModel();
199 let assistedEntryBox
= this.lookup('assistedEntry');
200 if (!assistedEntryBox
.getValue()) {
201 // not in assisted entry mode, nothing to do
205 let linkEditor
= this.lookup('linkEditor');
207 let jsons
= Ext
.util
.Base64
.decode(value
);
208 let joinInfo
= Ext
.JSON
.decode(jsons
, true);
216 if (!(joinInfo
&& joinInfo
.totem
)) {
218 linkEditor
.setLinks([]);
219 linkEditor
.setInfoText();
221 let interfaces
= joinInfo
.totem
.interface;
222 let links
= Object
.values(interfaces
).map(iface
=> {
223 let linkNumber
= iface
.linknumber
;
225 if (joinInfo
.peerLinks
) {
226 peerLink
= joinInfo
.peerLinks
[linkNumber
];
231 text
: peerLink
? Ext
.String
.format(gettext("peer's link address: {0}"), peerLink
) : '',
236 linkEditor
.setInfoText();
237 if (links
.length
== 1 && joinInfo
.ring_addr
!== undefined &&
238 joinInfo
.ring_addr
[0] === joinInfo
.ipAddress
) {
240 links
[0].allowBlank
= true;
241 links
[0].emptyText
= gettext("IP resolved by node's hostname");
244 linkEditor
.setLinks(links
);
247 ip
: joinInfo
.ipAddress
,
248 fp
: joinInfo
.fingerprint
,
249 clusterName
: joinInfo
.totem
.cluster_name
254 vm
.set('info', info
);
259 // joining may produce temporarily auth failures, ignore as long the task runs
260 PVE
.Utils
.silenceAuthFailures
= true;
264 taskDone: function(success
) {
265 delete PVE
.Utils
.silenceAuthFailures
;
267 // reload always (if user wasn't faster), but wait a bit for pveproxy
268 Ext
.defer(function() {
269 window
.location
.reload(true);
271 var txt
= gettext('Cluster join task finished, node certificate may have changed, reload GUI!');
272 // ensure user cannot do harm
273 Ext
.getBody().mask(txt
, ['pve-static-mask']);
274 // TaskView may hide above mask, so tell him directly
276 title
: gettext('Join Task Finished'),
284 xtype
: 'proxmoxcheckbox',
285 reference
: 'assistedEntry',
286 name
: 'assistedEntry',
287 itemId
: 'assistedEntry',
292 'data-qtip': gettext('Select if join information should be extracted from pasted cluster information, deselect for manual entering')
294 boxLabel
: gettext('Assisted join: Paste encoded cluster join information and enter password.')
298 name
: 'serializedinfo',
301 fieldLabel
: gettext('Information'),
302 emptyText
: gettext('Paste encoded Cluster Information here'),
303 validator: function(val
) {
304 return val
=== '' || this.valid
||
305 gettext('Does not seem like a valid encoded Cluster Information!');
308 disabled
: '{!assistedEntry.checked}',
309 hidden
: '{!assistedEntry.checked}'
325 fieldLabel
: gettext('Peer Address'),
329 readOnly
: '{assistedEntry.checked}',
336 margin
: '0 0 10px 5px',
337 inputType
: 'password',
338 emptyText
: gettext("Peer's root password"),
339 fieldLabel
: gettext('Password'),
347 fieldLabel
: gettext('Fingerprint'),
351 readOnly
: '{assistedEntry.checked}'
356 xtype
: 'fieldcontainer',
357 fieldLabel
: gettext("Cluster Network"),
360 xtype
: 'pveCorosyncLinkEditor',
361 itemId
: 'linkEditor',
362 reference
: 'linkEditor',
363 allowNumberEdit
: false