Example #1
0
	def __printer_search_form( self, filter = '*', key = 'printer' ):
		select = umcd.make( self[ 'cups/list' ][ 'key' ], default = key,
							attributes = { 'width' : '200' } )
		text = umcd.make( self[ 'cups/list' ][ 'filter' ], default = filter,
						  attributes = { 'width' : '250' } )
		form = umcd.SearchForm( 'cups/list', [ [ ( select, 'printer' ), ( text, '*' ) ] ] )
		return form
Example #2
0
 def __printer_search_form(self, filter='*', key='printer'):
     select = umcd.make(self['cups/list']['key'],
                        default=key,
                        attributes={'width': '200'})
     text = umcd.make(self['cups/list']['filter'],
                      default=filter,
                      attributes={'width': '250'})
     form = umcd.SearchForm('cups/list', [[(select, 'printer'),
                                           (text, '*')]])
     return form
Example #3
0
	def _web_cups_quota_user_show( self, object, res ):
		lst = umcd.List()

		quota = res.dialog
		if quota[ 'user' ]:
			headline = _( "Modify print quota setting for user '%(user)s' on printer %(printer)s" ) % quota
		else:
			headline = _( "Add print quota entry on printer %(printer)s" ) % quota

		# user and partition
		if not quota['user']:
			user = umcd.make( self[ 'cups/quota/user/set' ][ 'user' ] )
		else:
			if type(quota['user']) == type([]):
				user = umcd.make_readonly( self[ 'cups/quota/user/set' ][ 'user' ], default = ','.join(quota['user']) )
			else:
				user = umcd.make_readonly( self[ 'cups/quota/user/set' ][ 'user' ], default = quota['user'] )
		items = [ user.id() ]

		if not quota['printer']:
			printer = umcd.make( self[ 'cups/quota/user/set' ][ 'printer' ] )
		else:
			printer = umcd.make_readonly( self[ 'cups/quota/user/set' ][ 'printer' ],
											default = quota['printer'] )
		items += [ printer.id() ]
		lst.add_row( [ user, printer ] )

		soft = umcd.make( self[ 'cups/quota/user/set' ][ 'softlimit' ], default = quota['softlimit'] )
		hard = umcd.make( self[ 'cups/quota/user/set' ][ 'hardlimit' ], default = quota['hardlimit'] )
		items += [ soft.id(), hard.id() ]
		lst.add_row( [ soft, hard ] )

		opts = { 'softlimit' : quota['softlimit'],
				 'hardlimit' : quota['hardlimit']}
		if quota['printer']:
			opts['printer'] = quota['printer']
		if quota['user']:
			opts['user'] = quota['user']

		req = umcp.Command( args = [ 'cups/quota/user/set' ], opts = opts )
		if quota['printer']:
			req_show = umcp.Command( args = [ 'cups/quota/user/show' ],
									 opts = { 'printer' : quota['printer'] } )
			items_show = []
		else:
			req_show = umcp.Command( args = [ 'cups/quota/user/show' ] )
			items_show = [ printer.id(), ]

		actions = ( umcd.Action( req, items ), umcd.Action( req_show, items_show ) )
		button = umcd.SetButton( actions )
		cancel = umcd.CancelButton( attributes = { 'align' : 'right' } )
		lst.add_row( [ button, cancel ] )

		res.dialog = umcd.Frame( [ lst ], headline )
		self.revamped( object.id(), res )
