From 48fab47e09db138e1820edd5a34f2cecadaa8d19 Mon Sep 17 00:00:00 2001 From: Ajith Antony Date: Fri, 4 Oct 2013 11:49:53 -0500 Subject: [PATCH] Delete the Nic classes from my previous implemntation Not sure what I did, but when I was squashing, I accidently this in. --- salt/modules/virt.py | 92 -------------------------------------------- 1 file changed, 92 deletions(-) diff --git a/salt/modules/virt.py b/salt/modules/virt.py index c1054adeeb..80c54006a1 100644 --- a/salt/modules/virt.py +++ b/salt/modules/virt.py @@ -450,98 +450,6 @@ def _get_image_info(hypervisor, name, **kwargs): ret['pool'] = __salt__['config.option']('virt.images') return ret - -class _Interface(object): - def __init__(self, - name=None, - source=None, - type=None, # pylint: disable=redefined-builtin - model='virtio', - mac=None, - **kwargs): - if not (source and type): - raise Exception('Need a source and type for _Interface, ' - 'got: \'{0}\' and \'{1}\' respectively' - .format(source, type)) - self.name = name - self.model = model - self.source = source - self.type = type - - if mac is not None: - self.mac = mac - else: - self.mac = salt.utils.gen_mac() - - def __str__(self): - return ('Name: {0}, Type: {1}, Source: {2}, ' - 'Model: {3}, MAC: {4}' - .format(self.name, self.type, self.source, self.model, self.mac)) - - def __repr__(self): - return '{0} ({1})'.format(self.__class__, self.__str__()) - - -class _NicProfile(object): - default = {'eth0': {'bridge': 'br0', 'model': 'virtio'}} - - def __init__(self, name): - self.interfaces = [] - self.name = name - - config_data = __salt__['config.option']('virt.nic', {}).get( - name, self.__class__.default - ) - - # support old style dicts - if isinstance(config_data, dict): - for interface_name, attributes in config_data.items(): - attributes['name'] = interface_name - self.interfaces.append(attributes) - - # new style lists - elif isinstance(config_data, list): - self.interfaces = config_data - - for interface in self.interfaces: - self._normalize_net_types(interface) - - def _normalize_net_types(self, attributes): - ''' - Guess which style of definition: - - bridge: br0 - - network: net0 - - type: network - source: net0 - ''' - for type_ in ['bridge', 'network']: - if type_ in attributes: - attributes['type'] = type_ - # we want to discard the original key - attributes['source'] = attributes.pop(type_) - - attributes['type'] = attributes.get('type', None) - attributes['source'] = attributes.get('source', None) - - def __str__(self): - lines = [] - for interface in self.interfaces: - lines.append(interface.__str__()) - return '\n'.join(lines) - - def create_interfaces(self, **kwargs): - results = [] - for interface in self.interfaces: - dmac = '{0}_mac'.format(interface['name']) - if dmac in kwargs: - interface['mac'] = kwargs[dmac] - results.append(_Interface(**interface)) - return results - - def _disk_profile(profile, hypervisor, **kwargs): ''' Gather the disk profile from the config or apply the default based