Skip to content

Commit d8e2f6b

Browse files
author
Anthony Xu
committed
Revert "Removed the hostvmstats.py file from the scripts and from all of patch files and from vmops"
This reverts commit eb19545.
1 parent a9f473e commit d8e2f6b

5 files changed

Lines changed: 66 additions & 1 deletion

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/python
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
# $Id: hostvmstats.py 10054 2010-06-29 22:09:31Z abhishek $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/vm/hypervisor/xenserver/hostvmstats.py $
19+
20+
import XenAPI
21+
import urllib
22+
import time
23+
import logging
24+
logging.basicConfig(filename='/tmp/xapilog',level=logging.DEBUG)
25+
26+
def get_stats(session, collect_host_stats, consolidation_function, interval, start_time):
27+
try:
28+
29+
if collect_host_stats == "true" :
30+
url = "http://localhost/rrd_updates?"
31+
url += "session_id=" + session._session
32+
url += "&host=" + collect_host_stats
33+
url += "&cf=" + consolidation_function
34+
url += "&interval=" + str(interval)
35+
url += "&start=" + str(int(time.time())-100)
36+
else :
37+
url = "http://localhost/rrd_updates?"
38+
url += "session_id=" + session._session
39+
url += "&host=" + collect_host_stats
40+
url += "&cf=" + consolidation_function
41+
url += "&interval=" + str(interval)
42+
url += "&start=" + str(int(time.time())-100)
43+
44+
logging.debug("Calling URL: %s",url)
45+
sock = urllib.URLopener().open(url)
46+
xml = sock.read()
47+
sock.close()
48+
logging.debug("Size of returned XML: %s",len(xml))
49+
return xml
50+
except Exception,e:
51+
logging.exception("get_stats() failed")
52+
raise

‎scripts/vm/hypervisor/xenserver/vmops‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import os, sys, time
2424
import XenAPIPlugin
2525
sys.path.extend(["/opt/xensource/sm/", "/usr/local/sbin/", "/sbin/"])
2626
import base64
27+
import hostvmstats
2728
import socket
2829
import stat
2930
import tempfile
@@ -53,6 +54,15 @@ def add_to_VCPUs_params_live(session, args):
5354
return 'false'
5455
return 'true'
5556

57+
@echo
58+
def gethostvmstats(session, args):
59+
collect_host_stats = args['collectHostStats']
60+
consolidation_function = args['consolidationFunction']
61+
interval = args['interval']
62+
start_time = args['startTime']
63+
result = hostvmstats.get_stats(session, collect_host_stats, consolidation_function, interval, start_time)
64+
return result
65+
5666
@echo
5767
def setup_iscsi(session, args):
5868
uuid=args['uuid']
@@ -1619,7 +1629,7 @@ def bumpUpPriority(session, args):
16191629

16201630

16211631
if __name__ == "__main__":
1622-
XenAPIPlugin.dispatch({"pingtest": pingtest, "setup_iscsi":setup_iscsi,
1632+
XenAPIPlugin.dispatch({"pingtest": pingtest, "setup_iscsi":setup_iscsi, "gethostvmstats": gethostvmstats,
16231633
"getgateway": getgateway, "preparemigration": preparemigration,
16241634
"setIptables": setIptables, "pingdomr": pingdomr, "pingxenserver": pingxenserver,
16251635
"savePassword": savePassword,

‎scripts/vm/hypervisor/xenserver/xenserver56/patch‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
NFSSR.py=/opt/xensource/sm
3030
vmops=..,0755,/etc/xapi.d/plugins
3131
vmopsSnapshot=..,0755,/etc/xapi.d/plugins
32+
hostvmstats.py=..,0755,/opt/xensource/sm
3233
systemvm.iso=../../../../../vms,0644,/opt/xensource/packages/iso
3334
id_rsa.cloud=../../../systemvm,0600,/root/.ssh
3435
network_info.sh=..,0755,/opt/xensource/bin

‎scripts/vm/hypervisor/xenserver/xenserver56fp1/patch‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
NFSSR.py=/opt/xensource/sm
3030
vmops=..,0755,/etc/xapi.d/plugins
3131
vmopsSnapshot=..,0755,/etc/xapi.d/plugins
32+
hostvmstats.py=..,0755,/opt/xensource/sm
3233
systemvm.iso=../../../../../vms,0644,/opt/xensource/packages/iso
3334
id_rsa.cloud=../../../systemvm,0600,/root/.ssh
3435
network_info.sh=..,0755,/opt/xensource/bin

‎scripts/vm/hypervisor/xenserver/xenserver60/patch‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ cloudstack_plugins.conf=..,0644,/etc/xensource
3434
cloudstack_pluginlib.py=..,0755,/etc/xapi.d/plugins
3535
ovstunnel=..,0755,/etc/xapi.d/plugins
3636
vmopsSnapshot=..,0755,/etc/xapi.d/plugins
37+
hostvmstats.py=..,0755,/opt/xensource/sm
3738
systemvm.iso=../../../../../vms,0644,/opt/xensource/packages/iso
3839
id_rsa.cloud=../../../systemvm,0600,/root/.ssh
3940
network_info.sh=..,0755,/opt/xensource/bin

0 commit comments

Comments
 (0)