Fixed custom fields loading

Change-Id: I3677da2f101cffcae46517ac41393e57284123b7
This commit is contained in:
aviau 2015-05-08 15:45:07 -04:00
parent 55e4cb9962
commit afd68d0c77
2 changed files with 10 additions and 8 deletions

View File

@ -11,7 +11,6 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import json
from surveilclient.common import surveil_manager
@ -28,10 +27,6 @@ class HostsManager(surveil_manager.SurveilManager):
def create(self, **kwargs):
"""Create a new host."""
if "custom_fields" in kwargs:
kwargs["custom_fields"] = json.loads(kwargs["custom_fields"])
resp, body = self.http_client.json_request(
HostsManager.base_url, 'POST',
body=kwargs
@ -50,9 +45,6 @@ class HostsManager(surveil_manager.SurveilManager):
"""Update a host."""
kwargs["host_name"] = host_name
if "custom_fields" in kwargs:
kwargs["custom_fields"] = json.loads(kwargs["custom_fields"])
resp, body = self.http_client.json_request(
HostsManager.base_url + '/' + host_name, 'PUT',
body=kwargs

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import json
from surveilclient.common import utils
from surveilclient.openstack.common import cliutils
@ -67,6 +69,10 @@ def do_config_host_update(sc, args):
'notification_period',
'use']
host = _dict_from_args(args, arg_names)
if "custom_fields" in host:
host["custom_fields"] = json.loads(host["custom_fields"])
sc.config.hosts.update(args.host_name, **host)
@ -93,6 +99,10 @@ def do_config_host_create(sc, args):
'notification_period',
'use']
host = _dict_from_args(args, arg_names)
if "custom_fields" in host:
host["custom_fields"] = json.loads(host["custom_fields"])
sc.config.hosts.create(**host)