View | Details | Raw Unified | Return to bug 36272
Collapse All | Expand All

(-)umc/js/uvmm/CloudConnectionWizard.js (-6 / +10 lines)
 Lines 48-54    Link Here 
48
		buildRendering: function() {
48
		buildRendering: function() {
49
			this.pages.push({
49
			this.pages.push({
50
				name: 'pre_finish',
50
				name: 'pre_finish',
51
				widgets: []
51
				widgets: [{
52
					name: 'dn',
53
					type: TextBox,
54
					visible: false
55
				}]
52
			});
56
			});
53
			this.inherited(arguments);
57
			this.inherited(arguments);
54
		},
58
		},
 Lines 68-89    Link Here 
68
		},
72
		},
69
73
70
		_testConnection: function(values) {
74
		_testConnection: function(values) {
71
			this.standby(true);
75
			var dn = values.dn;
72
			return tools.umcpCommand('uvmm/cloud/add', {
76
			delete values.dn;
77
			return this.standbyDuring(tools.umcpCommand('uvmm/cloud/add', {
73
				cloudtype: values.cloudtype,
78
				cloudtype: values.cloudtype,
74
				name: values.name,
79
				name: values.name,
80
				dn: dn,
75
				testconnection: true,
81
				testconnection: true,
76
				parameter: values
82
				parameter: values
77
			}).then(lang.hitch(this, function(response) {
83
			}).then(lang.hitch(this, function(response) {
78
				this.moduleStore.onChange();
84
				this.moduleStore.onChange();
79
				this.standby(false);
80
				this.onFinished(response, values);
85
				this.onFinished(response, values);
81
			}), lang.hitch(this, function(errormsg) {
86
			}), lang.hitch(this, function(errormsg) {
82
				this.standby(false);
83
				// show error message
87
				// show error message
84
				dialog.alert('Error: ' + errormsg);
88
				dialog.alert('Error: ' + errormsg);
85
				return 'general';
89
				return 'general';
86
			}));
90
			})));
87
		},
91
		},