Example #4
0
	def __init__(self, command, change=False): #, show_paravirtual = False
		umcd.IWizard.__init__( self, command )
		if change:
			self.title = _('Change media')
		else:
			self.title = _('Add drive')
		self.change = change
		self.pool_syntax = DynamicSelect( _( 'Storage pool' ) )
		self.image_syntax = DynamicSelect( _( 'Drive image' ) )
		self.driver_syntax = DynamicSelect( _( 'Image format' ) )
		self.drive_type_select = DriveTypeSelect()
		self.disk_select = DiskSelect()
		self.actions[ 'pool-selected' ] = self.pool_selected
		self.actions['type-selected'] = self.type_selected
		self.uvmm = uvmmd.Client( auto_connect = False )
		self.domain_name = None
		self.domain_virttech = VirtTech()
		self.node_uri = None
		self.node_info = None
		self.reset()

		# PAGE_INIT=0: Select HD or ROM
		page = umcd.Page( self.title, _( 'What type of drive should be created?' ) )
		page.options.append( umcd.make( ( 'drive-type', self.drive_type_select ) ) )
		self.append( page )

		# PAGE_HD=1: Select (new or) existing image or block device
		if change:
			page = umcd.Page(self.title, _('Choose between using an existing image or using a local device.'))
		else:
			page = umcd.Page(self.title, _('For the drive a new image can be created or an existing one can be chosen. An existing image should only be used by one virtual instance at a time.'))
		page.options.append( umcd.make( ( 'existing-or-new-disk', self.disk_select ) ) )
		self.append( page )

		# PAGE_OLD=2: Select existing image
		page = umcd.Page( self.title )
		page.options.append( umcd.Text( '' ) ) # will be replaced with pool selection button
		page.options.append( umcd.make( ( 'vol-name-old', self.image_syntax ) ) )
		self.append( page )

		# PAGE_NEW=3: [Only new HD] Select name and size
		page = umcd.Page( self.title, _( 'Each hard drive image is located within a so called storage pool, which might be a local directory, a device, an LVM volume or any type of share (e.g. mounted via iSCSI, NFS or CIFS). The newly create image will have the specified name and size provided by the following settings. Currently these was been set to default images. It has to be ensured that there is enough space left in the defined storage pool.' ) )
		page.options.append( umcd.Text( '' ) ) # will be replaced with pool selection button
		page.options.append(umcd.Text('')) # will be replaced with driver type selection button
		page.options.append( umcd.make( ( 'vol-name-new', umc.String( _( 'Filename' ) ) ) ) )
		page.options.append( umcd.make( ( 'image-size', umc.String( _( 'Size (default unit MB)' ), regex = MemorySize.SIZE_REGEX ) ) ) )
		self.append( page )

		# PAGE_MANUAL=4: Enter block device
		page = umcd.Page( self.title, _( 'To bind the drive to a local device the filename of the associated block device must be specified.' ) )
		page.options.append( umcd.make( ( 'vol-name-dev', umc.String( _( 'Device filename' ) ) ) ) )
		self.append( page )

		# PAGE_SUMMARY=5: Show summary
		if change:
			page = umcd.Page(self.title, _('The following drive will be updated:'))
		else:
			page = umcd.Page(self.title, _('The following drive will be created:'))
		self.append( page )
