13
13
"""
14
14
15
15
__author__ = 'VMware, Inc.'
16
- __copyright__ = 'Copyright 2019 VMware, Inc. All rights reserved.'
17
16
__vcenter_version__ = '6.7+'
18
17
19
- from datetime import datetime , date
20
- from samples .vsphere .common import (sample_cli , sample_util , vapiconnect )
18
+ from samples .vsphere .common import (sample_cli , sample_util )
21
19
from com .vmware .appliance_client import Health
22
20
from com .vmware .vapi .std_client import LocalizableMessage
23
21
from com .vmware .appliance_client import Notification
22
+ from vmware .vapi .vsphere .client import create_vsphere_client
23
+ from samples .vsphere .common .ssl_helper import get_unverified_session
24
24
25
25
26
26
class HealthMessages (object ):
@@ -35,9 +35,7 @@ class HealthMessages(object):
35
35
36
36
def __init__ (self ):
37
37
self .item = None
38
- self .stub_config = None
39
-
40
- def setup (self ):
38
+ self .client = None
41
39
parser = sample_cli .build_arg_parser ()
42
40
43
41
parser .add_argument (
@@ -48,20 +46,21 @@ def setup(self):
48
46
help = 'Specify the name of health item to view the messages' )
49
47
50
48
args = sample_util .process_cli_args (parser .parse_args ())
51
- self .item = args .item
49
+ if args .item :
50
+ self .item = args .item
51
+ self .cleardata = args .cleardata
52
52
53
53
# Connect to vAPI services
54
- self .stub_config = vapiconnect .connect (
55
- host = args .server ,
56
- user = args .username ,
57
- pwd = args .password ,
58
- skip_verification = args .skipverification )
59
-
60
- self .health_client = Health (self .stub_config )
54
+ session = get_unverified_session () if args .skipverification else None
55
+ self .client = create_vsphere_client (server = args .server ,
56
+ username = args .username ,
57
+ password = args .password ,
58
+ session = session )
59
+ self .health_client = Health (self .client ._stub_config )
61
60
62
61
def run (self ):
63
62
message_list = self .health_client .messages (self .item )
64
- print (" Health Alarams" )
63
+ print ("Health Alarams" )
65
64
print ("-------------------\n " )
66
65
if not message_list :
67
66
print ("No health alarms for : " + self .item )
@@ -76,7 +75,6 @@ def run(self):
76
75
77
76
def main ():
78
77
health_sample = HealthMessages ()
79
- health_sample .setup ()
80
78
health_sample .run ()
81
79
82
80
0 commit comments