88
92
89
		next: function(currentPage) {
93
		next: function(currentPage) {
(-)umc/js/uvmm/EC2.js (-2 / +2 lines)
 Lines 40-52    Link Here 
40
			this.inherited(arguments);
40
			this.inherited(arguments);
41
			this.pages = [{
41
			this.pages = [{
42
				name: 'credentials',
42
				name: 'credentials',
43
				headerText: _('Create a new cloud connection.'),
43
				headerText: _('Cloud connection'),
44
				helpText: _('Please enter the corresponding credentials for the cloud connection. <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSGettingStartedGuide/AWSCredentials.html" target=_blank>Use this link to get information about AWS credentials</a>'),
44
				helpText: _('Please enter the corresponding credentials for the cloud connection. <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSGettingStartedGuide/AWSCredentials.html" target=_blank>Use this link to get information about AWS credentials</a>'),
45
				layout: [
45
				layout: [
46
					'name',
46
					'name',
47
					'region',
47
					'region',
48
					'access_id',
48
					'access_id',
49
					'password',
49
					'password'
50
				],
50
				],
51
				widgets: [{
51
				widgets: [{
52
					name: 'name',
52
					name: 'name',
(-)umc/js/uvmm.js (-13 / +33 lines)
 Lines 258-282    Link Here 
258
258
259
			// add a context menu to edit/delete items
259
			// add a context menu to edit/delete items
260
			var menu = new Menu({});
260
			var menu = new Menu({});
261
			menu.addChild(new MenuItem({
261
			menu.addChild(this._menuEdit = new MenuItem({
262
				label: _( 'Edit' ),
262
				label: _( 'Edit' ),
263
				iconClass: 'umcIconEdit',
263
				iconClass: 'umcIconEdit',
264
				onClick: lang.hitch(this, function(e) {
264
				onClick: lang.hitch(this, function() {
265
					if(this._navContextItem) {
265
					console.log(this._navContextItem.id);
266
						if(this._navContextItem.type == 'cloud' && this._navContextItem.dn) {
266
					this._editCloudConnection(this._navContextItem);
267
							require('umc/app').openModule('udm', 'uvmm/cloudconnection',{'openObject': {'objectDN': this._navContextItem.dn, 'objectType': 'uvmm/cloudconnection'}});
267
				})
268
						} else if(this._navContextItem.type == 'cloud' || (this._navContextItem.type == 'group' && this._navContextItem.id == 'cloudconnections')) {
268
			}));
269
							require('umc/app').openModule('udm', 'uvmm/cloudconnection');
269
			menu.addChild(this._menuDelete = new MenuItem({
270
						}
271
					}
272
				})}));
273
	/*		menu.addChild(new MenuItem({
274
				label: _( 'Delete' ),
270
				label: _( 'Delete' ),
275
				iconClass: 'umcIconDelete',
271
				iconClass: 'umcIconDelete',
276
				onClick: lang.hitch(this, function() {
272
				onClick: lang.hitch(this, function() {
277
					this.removeObjects(this._navContextItem.id);
273
					this.removeObjects(this._navContextItem.id);
278
				})
274
				})
279
			}));*/
275
			}));
280
			menu.addChild(new MenuItem({
276
			menu.addChild(new MenuItem({
281
				label: _( 'Reload' ),
277
				label: _( 'Reload' ),
282
				iconClass: 'umcIconRefresh',
278
				iconClass: 'umcIconRefresh',
 Lines 295-300    Link Here 
295
			}), true));
291
			}), true));
296
			this.own(aspect.before(menu, '_openMyself', lang.hitch(this, function() {
292
			this.own(aspect.before(menu, '_openMyself', lang.hitch(this, function() {
297
				this._navContextItem = this._navContextItemFocused;
293
				this._navContextItem = this._navContextItemFocused;
294
				this._updateMenuAvailability();
298
			})));
295
			})));
299
296
300
			// when we right-click anywhere on the tree, make sure we open the menu
297
			// when we right-click anywhere on the tree, make sure we open the menu
 Lines 348-353    Link Here 
348
			this._domainPage.on('UpdateProgress', lang.hitch(this, 'updateProgress'));
345
			this._domainPage.on('UpdateProgress', lang.hitch(this, 'updateProgress'));
349
		},
346
		},
350
347
348
		_updateMenuAvailability: function() {
349
			var item = this._navContextItemFocused;
350
			var canEdit = item.type == 'cloud' && item.dn;
351
			var canDelete = canEdit;
352
			this._menuEdit.set('disabled', !canEdit);
353
			this._menuDelete.set('disabled', !canDelete);
354
		},
355
351
		postCreate: function() {
356
		postCreate: function() {
352
			this.inherited(arguments);
357
			this.inherited(arguments);
353
358
 Lines 744-749    Link Here 
744
			this.selectChild(wizard);
749
			this.selectChild(wizard);
745
		},
750
		},
746
751
752
		_editCloudConnection: function(item) {
753
			var values = {cloudtype: item.cloudtype};
754
			this._addCloudConnection(values).then(lang.hitch(this, function(wizard) {
755
				tools.forIn(wizard._pages, function(pageName, page) {
756
					tools.forIn(item.params, function(key, value) {
757
						var widget = wizard.getWidget(pageName, key);
758
						if (widget) {
759
							widget.set('value', value);
760
						}
761
					});
762
				});
763
			}));
764
		},
765
747
		_addCloudConnection: function(values) {
766
		_addCloudConnection: function(values) {
748
			var wizard = null;
767
			var wizard = null;
749
768
 Lines 786-792    Link Here 
786
				tools.defer(wait, 1000);
805
				tools.defer(wait, 1000);
787
			});
806
			});
788
807
789
			this.loadWizardPages(values.cloudtype).then(lang.hitch(this, function(Wizard) {
808
			return this.loadWizardPages(values.cloudtype).then(lang.hitch(this, function(Wizard) {
790
				wizard = new Wizard({
809
				wizard = new Wizard({
791
					autoValidate: true,
810
					autoValidate: true,
792
					onFinished: _finished,
811
					onFinished: _finished,
 Lines 797-802    Link Here 
797
				});
816
				});
798
				this.addChild(wizard);
817
				this.addChild(wizard);
799
				this.selectChild(wizard);
818
				this.selectChild(wizard);
819
				return wizard;
800
			}));
820
			}));
801
		},
821
		},
802
822
(-)umc/python/uvmm/cloud.py (-9 / +22 lines)
 Lines 36-43    Link Here 
36
from univention.management.console.log import MODULE
36
from univention.management.console.log import MODULE
37
from univention.management.console.modules.decorators import sanitize
37
from univention.management.console.modules.decorators import sanitize
38
from univention.management.console.modules.sanitizers import SearchSanitizer, ChoicesSanitizer
38
from univention.management.console.modules.sanitizers import SearchSanitizer, ChoicesSanitizer
39
from univention.uvmm.uvmm_ldap import ldap_cloud_types, ldap_cloud_connection_add
39
from univention.uvmm.uvmm_ldap import ldap_cloud_types, ldap_cloud_connection_add, ldap_cloud_connection_edit
40
from subprocess import call
41
40
42
from notifier import Callback
41
from notifier import Callback
43
from urlparse import urldefrag
42
from urlparse import urldefrag
 Lines 87-92    Link Here 
87
						'cloudtype': d.cloudtype,
86
						'cloudtype': d.cloudtype,
88
						'available': d.available,
87
						'available': d.available,
89
						'last_error_message': d.last_error_message,
88
						'last_error_message': d.last_error_message,
89
						'params': d.params,
90
						'dn': d.dn,
90
						'dn': d.dn,
91
						})