Example #5
0
	def __init__( self, command ):
		umcd.IWizard.__init__( self, command )
		self.title = _( 'Create new virtual instance' )
		self.udm = udm.Client()
		self.uvmm = uvmmd.Client( auto_connect = False )
		self.node_info = None
		self.profile_syntax = DynamicSelect( _( 'Profiles' ) )
		self.drive_wizard = DriveWizard(command)
		self.drive_wizard_active = False
		self.actions[ 'new-drive' ] = self.new_drive
		self.actions[ 'pool-selected' ] = self.drive_wizard.pool_selected # FIXME: KeyError 'drive-type'
		self.actions['type-selected'] = self.drive_wizard.type_selected
		self.drives = []

		# PAGE_INIT=0
		page = umcd.Page( self.title, _( 'By selecting a profile for the virtual instance most of the settings will be set to default values. In the following steps some of these values might be modified. After the creation of the virtual instance all parameters, extended settings und attached drives can be adjusted. It should be ensured that the profile is for the correct architecture as this option can not be changed afterwards.' ) )
		page.options.append( umcd.make( ( 'instance-profile', self.profile_syntax ) ) )
		self.append( page )

		# PAGE_BASIC=1
		page = umcd.Page( self.title, _( 'The following settings were read from the selected profile and can be modified now.' ) )
		page.options.append( umcd.make( ( 'name', umc.String( _( 'Name' ) ) ) ) )
		page.options.append( umcd.make( ( 'description', umc.String( _( 'Description' ), required = False ) ) ) )
		page.options.append( umcd.make( ( 'memory', umc.String( _( 'Memory (in MB)' ), regex = MemorySize.SIZE_REGEX ) ) ) )
		page.options.append( umcd.make( ( 'cpus', NumberSelect( _( 'CPUs' ) ) ) ) )
		page.options.append( umcd.make( ( 'vnc', umc.Boolean( _( 'Enable direct access' ) ) ) ) )
		self.append( page )

		# PAGE_SUMMARY=2
		page = umcd.Page( self.title, umcd.HTML( _( 'The virtual instance will be created with the settings shown below. The button <i>Add drive</i> can be used to attach another drive.' ) ) )
		page.options.append( umcd.HTML( '' ) )
		add_cmd = umcp.SimpleCommand(command, options={'action': 'new-drive'})
		add_act = umcd.Action(add_cmd)
		add_btn = umcd.LinkButton(_('Add drive'), 'uvmm/add', actions=(add_act,))
		add_btn.set_size(umct.SIZE_SMALL)
		page.actions.append( add_btn )
		self.append( page )
Example #6
0
File: nic.py Project: B-Rich/smart
	def uvmm_nic_dialog( self, response, domain_info, object, command ):
		nic_driver_select.virttech = domain_info.domain_type
		nic_list = umcd.List( attributes = { 'width' : '100%' }, default_type = 'uvmm_table'  )
		ids = []

		nic_list.add_row( [ umcd.HTML( _( 'Two types of network interfaces are support. The first one is <i>Bridge</i> that requires a static network connection on the physical server that is configurated to be used for bridging. By default the network interface called eth0 is setup for such a case on each UVMM node. If a virtual instance should have more than one bridging network interface, additional network interfaces on the physical server must be configured first. The second type is <i>NAT</i> that provides a private network for virtual instances on the physical server and permits access to the external network. This network type is useful for computers with varying network connections like notebooks. For such an interface the network configuration of the UVMM node needs to be modified. This is done automatically by the UVMM service when starting the virtual instance. Further details about the network configuration can be found in <a href="http://sdb.univention.de/1172" target="_blank">this article</a>.' ), attributes = { 'colspan' : '2' } ) ] )
		options = copy.copy( object.options )
		cmd = umcp.SimpleCommand( 'uvmm/nic/%s' % command, options = options )
		cmd.incomplete = True
		choices = ( ( 'bridge', _( 'Bridge' ) ), ( 'network:default', _( 'NAT' ) ) )
		# TODO currently we just support the network default
		if object.options.get( 'nictype' ) == 'network':
			object.options[ 'nictype' ] = 'network:default'
		nic_type = umcd.SimpleSelectButton( _( 'Type' ), option = 'nictype', choices = choices, actions = [ umcd.Action( cmd ) ], default = object.options.get( 'nictype', 'bridge' ) )
		# nic_type = umcd.make( self[ 'uvmm/nic/create' ][ 'nictype' ] )
		if object.options.get( 'nictype', '' ).startswith( 'network:' ):
			info = umcd.InfoBox( _( 'By default the private network is 192.168.122.0/24' ) )
		else:
			info = ''
		nic_list.add_row( [ nic_type, info ] )
		ids.append( nic_type.id() )

		default_driver = object.options.get( 'driver', None )
		if default_driver is None:
			if domain_info.os_type in ( 'xen', 'linux' ):
				default_driver = 'netfront'
			else:
				default_driver = 'rtl8139'
		nic_driver = umcd.make( self[ 'uvmm/nic/create' ][ 'driver' ], default = default_driver )
		nic_list.add_row( [ nic_driver, '' ] )
		ids.append( nic_driver.id() )

		if object.options.get( 'nictype', 'bridge' ) == 'bridge':
			nic_source = umcd.make( self[ 'uvmm/nic/create' ][ 'source' ], default = object.options.get( 'source', 'eth0' ) )
			info = umcd.InfoBox( _( 'The source is the name of the network interface on the phyiscal server that is configured for bridging. By default it is eth0.' ) )
			nic_list.add_row( [ nic_source, info ] )
			ids.append( nic_source.id() )

		nic_mac = umcd.make( self[ 'uvmm/nic/create' ][ 'mac' ], default = object.options.get( 'mac', '' ) )
		nic_list.add_row( [ nic_mac, '' ] )
		ids.append( nic_mac.id() )

		opts = copy.copy( object.options )
		if not 'nictype' in opts:
			opts[ 'nictype' ] = 'bridge'
		cmd = umcp.SimpleCommand( 'uvmm/nic/%s' % command, options = opts )
		options = copy.copy( object.options )
		for key in ( 'nictype', 'driver', 'source', 'mac' ):
			if key in options:
				del options[ key ]
			if 'old-%s' % key in options:
				del options[ 'old-%s' % key ]
		overview_cmd = umcp.SimpleCommand( 'uvmm/domain/overview', options = options )

		nic_type.actions[ 0 ].options = ids

		if command == 'edit':
			btn_text = _( 'Save' )
			title = _( 'Edit network interface' )
		else:
			btn_text = _( 'Add' )
			title = _( 'Adding network interface' )
		nic_list.add_row([
			umcd.Button(_('Cancel'), actions=[umcd.Action(overview_cmd)]),
			umcd.Cell(umcd.Button(btn_text, actions=[umcd.Action(cmd, ids), umcd.Action(overview_cmd)], default=True), attributes={'align': 'right'})
			])

		response.dialog[ 0 ].set_dialog( umcd.Section( title, nic_list, attributes = { 'width' : '100%' } ) )
