From 681174296d5c0f70ff8609e82e24921ec3edbbc1 Mon Sep 17 00:00:00 2001 From: Daniel Henrique Barboza Date: Thu, 14 Jul 2016 17:27:52 -0300 Subject: [PATCH] Fixing wok_log redundancy and i18n.py error messages This patch removes wok_log calls when they are just reproducing the same message of a call to a wok.exception (NotFoundError, OperationFailed ...) class. Wok exceptions already write the messages into the log and calling wok_log is redundant. Any other use of wok_log was preserved (logging a message that didn't appear to the user, for example). i18n.py messages were fixed along the way (wrong use of message strings, typos, etc). Files affected: model/nfsshares.py, model/nw_cfginterfaces_utils.py, model/ovsbridges.py, model/physical_vol.py Signed-off-by: Daniel Henrique Barboza --- i18n.py | 98 ++++++++++++++------------------- model/nfsshares.py | 6 +- model/nw_cfginterfaces_utils.py | 53 +----------------- model/ovsbridges.py | 31 +---------- model/physical_vol.py | 8 +-- 5 files changed, 49 insertions(+), 147 deletions(-) diff --git a/i18n.py b/i18n.py index 0825de38..2b41ab43 100644 --- a/i18n.py +++ b/i18n.py @@ -34,16 +34,11 @@ "GINNET0010E": _("Unable to delete default gateway: %(err)s"), "GINNET0011E": _("Unable to set default gateway: %(err)s"), "GINNET0014E": _("%(name)s is not valid network interface"), - "GINNET0015E": _("Error getting information from ifcfg file: " - "'%(error)s'."), - "GINNET0016E": _("Unable to activate the interface on '%(name)s', " - "'%(error)s'."), - "GINNET0017E": _("Unable to deactivate the interface on '%(name)s', " - "'%(error)s'."), - "GINNET0018E": _("Invalid ipv4 address '%(ip)s', " - "'%(error)s'."), - "GINNET0019E": _("Invalid prefix '%(PREFIX)s', " - "'%(error)s'."), + "GINNET0015E": _("Error getting information from ifcfg file: '%(error)s'."), + "GINNET0016E": _("Unable to activate the interface on '%(name)s', '%(error)s'."), + "GINNET0017E": _("Unable to deactivate the interface on '%(name)s', '%(error)s'."), + "GINNET0018E": _("Invalid ipv4 address '%(ip)s', '%(error)s'."), + "GINNET0019E": _("Invalid prefix '%(PREFIX)s', '%(error)s'."), "GINNET0020E": _("IP address is missing."), "GINNET0021E": _("PREFIX missing."), "GINNET0022E": _("Invalid boot protocol '%(mode)s', "), @@ -52,50 +47,41 @@ "GINNET0025E": _("Device name of interface is missing or invalid."), "GINNET0026E": _("Missing ipv4 initialization key."), "GINNET0027E": _("Missing ipv6 initialization key."), - "GINNET0028E": _("Invalid ipv6 address '%(ip)s', " - "'%(error)s'."), - "GINNET0029E": _("Missing ipv6 address information"), + "GINNET0028E": _("Invalid ipv6 address '%(ip)s', '%(error)s'."), + "GINNET0029E": _("Missing ipv6 address information."), "GINNET0030E": _("Exception getting route information: %(err)s"), - "GINNET0032E": _("Bond info is missing"), + "GINNET0032E": _("Bond info is missing."), "GINNET0033E": _("Allowed values for BONDING_MASTER are 'yes' or 'no'"), - "GINNET0034E": _("Bonding master is missing"), - "GINNET0036E": _("Slave(s) is missing"), - "GINNET0037E": _("Minimum one slave has to be given for the bond " - "interface"), - "GINNET0038E": _("Type is missing"), - "GINNET0040E": _("Invalid bonding option parameter"), - "GINNET0041E": _("'yes' or 'no' is allowed value for the VLAN"), - "GINNET0042E": _("Vlan info is missing"), - "GINNET0043E": _("Vlan is missing"), - "GINNET0044E": _("Vlan id is missing"), - "GINNET0045E": _("Physical device name is missing"), - "GINNET0046E": _("A VLAN slave cannot be configured on a bond with the " - "fail_over_mac=follow option"), - "GINNET0047E": _("For vlan creation over bond, slaves has to be up"), - "GINNET0048E": _("Module 802q is not loaded into kernel"), + "GINNET0034E": _("Bonding master is missing."), + "GINNET0036E": _("Slave(s) is missing."), + "GINNET0037E": _("Minimum one slave has to be given for the bond interface."), + "GINNET0038E": _("Type is missing."), + "GINNET0040E": _("Invalid bonding option parameter."), + "GINNET0041E": _("'yes' or 'no' are the allowed values for the VLAN."), + "GINNET0042E": _("Vlan info is missing."), + "GINNET0043E": _("Vlan is missing."), + "GINNET0044E": _("Vlan id is missing."), + "GINNET0045E": _("Physical device name is missing."), + "GINNET0046E": _("A VLAN slave cannot be configured on a bond with the fail_over_mac=follow option."), + "GINNET0047E": _("For vlan creation over bond, slaves has to be up."), + "GINNET0048E": _("Module 802q is not loaded into kernel."), "GINNET0049E": _("Failed to delete ifcfg file, Error: '%(error)s'"), - "GINNET0050E": _("VLAN id exceeds the ranges from '0' to '4095'"), - "GINNET0051E": _("Parent interface of type 'Bond' is not active"), - "GINNET0052E": _("Type is unknown"), - "GINNET0053E": _("Persistent file for slave '%(slave)s' is missing"), - "GINNET0055E": _("Interface '%(name)s' is neither Vlan nor " - "Bond to perform delete operation"), - "GINNET0056E": _("Failed to identify the type of interface"), - "GINNET0057E": _("Persistent file is not available for an interface, " - "'%(name)s'"), - "GINNET0058E": _("Failed to a delete token from ifcfg file, Error: " - "'%(error)s'"), - "GINNET0059E": _("Unable to bring up the interface '%(name)s', " - "'%(error)s'."), - "GINNET0060E": _("Unable to bring down the interface '%(name)s', " - "'%(error)s'."), - "GINNET0061E": _("Missing IPV4 addresses information"), - "GINNET0062E": _("The prefix value %(PREFIX)s is not in range 1-32"), - "GINNET0063E": _("Exception updating the interface settings"), + "GINNET0050E": _("VLAN id exceeds the ranges from '0' to '4095'."), + "GINNET0051E": _("Parent interface of type 'Bond' is not active."), + "GINNET0052E": _("Type is unknown."), + "GINNET0053E": _("Persistent file for slave '%(slave)s' is missing."), + "GINNET0055E": _("Interface '%(name)s' is neither Vlan nor Bond to perform delete operation."), + "GINNET0056E": _("Failed to identify the type of interface."), + "GINNET0057E": _("Persistent file is not available for an interface, '%(name)s'."), + "GINNET0058E": _("Failed to a delete token from ifcfg file, Error: '%(error)s'."), + "GINNET0059E": _("Unable to bring up the interface '%(name)s', '%(error)s'."), + "GINNET0060E": _("Unable to bring down the interface '%(name)s', '%(error)s'."), + "GINNET0061E": _("Missing IPV4 addresses information."), + "GINNET0062E": _("The prefix value %(PREFIX)s is not in range 1-32."), + "GINNET0063E": _("Exception updating the interface settings: %(err)s"), "GINNET0064E": _("Boot protocol is missing for ipv6 settings."), - "GINNET0065E": _("The prefix value %(PREFIX)s is not in range 1-128"), - "GINNET0066E": _("Given vlan id is not an integer type, Error: '%(" - "error)s'"), + "GINNET0065E": _("The prefix value %(PREFIX)s is not in range 1-128."), + "GINNET0066E": _("Given vlan id is not an integer type, Error: '%(error)s'."), "GINNET0067E": _("Maximum length of device name is 15 characters only."), "GINNET0068E": _("Device name is invalid."), "GINNET0070E": _("Gateway information is missing."), @@ -260,10 +246,10 @@ "GINLVM0002E": _("Error executing 'lvm version' command. %(err)s"), "GINLVM0003E": _("Incompatible output from 'lvm version' command. %(err)s"), - "GINPV00001E": _("Required pv_name parameter"), - "GINPV00002E": _("Failed to create PV"), - "GINPV00003E": _("Failed to fetch PV list"), - "GINPV00004E": _("Failed to fetch PV details"), + "GINPV00001E": _("Required pv_name parameter."), + "GINPV00002E": _("Failed to create PV %(name)s."), + "GINPV00003E": _("Failed to fetch PV list. Error: %(err)s"), + "GINPV00004E": _("Failed to fetch PV %(name)s details."), "GINPV00005E": _("Failed to delete PV, error: %(err)s"), "GINPV00006E": _("pvs command failed"), "GINPV00007E": _("Unable to get information of device %(dev)s, error: %(err)s"), @@ -353,8 +339,8 @@ "GINSERV00002E": _("Service name %(name)s not found."), "GINSTG00001E": _("Invalid URI, please use /stgserver/%(ipaddr)s/nfsshares"), "GINSTG00002E": _("Invalid URI, no list of storage servers available"), - "GINNFS00001E": _("Error fetching NFS shares"), - "GINNFS00002E": _("Invalid server or no NFS exports found on server"), + "GINNFS00001E": _("Error fetching NFS shares for server %(name)s."), + "GINNFS00002E": _("Invalid server or no NFS exports found on server."), # These messages (ending with L) are for user log purposes "GINDASD0001L": _("Formatted DASD device '%(ident)s' with block size %(blk_size)s"), diff --git a/model/nfsshares.py b/model/nfsshares.py index ecaa632b..2c7e8e79 100644 --- a/model/nfsshares.py +++ b/model/nfsshares.py @@ -19,7 +19,7 @@ import fs_utils from wok.exception import NotFoundError, OperationFailed -from wok.utils import patch_find_nfs_target, wok_log +from wok.utils import patch_find_nfs_target class NFSSharesModel(object): @@ -44,6 +44,4 @@ def get_list(self, model_args): return {'NFSShares': sharepoints} except ValueError: - wok_log.error("Error fetching NFS shares " - "for server %s" % name) - raise OperationFailed("GINNFS00001E") + raise OperationFailed("GINNFS00001E", {'name': name}) diff --git a/model/nw_cfginterfaces_utils.py b/model/nw_cfginterfaces_utils.py index ef1ffdb9..6bb39d83 100644 --- a/model/nw_cfginterfaces_utils.py +++ b/model/nw_cfginterfaces_utils.py @@ -303,23 +303,17 @@ def trim_quotes(self, param): def validate_device_name(self, device_name): if device_name == "": - wok_log.error("Device info is missing or invalid") raise MissingParameter("GINNET0025E") if len(device_name) > 15: - wok_log.error("Maximum length of device name is 15 characters " - "only") raise InvalidParameter("GINNET0067E") if ' ' in device_name: - wok_log.error("Invalid device id") raise InvalidParameter("GINNET0068E") def validate_minimal_info(self, params): cfg_map = {} if BASIC_INFO not in params: - wok_log.error("Basic info is missing") raise MissingParameter("GINNET0024E") if DEVICE not in params[BASIC_INFO]: - wok_log.error("Missing parameter: DEVICE") raise MissingParameter("GINNET0025E") else: self.validate_device_name(params[BASIC_INFO][DEVICE]) @@ -329,12 +323,9 @@ def validate_minimal_info(self, params): # ensure comparision are in same type. if decode_value(cfg_map[DEVICE]) in map(decode_value, self.get_interface_list()): - wok_log.error("Interface with the name %s already exists" - % params[BASIC_INFO][DEVICE]) raise InvalidParameter('GINNET0072E', {'iface': cfg_map[ DEVICE]}) if TYPE not in params[BASIC_INFO]: - wok_log.error("Type info is missing") raise MissingParameter("GINNET0038E") else: cfg_map[TYPE] = params[BASIC_INFO][TYPE] @@ -342,29 +333,22 @@ def validate_minimal_info(self, params): def validate_info_for_vlan(self, params): if VLANINFO not in params[BASIC_INFO]: - wok_log.error("Vlan info is missing") raise MissingParameter("GINNET0042E") if PHYSDEV not in params[BASIC_INFO][VLANINFO]: - wok_log.error("Phydev is missing") raise MissingParameter("GINNET0045E") def validate_vlan_driver(self): cmd = ['modprobe', '8021q'] out, error, returncode = run_command(cmd) if returncode != 0: - wok_log.error('Module 802q is not loaded into kernel') raise OperationFailed('GINNET0048E') - wok_log.info('Module 802q has already loaded into kernel') def validate_dict_bond_for_vlan(self, cfgdata): if BASIC_INFO not in cfgdata: - wok_log.error('Basic info is missing for the bond') raise MissingParameter("GINNET0024E") if BONDINFO not in cfgdata[BASIC_INFO]: - wok_log.error('Bond info is missing for the bond') raise MissingParameter("GINNET0032E") if SLAVES not in cfgdata[BASIC_INFO][BONDINFO]: - wok_log.error('Slave info is missing') raise MissingParameter("GINNET0036E") def validate_interface(self, name): @@ -404,7 +388,6 @@ def read_ifcfg_file(self, interface_name): raise OperationFailed('GINNET0015E', {'error': e.message}) finally: gingerNetworkLock.release() - wok_log.info('reading finished Key value :' + encode_value(cfgmap)) return cfgmap def get_master(self, cfgmap): @@ -466,7 +449,6 @@ def validate_ipv4_address(self, ip): return raise Exception("Not an ipv4 address") except Exception, e: - wok_log.error("Invalid ipv4 address:" + encode_value(e.message)) raise InvalidParameter('GINNET0018E', {'ip': ip, 'error': e.message}) @@ -521,7 +503,6 @@ def validate_ipv6_address(self, ip): return raise Exception("Not an ipv6 address") except Exception, e: - wok_log.error(("Invalid ipv6 address:" + encode_value(e.message))) raise InvalidParameter('GINNET0028E', {'ip': ip, 'error': e.message}) @@ -549,12 +530,10 @@ def validateipinfo(self, ipaddrinfo): raise InvalidParameter('GINNET0065E', { 'PREFIX': ipaddrinfo[PREFIX]}) except Exception, e: - wok_log.error(("Invalid prefix:" + encode_value(e.message))) raise InvalidParameter( 'GINNET0019E', {'PREFIX': ipaddrinfo[PREFIX], 'error': e.message}) else: - wok_log.error(("No netmask or prefix provided")) raise MissingParameter('GINNET0021E') return ipaddrinfo @@ -568,7 +547,6 @@ def get_ipv6_prefix(self, ip): ip = IPAddress(ip) return ip.netmask_bits() except Exception, e: - wok_log.error(("Invalid prefix:" + encode_value(e.message))) raise InvalidParameter('GINNET0019E', {'PREFIX': ip, 'error': e.message}) @@ -580,8 +558,7 @@ def get_ipv4_prefix(self, ip): return ip.netmask_bits() else: raise Exception('') - except Exception, e: - wok_log.error(("Invalid prefix:" + encode_value(e.message))) + except: raise InvalidParameter('GINNET0071E', {'PREFIX': ip}) def validate_populate_ipv4_routes(self, routes_input): @@ -591,7 +568,6 @@ def validate_populate_ipv4_routes(self, routes_input): if ADDRESS in routes: self.validate_ipv4_address(routes[ADDRESS]) else: - wok_log.error(("IPV4 address is missing for routes")) raise MissingParameter('GINNET0061E') if NETMASK in routes: match = re.match("^(\d{0,3})\.(\d{0,3})\.(\d{0,3})" @@ -606,12 +582,10 @@ def validate_populate_ipv4_routes(self, routes_input): raise InvalidParameter('GINNET0062E', { 'PREFIX': routes[NETMASK]}) else: - wok_log.error(("Netmask/Prefix is missing for routes")) raise MissingParameter('GINNET0021E') if GATEWAY in routes: self.validate_ipv4_address(routes[GATEWAY]) else: - wok_log.error(("Gateway address is missing for routes")) raise MissingParameter('GINNET0070E') modified_routes.append(route_info) return modified_routes @@ -622,7 +596,6 @@ def get_type_from_cfg(self, name): if TYPE in params and params[TYPE] is not None: return params[TYPE] else: - wok_log.error("Failed to identify the type of interface") raise OperationFailed("GINNET0056E") else: return "n/a" @@ -774,7 +747,6 @@ def validate_and_get_vlanid(self, params, vlan_info, device): vlanid_fromdevice = self.convert_to_int_ifvalid(device.split( DOT)[1]) elif VLAN_ID not in params[BASIC_INFO][VLANINFO]: - wok_log.error("Vlan id is missing") raise MissingParameter("GINNET0044E") if vlanid_fromdevice: if vlanid_fromdevice not in vlanid_range: @@ -782,7 +754,6 @@ def validate_and_get_vlanid(self, params, vlan_info, device): if VLAN_ID in params[BASIC_INFO][VLANINFO]: vlan_id = params[BASIC_INFO][VLANINFO][VLAN_ID] if int(vlan_id) not in vlanid_range: - wok_log.error("VLAN id exceeds the ranges from '0' to '4095'") raise InvalidParameter("GINNET0050E") vlan_info[VLAN_ID] = params[BASIC_INFO][VLANINFO][VLAN_ID] return vlan_info @@ -791,7 +762,6 @@ def convert_to_int_ifvalid(self, value): try: int_value = int(value) except ValueError, e: - wok_log.error("Given vlanid is not an integer type") raise InvalidParameter("GINNET0066E", {'error': e.message}) return int_value @@ -888,8 +858,6 @@ def validate_arp_ip_target(opt_value): for key in bond_opt_value: self.validate_ipv4_address(key) else: - wok_log.error("Up to 16 IP addresses can be given as " - "arp_ip_target") raise InvalidParameter("GINNET0040E") else: self.validate_ipv4_address(bond_opt_value) @@ -1012,7 +980,6 @@ def assign_ipv4_address(self, cfgmap, params): self.validate_ipv4_address(ipaddrinfo[IPADDR]) cfgmap[IPADDR + postfix] = ipaddrinfo[IPADDR] else: - wok_log.error(("No ip address provided")) raise MissingParameter('GINNET0020E') # Fix for issue 169 if PREFIX in ipaddrinfo: @@ -1039,7 +1006,6 @@ def assign_ipv4_address(self, cfgmap, params): 'GINNET0071E', {'PREFIX': ipaddrinfo[ PREFIX]}) else: - wok_log.error("No prefix provided for IPv4 addresses.") raise MissingParameter('GINNET0021E') if GATEWAY in ipaddrinfo: self.validate_ipv4_address(ipaddrinfo[GATEWAY]) @@ -1047,8 +1013,6 @@ def assign_ipv4_address(self, cfgmap, params): index += 1 # Fix for issue 169 else: - wok_log.error(("IPv4 adresses are mandatory \ - when bootproto is none.")) raise MissingParameter('GINNET0061E') return cfgmap @@ -1077,7 +1041,6 @@ def assign_ipv6_address(self, cfgmap, params): cfgmap[IPV6ADDR_SECONDARIES] = \ ipaddrinfo[IPADDR] + '/' + ipaddrinfo[PREFIX] else: - wok_log.error(("For manual mode ipv6 addresses is needed")) raise MissingParameter('GINNET0029E') return cfgmap @@ -1145,7 +1108,6 @@ def update_ipv6(self, cfgmap, params): 'no': cfgmap[IPV6INIT] = params[IPV6_ID][IPV6INIT] else: - wok_log.error("IPV6INIT value is mandatory") raise MissingParameter('GINNET0027E') return cfgmap @@ -1198,7 +1160,7 @@ def update_cfgfile(self, cfgmap, params): ' cfg information' + encode_value(e.message)) if os.path.isfile(backupfile): shutil.copy(backupfile, p_file) - raise OperationFailed("GINNET0063E", {'Error': e.message}) + raise OperationFailed("GINNET0063E", {'err': e.message}) finally: if os.path.isfile(backupfile): os.remove(backupfile) @@ -1211,7 +1173,6 @@ def delete_persist_file(self, ifcfg_file): try: os.remove(ifcfg_file) except OSError, e: - wok_log.error("Failed to delete persistent fail ", e.message) raise OperationFailed("GINNET0049E", {'error': e.message}) def remove_vlan_persistent(self, name): @@ -1251,12 +1212,9 @@ def update_ipv4_bootproto(self, cfgmap, params): # do auto ip stuff cfgmap[BOOTPROTO] = AUTOIP else: - wok_log.error(("Bootprotocol not supported:" + - params[BOOTPROTO])) raise AttributeError('GINNET0022E', {'mode': params[BOOTPROTO]}) else: - wok_log.error("Bootprotocol not provided:") raise MissingParameter('GINNET0023E') return cfgmap @@ -1300,7 +1258,6 @@ def update_ipv4(self, cfgmap, params): cfgmap = self.cleanup_ipv4attributes(cfgmap) wok_log.info("IPV4INIT value is set to no") else: - wok_log.error("IPV4INIT value is mandatory") raise MissingParameter('GINNET0026E') return cfgmap @@ -1308,28 +1265,22 @@ def validate_and_get_vlan_info(self, params, cfgmap): vlan_info = {} wok_log.info('Validating vlan info given for interface') if DEVICE not in cfgmap: - wok_log.error("Missing parameter: DEVICE") raise MissingParameter("GINNET0025E") self.validate_device_name(cfgmap[DEVICE]) device = cfgmap[DEVICE] if device.count(DOT) > 1: - wok_log.error("Invalid Vlan device name has given") raise MissingParameter("GINNET0068E") if VLANINFO not in params[BASIC_INFO]: - wok_log.error("Missing parameter: VLANINFO") raise MissingParameter("GINNET0042E") if VLAN in params[BASIC_INFO][VLANINFO]: if not params[BASIC_INFO][VLANINFO][VLAN] == "yes": - wok_log.error("'yes' or 'no' is allowed value for the VLAN") raise MissingParameter("GINNET0041E") else: vlan_info[VLAN] = params[BASIC_INFO][VLANINFO][VLAN] else: - wok_log.error("Missing parameter: VLAN") raise MissingParameter("GINNET0043E") vlan_info = self.validate_and_get_vlanid(params, vlan_info, device) if PHYSDEV not in params[BASIC_INFO][VLANINFO]: - wok_log.error("Missing parameter(s): PHYSDEV") raise MissingParameter("GINNET0045E") else: vlan_info[PHYSDEV] = params[BASIC_INFO][VLANINFO][PHYSDEV] diff --git a/model/ovsbridges.py b/model/ovsbridges.py index b1cceff4..acedca32 100644 --- a/model/ovsbridges.py +++ b/model/ovsbridges.py @@ -162,10 +162,6 @@ def run_ovsvsctl_command(cmd): out, err, returncode = run_command(cmd) if returncode != 0: if 'database connection failed' in err: - wok_log.info( - 'Database connection error when executing an ovs-vsctl ' - 'command. Is openvswitch service running?' - ) raise OperationFailed('GINOVS00001E') return out, err, returncode @@ -175,7 +171,6 @@ def ovsbridge_exists(ovsbridge): cmd = ['ovs-vsctl', 'br-exists', ovsbridge] out, err, returncode = run_ovsvsctl_command(cmd) if returncode not in [0, 2]: - wok_log.error('Error executing ovs-vsctl br-exists: %s ' % err) raise OperationFailed('GINOVS00002E', {'err': err}) else: return returncode == 0 @@ -185,7 +180,6 @@ def get_ovsbridges_list(): cmd = ['ovs-vsctl', 'list-br'] out, err, returncode = run_ovsvsctl_command(cmd) if returncode != 0: - wok_log.error('Error executing ovs-vsctl list-br: %s ' % err) raise OperationFailed('GINOVS00002E', {'err': err}) else: return parse_listbr_output(out) @@ -193,16 +187,11 @@ def get_ovsbridges_list(): def create_ovsbridge(ovsbridge): if ovsbridge_exists(ovsbridge): - wok_log.error( - 'Error creating ovsbridge %s. OVSbridge already ' - 'exists.' % ovsbridge - ) raise InvalidParameter('GINOVS00003E', {'name': ovsbridge}) cmd = ['ovs-vsctl', 'add-br', ovsbridge] out, err, returncode = run_ovsvsctl_command(cmd) if returncode != 0: - wok_log.error('Error executing ovs-vsctl add-br: %s ' % err) raise OperationFailed('GINOVS00002E', {'err': err}) @@ -210,7 +199,6 @@ def delete_ovsbridge(ovsbridge): cmd = ['ovs-vsctl', 'del-br', ovsbridge] out, err, returncode = run_ovsvsctl_command(cmd) if returncode != 0: - wok_log.error('Error executing ovs-vsctl del-br: %s ' % err) raise OperationFailed('GINOVS00002E', {'err': err}) @@ -218,7 +206,6 @@ def get_bridge_ports(ovsbridge): cmd = ['ovs-vsctl', 'list-ports', ovsbridge] out, err, returncode = run_ovsvsctl_command(cmd) if returncode != 0: - wok_log.error('Error executing ovs-vsctl list-ports: %s ' % err) raise OperationFailed('GINOVS00002E', {'err': err}) else: return parse_listports_output(out) @@ -228,7 +215,6 @@ def get_interface_info(uuid): cmd = ['ovs-vsctl', 'list', 'Interface', uuid] out, err, returncode = run_ovsvsctl_command(cmd) if returncode != 0: - wok_log.error('Error executing ovs-vsctl list Interface : %s ' % err) raise OperationFailed('GINOVS00002E', {'err': err}) else: info = parse_listinterface_output(out) @@ -240,7 +226,6 @@ def get_port_info(port): cmd = ['ovs-vsctl', 'list', 'Port', port] out, err, returncode = run_ovsvsctl_command(cmd) if returncode != 0: - wok_log.error('Error executing ovs-vsctl list Port : %s ' % err) raise OperationFailed('GINOVS00002E', {'err': err}) else: @@ -261,10 +246,6 @@ def get_port_info(port): def add_interface_to_ovsbridge(ovsbridge, interface): if not ovsbridge_exists(ovsbridge): - wok_log.error( - 'Error adding interface %s for ovsbridge %s. OVSbridge ' - 'does not exist.' % (interface, ovsbridge) - ) raise NotFoundError('GINOVS00004E', {'name': ovsbridge}) cmd = ['ovs-vsctl', 'add-port', ovsbridge, interface] @@ -286,17 +267,12 @@ def del_port_from_ovsbridge(ovsbridge, port): cmd = ['ovs-vsctl', 'del-port', ovsbridge, port] out, err, returncode = run_ovsvsctl_command(cmd) if returncode != 0: - wok_log.error('Error executing ovs-vsctl del-port: %s ' % err) raise OperationFailed('GINOVS00002E', {'err': err}) def add_bond_to_ovsbridge(ovsbridge, bond, bond_ifaces): if not ovsbridge_exists(ovsbridge): - wok_log.error( - 'Error creating bond %s for ovsbridge %s. OVSbridge does not ' - 'exist.' % (bond, ovsbridge) - ) - raise NotFoundError('GINOVS00003E', {'name': ovsbridge}) + raise NotFoundError('GINOVS00004E', {'name': ovsbridge}) if len(bond_ifaces) < 2: raise InvalidParameter('GINOVS00006E') @@ -304,7 +280,6 @@ def add_bond_to_ovsbridge(ovsbridge, bond, bond_ifaces): cmd = ['ovs-vsctl', 'add-bond', ovsbridge, bond] + bond_ifaces out, err, returncode = run_ovsvsctl_command(cmd) if returncode != 0: - wok_log.error('Error executing ovs-vsctl add-bond: %s ' % err) raise OperationFailed('GINOVS00002E', {'err': err}) @@ -377,10 +352,6 @@ class OVSBridgeModel(object): def lookup(self, name): if not ovsbridge_exists(name): - wok_log.error( - 'Error retrieving ovsbridge %s. OVSbridge does not ' - 'exist.' % name - ) raise NotFoundError('GINOVS00004E', {'name': name}) br_ports = get_bridge_ports(name) diff --git a/model/physical_vol.py b/model/physical_vol.py index 8a0eb93a..76f87799 100644 --- a/model/physical_vol.py +++ b/model/physical_vol.py @@ -23,7 +23,7 @@ from wok.exception import MissingParameter, NotFoundError from wok.exception import InvalidParameter, OperationFailed from wok.model.tasks import TaskModel -from wok.utils import add_task, wok_log +from wok.utils import add_task class PhysicalVolumesModel(object): @@ -63,9 +63,8 @@ def _create_task(self, cb, params): utils._create_pv(pvname) except OperationFailed: - wok_log.error("PV create failed") raise OperationFailed("GINPV00002E", - {'pvname': pvname}) + {'name': pvname}) cb('OK', True) @@ -74,7 +73,6 @@ def get_list(self): try: pv_names = utils._get_pv_devices() except OperationFailed as e: - wok_log.error("Unable to fetch list of PVs") raise NotFoundError("GINPV00003E", {'err': e.message}) @@ -94,12 +92,10 @@ def lookup(self, name): return utils._pvdisplay_out(name) except OperationFailed: - wok_log.error("Unable to fetch details of PV") raise NotFoundError("GINPV00004E", {'name': name}) def delete(self, name): try: utils._remove_pv(name) except OperationFailed as e: - wok_log.error("delete PV failed") raise InvalidParameter("GINPV00005E", {'err': e.message})