91
						})
92
92
 Lines 126-132    Link Here 
126
126
127
			if success:
127
			if success:
128
				# add cloud to ldap
128
				# add cloud to ldap
129
				ldap_cloud_connection_add(cloudtype, name, parameter)
129
				if dn:
130
					ldap_cloud_connection_edit(cloudtype, dn, name, parameter)
131
				else:
132
					ldap_cloud_connection_add(cloudtype, name, parameter)
130
133
131
				self.finished(request.id, data)
134
				self.finished(request.id, data)
132
			else:
135
			else:
 Lines 143-160    Link Here 
143
		name = request.options.get('name')
146
		name = request.options.get('name')
144
		testconnection = request.options.get('testconnection')
147
		testconnection = request.options.get('testconnection')
145
		parameter = request.options.get('parameter')
148
		parameter = request.options.get('parameter')
149
		dn = request.options.get('dn')
146
150
147
		# add cloud to uvmm
151
		# add cloud to uvmm
148
		args = parameter
152
		args = parameter
149
		args['name'] = name
153
		args['name'] = name
150
		args['type'] = cloudtype
154
		args['type'] = cloudtype
151
155
152
		self.uvmm.send(
156
		if dn:
153
				'L_CLOUD_ADD',
157
			self.uvmm.send(
154
				Callback(_finished, request),
158
					'L_CLOUD_EDIT',
155
				args=args,
159
					Callback(_finished, request),
156
				testconnection=testconnection
160
					args=args,
157
				)
161
					dn=dn,
162
					testconnection=testconnection
163
					)
164
		else:
165
			self.uvmm.send(
166
					'L_CLOUD_ADD',
167
					Callback(_finished, request),
168
					args=args,
169
					testconnection=testconnection
170
					)
158
171
159
172
160
	def cloud_list_keypair(self, request):
173
	def cloud_list_keypair(self, request):
(-)src/univention/uvmm/cloudconnection.py (+1 lines)
 Lines 79-84    Link Here 
79
		self.publicdata.last_update_try = -1
79
		self.publicdata.last_update_try = -1
80
		self.publicdata.available = False
80
		self.publicdata.available = False
81
		self.publicdata.last_error_message = ""
81
		self.publicdata.last_error_message = ""
82
		self.publicdata.params = cloud.copy()
82
		self._last_expensive_update = -1000000
83
		self._last_expensive_update = -1000000
83
84
84
		self._instances = []
85
		self._instances = []
(-)src/univention/uvmm/cloudnode.py (+2 lines)
 Lines 133-142    Link Here 
133
	def remove_connection(self, cloudname):
133
	def remove_connection(self, cloudname):
134
		"""Remove connection; cloudname = ldap name attribute"""
134
		"""Remove connection; cloudname = ldap name attribute"""
135
		try:
135
		try:
136
			connection = self.get(cloudname)
136
			del self[cloudname]
137
			del self[cloudname]
137
		except KeyError:
138
		except KeyError:
138
			raise CloudConnectionError("No Connection to %s present" % cloudname)
139
			raise CloudConnectionError("No Connection to %s present" % cloudname)
139
		logger.info("Removed connection to %s" % cloudname)
140
		logger.info("Removed connection to %s" % cloudname)
141
		return connection
140
142
141
	def list_conn_instances(self, conn_name, pattern="*"):
143
	def list_conn_instances(self, conn_name, pattern="*"):
142
		"""
144
		"""
(-)src/univention/uvmm/commands.py (+26 lines)
 Lines 36-41    Link Here 