Example #7
0
    def _web_cups_quota_user_show(self, object, res):
        lst = umcd.List()

        quota = res.dialog
        if quota['user']:
            headline = _(
                "Modify print quota setting for user '%(user)s' on printer %(printer)s"
            ) % quota
        else:
            headline = _(
                "Add print quota entry on printer %(printer)s") % quota

        # user and partition
        if not quota['user']:
            user = umcd.make(self['cups/quota/user/set']['user'])
        else:
            if type(quota['user']) == type([]):
                user = umcd.make_readonly(self['cups/quota/user/set']['user'],
                                          default=','.join(quota['user']))
            else:
                user = umcd.make_readonly(self['cups/quota/user/set']['user'],
                                          default=quota['user'])
        items = [user.id()]

        if not quota['printer']:
            printer = umcd.make(self['cups/quota/user/set']['printer'])
        else:
            printer = umcd.make_readonly(
                self['cups/quota/user/set']['printer'],
                default=quota['printer'])
        items += [printer.id()]
        lst.add_row([user, printer])

        soft = umcd.make(self['cups/quota/user/set']['softlimit'],
                         default=quota['softlimit'])
        hard = umcd.make(self['cups/quota/user/set']['hardlimit'],
                         default=quota['hardlimit'])
        items += [soft.id(), hard.id()]
        lst.add_row([soft, hard])

        opts = {
            'softlimit': quota['softlimit'],
            'hardlimit': quota['hardlimit']
        }
        if quota['printer']:
            opts['printer'] = quota['printer']
        if quota['user']:
            opts['user'] = quota['user']

        req = umcp.Command(args=['cups/quota/user/set'], opts=opts)
        if quota['printer']:
            req_show = umcp.Command(args=['cups/quota/user/show'],
                                    opts={'printer': quota['printer']})
            items_show = []
        else:
            req_show = umcp.Command(args=['cups/quota/user/show'])
            items_show = [
                printer.id(),
            ]

        actions = (umcd.Action(req, items), umcd.Action(req_show, items_show))
        button = umcd.SetButton(actions)
        cancel = umcd.CancelButton(attributes={'align': 'right'})
        lst.add_row([button, cancel])

        res.dialog = umcd.Frame([lst], headline)
        self.revamped(object.id(), res)
