Skip to content

Commit 5ee3ace

Browse files
committed
add more files
1 parent 2502888 commit 5ee3ace

File tree

3 files changed

+161
-2
lines changed

3 files changed

+161
-2
lines changed

scripts/vm/hypervisor/xenserver/xenserver84/patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# If [source path] starts with '~', then it is path relative to management server home directory.
2828
# If [source path] does not start with '/' or '~', then it is relative path to the location of the patch file.
2929
vmops=,0755,/etc/xapi.d/plugins
30-
vmopspremium=..,0755,/etc/xapi.d/plugins
30+
vmopspremium=,0755,/etc/xapi.d/plugins
3131
vmopsSnapshot=,0755,/etc/xapi.d/plugins
3232
xen-ovs-vif-flows.rules=..,0644,/etc/udev/rules.d
3333
ovs-vif-flows.py=,0755,/etc/xapi.d/plugins

scripts/vm/hypervisor/xenserver/xenserver84/vmopsSnapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/env python3
22
# Licensed to the Apache Software Foundation (ASF) under one
33
# or more contributor license agreements. See the NOTICE file
44
# distributed with this work for additional information
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
#!/usr/bin/env python3
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+
19+
# Version @VERSION@
20+
#
21+
# A plugin for executing script needed by vmops cloud
22+
23+
import os, sys, time
24+
import XenAPIPlugin
25+
if os.path.exists("/opt/xensource/sm"):
26+
sys.path.extend(["/opt/xensource/sm/", "/usr/local/sbin/", "/sbin/"])
27+
if os.path.exists("/usr/lib/xcp/sm"):
28+
sys.path.extend(["/usr/lib/xcp/sm/", "/usr/local/sbin/", "/sbin/"])
29+
import util
30+
import socket
31+
import cloudstack_pluginlib as lib
32+
import logging
33+
34+
lib.setup_logging("/var/log/cloud/cloud.log")
35+
36+
def echo(fn):
37+
def wrapped(*v, **k):
38+
name = fn.__name__
39+
logging.debug("#### CLOUD enter %s ####" % name )
40+
res = fn(*v, **k)
41+
logging.debug("#### CLOUD exit %s ####" % name )
42+
return res
43+
return wrapped
44+
45+
@echo
46+
def forceShutdownVM(session, args):
47+
domId = args['domId']
48+
try:
49+
cmd = ["/opt/xensource/debug/xenops", "destroy_domain", "-domid", domId]
50+
txt = util.pread2(cmd)
51+
except:
52+
txt = '10#failed'
53+
return txt
54+
55+
56+
@echo
57+
def create_privatetemplate_from_snapshot(session, args):
58+
templatePath = args['templatePath']
59+
snapshotPath = args['snapshotPath']
60+
tmpltLocalDir = args['tmpltLocalDir']
61+
try:
62+
cmd = ["bash", "/opt/cloud/bin/create_privatetemplate_from_snapshot.sh",snapshotPath, templatePath, tmpltLocalDir]
63+
txt = util.pread2(cmd)
64+
except:
65+
txt = '10#failed'
66+
return txt
67+
68+
@echo
69+
def upgrade_snapshot(session, args):
70+
templatePath = args['templatePath']
71+
snapshotPath = args['snapshotPath']
72+
try:
73+
cmd = ["bash", "/opt/cloud/bin/upgrate_snapshot.sh",snapshotPath, templatePath]
74+
txt = util.pread2(cmd)
75+
except:
76+
txt = '10#failed'
77+
return txt
78+
79+
@echo
80+
def copy_vhd_to_secondarystorage(session, args):
81+
mountpoint = args['mountpoint']
82+
vdiuuid = args['vdiuuid']
83+
sruuid = args['sruuid']
84+
try:
85+
cmd = ["bash", "/opt/cloud/bin/copy_vhd_to_secondarystorage.sh", mountpoint, vdiuuid, sruuid]
86+
txt = util.pread2(cmd)
87+
except:
88+
txt = '10#failed'
89+
return txt
90+
91+
@echo
92+
def copy_vhd_from_secondarystorage(session, args):
93+
mountpoint = args['mountpoint']
94+
sruuid = args['sruuid']
95+
namelabel = args['namelabel']
96+
try:
97+
cmd = ["bash", "/opt/cloud/bin/copy_vhd_from_secondarystorage.sh", mountpoint, sruuid, namelabel]
98+
txt = util.pread2(cmd)
99+
except:
100+
txt = '10#failed'
101+
return txt
102+
103+
@echo
104+
def remove_corrupt_vdi(session, args):
105+
vdifile = args['vdifile']
106+
try:
107+
cmd = ['rm', '-f', vdifile]
108+
txt = util.pread2(cmd)
109+
except:
110+
txt = '10#failed'
111+
return txt
112+
113+
@echo
114+
def setup_heartbeat_sr(session, args):
115+
host = args['host']
116+
sr = args['sr']
117+
try:
118+
cmd = ["bash", "/opt/cloud/bin/setup_heartbeat_sr.sh", host, sr]
119+
txt = util.pread2(cmd)
120+
except:
121+
txt = ''
122+
return txt
123+
124+
@echo
125+
def setup_heartbeat_file(session, args):
126+
host = args['host']
127+
sr = args['sr']
128+
add = args['add']
129+
try:
130+
cmd = ["bash", "/opt/cloud/bin/setup_heartbeat_file.sh", host, sr, add]
131+
txt = util.pread2(cmd)
132+
except:
133+
txt = ''
134+
return txt
135+
136+
137+
@echo
138+
def heartbeat(session, args):
139+
host = args['host']
140+
timeout = args['timeout']
141+
interval = args['interval']
142+
try:
143+
cmd = ["/bin/bash", "/opt/cloud/bin/launch_hb.sh", host, timeout, interval]
144+
txt = util.pread2(cmd)
145+
except:
146+
txt='fail'
147+
return txt
148+
149+
@echo
150+
def asmonitor(session, args):
151+
try:
152+
perfmod = __import__("perfmon")
153+
result = perfmod.get_vm_group_perfmon(args)
154+
return result
155+
except:
156+
return 'fail'
157+
158+
if __name__ == "__main__":
159+
XenAPIPlugin.dispatch({"forceShutdownVM":forceShutdownVM, "upgrade_snapshot":upgrade_snapshot, "create_privatetemplate_from_snapshot":create_privatetemplate_from_snapshot, "copy_vhd_to_secondarystorage":copy_vhd_to_secondarystorage, "copy_vhd_from_secondarystorage":copy_vhd_from_secondarystorage, "setup_heartbeat_sr":setup_heartbeat_sr, "setup_heartbeat_file":setup_heartbeat_file, "heartbeat": heartbeat, "asmonitor": asmonitor, "remove_corrupt_vdi": remove_corrupt_vdi})

0 commit comments

Comments
 (0)