mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-31 11:22:27 +00:00 
			
		
		
		
	fix rspconfig issues API related
This commit is contained in:
		| @@ -375,11 +375,12 @@ rmdir \"/tmp/$userid\" \n") | ||||
|         node = kw['node'] | ||||
|         obmc = openbmc.OpenBMCRest(name=node, nodeinfo=kw['nodeinfo'], messager=self.callback, | ||||
|                                    debugmode=self.debugmode, verbose=self.verbose) | ||||
|  | ||||
|         try: | ||||
|             obmc.login() | ||||
|             obmc.set_apis_values(key, value) | ||||
|         except (SelfServerException, SelfClientException) as e: | ||||
|             self.callback.error(e.message, node) | ||||
|             return self.callback.error(e.message, node) | ||||
|  | ||||
|         self.callback.info("%s: BMC Setting %s..." % (node, openbmc.RSPCONFIG_APIS[key]['display_name'])) | ||||
|  | ||||
| @@ -392,9 +393,12 @@ rmdir \"/tmp/$userid\" \n") | ||||
|             value = obmc.get_apis_values(key) | ||||
|  | ||||
|         except (SelfServerException, SelfClientException) as e: | ||||
|             self.callback.error(e.message, node) | ||||
|             return self.callback.error(e.message, node) | ||||
|  | ||||
|         str_value = '0.'+str(value) | ||||
|         if isinstance(value, dict): | ||||
|             str_value = value.values()[0] | ||||
|         else: | ||||
|             str_value = value  | ||||
|         result = '%s: %s: %s' % (node, openbmc.RSPCONFIG_APIS[key]['display_name'], str_value.split('.')[-1]) | ||||
|         self.callback.info(result) | ||||
|  | ||||
|   | ||||
| @@ -185,13 +185,17 @@ RSPCONFIG_APIS = { | ||||
|         'set_url': "attr/AutoReboot", | ||||
|         'get_url': "attr/AutoReboot", | ||||
|         'display_name': "BMC AutoReboot", | ||||
|         'attr_values': { | ||||
|             '0': False, | ||||
|             '1': True, | ||||
|          }, | ||||
|     }, | ||||
|     'powersupplyredundancy':{ | ||||
|         'baseurl': "/sensors/chassis/PowerSupplyRedundancy/", | ||||
|         'set_url': "/action/setValue", | ||||
|         'get_url': "/action/getValue", | ||||
|         'set_url': "action/setValue", | ||||
|         'get_url': "action/getValue", | ||||
|         'get_method': 'POST', | ||||
|         'get_data': '[]', | ||||
|         'get_data': [], | ||||
|         'display_name': "BMC PowerSupplyRedundancy", | ||||
|         'attr_values': { | ||||
|             'disabled': "Disables", | ||||
| @@ -220,6 +224,16 @@ RSPCONFIG_APIS = { | ||||
|             'setup': "xyz.openbmc_project.Control.Boot.Mode.Modes.Setup", | ||||
|         }, | ||||
|     }, | ||||
|     'timesyncmethod': { | ||||
|         'baseurl': '/time/sync_method', | ||||
|         'get_url': '', | ||||
|         'set_url': '/attr/TimeSyncMethod', | ||||
|         'display_name': 'BMC TimeSyncMethod', | ||||
|         'attr_values': { | ||||
|             'ntp': 'xyz.openbmc_project.Time.Synchronization.Method.NTP', | ||||
|             'manual': 'xyz.openbmc_project.Time.Synchronization.Method.Manual', | ||||
|         }, | ||||
|     }, | ||||
| } | ||||
|  | ||||
| EVENTLOG_URL      = "/logging/enumerate" | ||||
|   | ||||
| @@ -82,7 +82,7 @@ RFLASH_URLS = { | ||||
|     } | ||||
| } | ||||
|  | ||||
| RSPCONFIG_GET_OPTIONS = ['ip','ipsrc','netmask','gateway','vlan','ntpservers','hostname','bootmode','autoreboot','powersupplyredundancy','powerrestorepolicy'] | ||||
| RSPCONFIG_GET_OPTIONS = ['ip','ipsrc','netmask','gateway','vlan','ntpservers','hostname','bootmode','autoreboot','powersupplyredundancy','powerrestorepolicy', 'timesyncmethod'] | ||||
| RSPCONFIG_SET_OPTIONS = { | ||||
|     'ip':'.*', | ||||
|     'netmask':'.*', | ||||
| @@ -95,6 +95,7 @@ RSPCONFIG_SET_OPTIONS = { | ||||
|     'powerrestorepolicy':"^always_on$|^always_off$|^restore$", | ||||
|     'bootmode':"^regular$|^safe$|^setup$", | ||||
|     'admin_passwd':'.*,.*', | ||||
|     'timesyncmethod':'^ntp$|^manual$', | ||||
| } | ||||
| RSPCONFIG_USAGE = """ | ||||
| Handle rspconfig operations. | ||||
| @@ -124,6 +125,7 @@ The supported attributes and its values to set are: | ||||
|    autoreboot={0|1} | ||||
|    powersupplyredundancy={enabled|disabled} | ||||
|    powerrestorepolicy={always_on|always_off|restore} | ||||
|    timesyncmethod={ntp|manual} | ||||
| """ % RSPCONFIG_GET_OPTIONS | ||||
|  | ||||
| XCAT_LOG_DIR = "/var/log/xcat" | ||||
|   | ||||
| @@ -1643,7 +1643,13 @@ sub parse_command_status { | ||||
|                     # Everything else is invalid | ||||
|                         xCAT::SvrUtils::sendmsg([1, "Invalid value '$subcommand_value' for '$subcommand_key'"], $callback); | ||||
|                         my @valid_values = keys %{ $api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{attr_value} }; | ||||
|                         xCAT::SvrUtils::sendmsg([1, "Valid values: " . join(",", @valid_values)], $callback); | ||||
|                         if (!@valid_values) { | ||||
|                             if ($api_config_info{$::RSPCONFIG_CONFIGURED_API_KEY}{type} eq "boolean") { | ||||
|                                 xCAT::SvrUtils::sendmsg([1, "Valid values: 0,1"], $callback); | ||||
|                             } | ||||
|                         } else { | ||||
|                             xCAT::SvrUtils::sendmsg([1, "Valid values: " . join(",", @valid_values)], $callback); | ||||
|                         } | ||||
|                         return 1; | ||||
|                 } | ||||
|             } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user