Example #8
0
                    conf.add_row([
                        umcd.HTML('<i>%s</i>' % _('Image format')), driver_type
                    ])
                    conf.add_row(
                        [umcd.HTML('<i>%s</i>' % _('Image size')), size])

                    break
            else:
                conf.add_row([
                    umcd.HTML('<i>%s</i>' % _('Device filename')), drive.source
                ])

            # editable options
            pv_default = drive.target_bus in ('xen', 'virtio')
            paravirtual = umcd.make(
                ('drive-paravirtual', umc.Boolean(_('Paravirtual drive'))),
                default=pv_default)
            conf.add_row([umcd.Cell(paravirtual, attributes={'colspan': '2'})])

            opts = copy.copy(object.options)
            opts['drive-paravirtual-old'] = pv_default
            save = umcp.SimpleCommand('uvmm/drive/edit', options=opts)
            overview = umcp.SimpleCommand('uvmm/domain/overview',
                                          options=copy.copy(object.options))

            btn_save = umcd.Button(_('Save'),
                                   actions=[
                                       umcd.Action(save, [paravirtual.id()]),
                                       umcd.Action(overview)
                                   ],
                                   default=True)
Example #9
0
					conf.add_row([umcd.HTML('<i>%s</i>' % _('Storage pool')), pool_name])
					if len(basename) > 60:
						conf.add_row([umcd.HTML('<i>%s</i>' % _('Image filename')), umcd.HTML('<p title="%s">%s...</p>' %(xml_escape(basename), xml_escape(basename[0:60])))])
					else:
						conf.add_row([umcd.HTML('<i>%s</i>' % _('Image filename')), basename])
					conf.add_row([umcd.HTML('<i>%s</i>' % _('Image format')), driver_type])
					conf.add_row([umcd.HTML('<i>%s</i>' % _('Image size')), size])

					break
			else:
				conf.add_row( [ umcd.HTML( '<i>%s</i>' % _( 'Device filename' ) ), drive.source ] )

			# editable options
			pv_default = drive.target_bus in ( 'xen', 'virtio' )
			paravirtual = umcd.make( ( 'drive-paravirtual', umc.Boolean( _( 'Paravirtual drive' ) ) ), default = pv_default )
			conf.add_row( [ umcd.Cell( paravirtual, attributes = { 'colspan' : '2' } ) ] )

			opts = copy.copy( object.options )
			opts[ 'drive-paravirtual-old' ] = pv_default
			save = umcp.SimpleCommand( 'uvmm/drive/edit', options = opts )
			overview = umcp.SimpleCommand( 'uvmm/domain/overview', options = copy.copy( object.options ) )

			btn_save = umcd.Button( _( 'Save' ), actions = [ umcd.Action( save, [ paravirtual.id() ] ), umcd.Action( overview ) ], default = True )
			btn_cancel = umcd.Button( _( 'Cancel' ), actions = [ umcd.Action( overview ) ] )
			conf.add_row( [ umcd.Fill( 2, '' ) ] )
			conf.add_row( [ btn_cancel, '', umcd.Cell( btn_save, attributes = { 'align' : 'right' } ) ] )

			res.dialog[ 0 ].set_dialog( umcd.Section( _( 'Edit drive' ), conf, hideable = False ) )
			self.finished(object.id(), res)
			return