36
"""
36
"""
37
import copy
37
import copy
38
38
39
import ldap
40
39
import protocol
41
import protocol
40
import node
42
import node
41
import cloudnode
43
import cloudnode
 Lines 70-75    Link Here 
70
			raise CommandError('L_CLOUD_ADD', e)
72
			raise CommandError('L_CLOUD_ADD', e)
71
73
72
	@staticmethod
74
	@staticmethod
75
	def L_CLOUD_EDIT(server, request):
76
		""" Edit cloud via libcloud """
77
		if not isinstance(request.dn, basestring):
78
			raise CommandError('L_CLOUD_EDIT', _('dn != dict: %(dn)s'), dn=request.dn)
79
80
		if not isinstance(request.args, dict):
81
			raise CommandError('L_CLOUD_EDIT', _('args != dict: %(args)s'), args=request.args)
82
83
		if not isinstance(request.testconnection, bool):
84
			raise CommandError('L_CLOUD_EDIT', _('testconnection is not a bool %(testconnection)s'), testconnection=request.testconnection)
85
86
		logger.debug('L_CLOUD_EDIT %s %s, testconnection: %s' % (request.dn, request.args, request.testconnection))
87
		old_name = ldap.explode_dn(request.dn, 1)[0]
88
		old_args = None
89
		try:
90
			old_connection = cloudnode.cloudconnections.remove_connection(old_name)
91
			cloudnode.cloudconnections.add_connection(request.args, request.testconnection)
92
		except cloudnode.CloudConnectionError, e:
93
			if old_args is not None:
94
				cloudnode.cloudconnections[old_name] = old_connection
95
				#old_connection.connect(cloud, False)
96
			raise CommandError('L_CLOUD_EDIT', e)
97
98
	@staticmethod
73
	def L_CLOUD_REMOVE(server, request):
99
	def L_CLOUD_REMOVE(server, request):
74
		""" Remove cloud via libcloud """
100
		""" Remove cloud via libcloud """
75
		if not isinstance(request.name, basestring):
101
		if not isinstance(request.name, basestring):
(-)src/univention/uvmm/protocol.py (+8 lines)
 Lines 278-283    Link Here 
278
		self.args = None
278
		self.args = None
279
		self.testconnection = True
279
		self.testconnection = True
280
280
281
class Request_L_CLOUD_EDIT(Request):
282
	"""Add libcloud cloud connection"""
283
	def _default(self):
284
		self.command = 'L_CLOUD_EDIT'
285
		self.dn = None
286
		self.args = None
287
		self.testconnection = True
288
281
class Request_L_CLOUD_REMOVE(Request):
289
class Request_L_CLOUD_REMOVE(Request):
282
	"""Remove libcloud cloud connection"""
290
	"""Remove libcloud cloud connection"""
283
	def _default(self):
291
	def _default(self):
(-)src/univention/uvmm/uvmm_ldap.py (+20 lines)
 Lines 236-241    Link Here 
236
	except LDAPError, e:
236
	except LDAPError, e:
237
		raise LdapConnectionError(_('Could not open LDAP-Admin connection'))
237
		raise LdapConnectionError(_('Could not open LDAP-Admin connection'))
238
238
239
def ldap_cloud_connection_edit(cloudtype, dn, name, parameter):
240
	""" Modify an existing cloud connection."""
241
	try:
242
		lo, position = univention.admin.uldap.getMachineConnection()
243
		parameter_lst = []
244
		for k,v in parameter.items():
245
			if (k and v):
246
				parameter_lst.append('%s=%s' % (k,v))
247
		attrs = {
248
			'objectClass': ['univentionVirtualMachineCloudConnection', 'univentionVirtualMachineHostOC', 'univentionObject'],
249
			'univentionObjectType': 'uvmm/cloudconnection',
250
			'cn': name,
251
			'univentionVirtualMachineCloudConnectionParameter': parameter_lst
252
		}
253
		modlist = [(k,None,v) for k,v in attrs.items()]
254
		lo.modify(dn, modlist)
255
256
	except LDAPError:
257
		raise LdapConnectionError(_('Could not open LDAP-Admin connection'))
258
239
def ldap_cloud_connection_add(cloudtype, name, parameter):
259
def ldap_cloud_connection_add(cloudtype, name, parameter):
240
	""" Add a new cloud connection."""
260
	""" Add a new cloud connection."""
241
	try:
261
	try:

Return to bug 36272