def get_network_params_object(self): """ Get Element SW Network object :description: get Network object :return: NetworkConfig object :rtype: object(NetworkConfig object) """ try: bond_1g_network = NetworkConfig(method=self.method, address=self.ip_address_1g, netmask=self.subnet_1g, gateway=self.gateway_address_1g, mtu=self.mtu_1g, dns_nameservers=self.dns_nameservers, dns_search=self.dns_search_domains, bond_mode=self.bond_mode_1g, bond_lacp_rate=self.lacp_1g, virtual_network_tag=self.virtual_network_tag) bond_10g_network = NetworkConfig(method=self.method, address=self.ip_address_10g, netmask=self.subnet_10g, gateway=self.gateway_address_10g, mtu=self.mtu_10g, dns_nameservers=self.dns_nameservers, dns_search=self.dns_search_domains, bond_mode=self.bond_mode_10g, bond_lacp_rate=self.lacp_10g, virtual_network_tag=self.virtual_network_tag) network_object = Network(bond1_g=bond_1g_network, bond10_g=bond_10g_network) return network_object except Exception as e: self.module.fail_json(msg='Error with setting up network object for node 1G and 10G configuration : %s' % to_native(e), exception=to_native(e))
def set_network_config_object(self, network_params): ''' set SolidFire network config object ''' network_config = dict() if network_params is not None: for key in network_params: if network_params[key] is not None: network_config[key] = network_params[key] if network_config: return NetworkConfig(**network_config) return None
def get_network_params_object(self): """ Get Element SW Network object :description: get Network object :return: NetworkConfig object :rtype: object(NetworkConfig object) """ do_1g = any([ x is not None for x in (self.ip_address_1g, self.subnet_1g, self.gateway_address_1g, self.mtu_1g, self.bond_mode_1g, self.lacp_1g) ]) do_10g = any([ x is not None for x in (self.ip_address_10g, self.subnet_10g, self.gateway_address_10g, self.mtu_10g, self.bond_mode_10g, self.lacp_10g) ]) bond_1g_network = None bond_10g_network = None network_object = None if do_1g: # add default values if self.bond_mode_1g is None: self.bond_mode_1g = 'ActivePassive' if self.bond_mode_1g == 'LACP' and self.lacp_1g is None: self.lacp_1g = 'Slow' if self.mtu_1g is None: self.mtu_1g = '1500' # str and not int! bond_1g_network = NetworkConfig( method=self.method, address=self.ip_address_1g, netmask=self.subnet_1g, gateway=self.gateway_address_1g, mtu=self.mtu_1g, dns_nameservers=self.dns_nameservers, dns_search=self.dns_search_domains, bond_mode=self.bond_mode_1g, bond_lacp_rate=self.lacp_1g, virtual_network_tag=self.virtual_network_tag) if do_10g: # add default values if self.bond_mode_10g is None: self.bond_mode_10g = 'ActivePassive' if self.bond_mode_10g == 'LACP' and self.lacp_10g is None: self.lacp_10g = 'Slow' if self.mtu_10g is None: self.mtu_10g = '1500' # str and not int! bond_10g_network = NetworkConfig( method=self.method, address=self.ip_address_10g, netmask=self.subnet_10g, gateway=self.gateway_address_10g, mtu=self.mtu_10g, dns_nameservers=self.dns_nameservers, dns_search=self.dns_search_domains, bond_mode=self.bond_mode_10g, bond_lacp_rate=self.lacp_10g, virtual_network_tag=self.virtual_network_tag) if do_1g or do_10g: network_object = Network(bond1_g=bond_1g_network, bond10_g=bond_10g_network) return network_object