Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,26 @@ repos:
- id: identity
- id: check-hooks-apply
- repo: https://github.com/thlorenz/doctoc.git
rev: v2.3.0
rev: facaad890e72966c88a6a5592f5b6a01c422deb2 # frozen: v2.5.0
Comment thread
jbampton marked this conversation as resolved.
hooks:
- id: doctoc
name: Add TOC for Markdown files
files: ^CONTRIBUTING\.md$|^INSTALL\.md$|^README\.md$
- repo: https://github.com/oxipng/oxipng
rev: v10.1.0
rev: 340cd9878d8d8289f09fa101b48a8f5f0b7783f4 # frozen: v10.2.0
hooks:
- id: oxipng
name: run oxipng
description: optimize PNG images with lossless compression
args: ['-o', '4', '--strip', 'safe', '--alpha']
- repo: https://github.com/gitleaks/gitleaks
rev: v8.30.0
rev: 2ca41cc1372d1e939a6a879f18cdc19fc1cac1ce # frozen: v8.30.0
hooks:
- id: gitleaks
name: run gitleaks
description: detect hardcoded secrets
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.6
rev: ad1b27d73581aa16cca06fc4a0761fc563ffe8e8 # frozen: v1.5.6
hooks:
- id: chmod
name: set file permissions
Expand Down Expand Up @@ -122,7 +122,7 @@ repos:
- --fuzzy-match-generates-todo
exclude: ^\.github/workflows/.*\.lock\.yml$
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
hooks:
#- id: check-added-large-files
- id: check-case-conflict
Expand Down Expand Up @@ -166,18 +166,18 @@ repos:
args: [--markdown-linebreak-ext=md]
exclude: ^services/console-proxy/rdpconsole/src/test/doc/freerdp-debug-log\.txt$
- repo: https://github.com/codespell-project/codespell
rev: v2.4.2
rev: 57b21406f092110c18776e39b0bda50d37c945c8 # frozen: v2.4.3
hooks:
- id: codespell
name: run codespell
description: Check spelling with codespell
- repo: https://github.com/pycqa/flake8
rev: 7.3.0
rev: d93590f5be797aabb60e3b09f2f52dddb02f349f # frozen: 7.3.0
hooks:
- id: flake8
args: [--config, .github/linters/.flake8]
- id: flake8
args: [--config, .github/linters/.flake8]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.48.0
rev: 5b5dddc4fb0f83c3ea1fc5616fa63e115dce83e0 # frozen: v0.49.1
hooks:
- id: markdownlint
name: run markdownlint
Expand All @@ -186,7 +186,7 @@ repos:
types: [markdown]
files: \.md$
- repo: https://github.com/adrienverge/yamllint
rev: v1.38.0
rev: cba56bcde1fdd01c1deb3f945e69764c291a6530 # frozen: v1.38.0
hooks:
- id: yamllint
name: run yamllint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def _isClusterOnline(self, cluster):
cmds = ['service o2cb status', cluster]
res = doCmd(cmds)
for line in res.split('\n'):
if not 'Checking O2CB cluster' in line: continue
return not 'Offline' in line
if 'Checking O2CB cluster' not in line: continue
return 'Offline' not in line

def _load(self):
cmd = ['service o2cb load']
Expand Down
2 changes: 1 addition & 1 deletion scripts/vm/hypervisor/xenserver/cloudstack_pluginlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def create_tunnel(bridge, remote_ip, gre_key, src_host, dst_host, network_uuid):
key_validation = do_cmd(verify_interface_key)
ip_validation = do_cmd(verify_interface_ip)

if not gre_key in key_validation or not remote_ip in ip_validation:
if gre_key not in key_validation or remote_ip not in ip_validation:
logging.debug("WARNING: Unexpected output while verifying " +
"interface %s on bridge %s" % (name, bridge))
return "FAILURE:VERIFY_INTERFACE_FAILED"
Expand Down
12 changes: 6 additions & 6 deletions scripts/vm/hypervisor/xenserver/vmops
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ def cleanup_rules(session, args):

chainscmd = "iptables-save | grep '^:' | awk '{print $1}' | cut -d':' -f2 | sed 's/-def//'| sed 's/-eg//' | sort|uniq"
chains = util.pread2(['/bin/bash', '-c', chainscmd]).split('\n')
vmchains = [ch for ch in chains if 1 in [ ch.startswith(c) for c in ['r-', 'i-', 's-', 'v-', 'l-']]]
vmchains = [ch for ch in chains if 1 in [ ch.startswith(c) for c in ['r-', 'i-', 's-', 'v-', 'l-']]]
util.SMlog('cleanup_rules: vmchains= %s' %vmchains)
util.SMlog('cleanup_rules: found %s iptables chains for vms on this host %s' % (len(vmchains), hostname[0]))
cleaned = 0
Expand All @@ -1192,14 +1192,14 @@ def cleanup_rules(session, args):
#after trimming the vm names which more than 29 chars, resident vm name and iptables chain name is substring of
#of resident vm.
for rvm in resident_vms:
if vmname in rvm:
if vmname in rvm:
vmpresent = True
break

if vmpresent is False:
vmname = chain + "-untagged"
for rvm in resident_vms:
if vmname in rvm:
if vmname in rvm:
vmpresent = True
break
#vm chain is present but vm is not running on the host. So remove the rules
Expand Down Expand Up @@ -1491,11 +1491,11 @@ def network_rules(session, args):
egressrules = 0
for line in lines:
logging.debug("Processing rule [%s]." % line)

#Example of rule: [I:tcp;12;34;1.2.3.4/24,NEXT] -> tokens: ['I:tcp', '12', '34', '1.2.3.4/24,NEXT'].
tokens = line.split(';')
logging.debug("Tokens %s." % tokens)

tokens_size = len(tokens)

expected_tokens_size = 4
Expand Down Expand Up @@ -1530,7 +1530,7 @@ def network_rules(session, args):
i = cidrs.index('0.0.0.0/0')
del cidrs[i]
allow_any = True

port_range = start + ":" + end
logging.debug("port range [%s]" % port_range)

Expand Down
61 changes: 30 additions & 31 deletions scripts/vm/hypervisor/xenserver/vmopsSnapshot
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand All @@ -18,7 +18,7 @@

# Version @VERSION@
#
# A plugin for executing script needed by vmops cloud
# A plugin for executing script needed by vmops cloud

import os, sys, time
import XenAPIPlugin
Expand Down Expand Up @@ -91,7 +91,7 @@ def create_secondary_storage_folder(session, args):
umount(local_mount_path)
# Remove the local folder
os.system("rmdir " + local_mount_path)

return "1"

@echo
Expand Down Expand Up @@ -127,15 +127,15 @@ def delete_secondary_storage_folder(session, args):
umount(local_mount_path)
# Remove the local folder
os.system("rmdir " + local_mount_path)

return "1"

@echo
def post_create_private_template(session, args):
local_mount_path = None
try:
try:
# get local template folder
# get local template folder
templatePath = args["templatePath"]
local_mount_path = os.path.join(CLOUD_DIR, util.gen_uuid())
nfsVersion = args["nfsVersion"]
Expand All @@ -148,7 +148,7 @@ def post_create_private_template(session, args):
file_size = args["size"]
virtual_size = args["virtualSize"]
template_id = args["templateId"]

# Create the template.properties file
template_properties_install_path = local_mount_path + "/template.properties"
f = open(template_properties_install_path, "w")
Expand All @@ -167,7 +167,7 @@ def post_create_private_template(session, args):
f.write("size=" + str(file_size) + "\n")
f.close()
logging.debug("Created template.properties file")

# Set permissions
permissions = stat.S_IREAD | stat.S_IWRITE | stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH | stat.S_IWOTH
os.chmod(template_properties_install_path, permissions)
Expand All @@ -184,16 +184,16 @@ def post_create_private_template(session, args):
umount(local_mount_path)
# Remove the local folder
os.system("rmdir " + local_mount_path)
return "1"
return "1"

def isfile(path, isISCSI):
errMsg = ''
exists = True
if isISCSI:
exists = checkVolumeAvailability(path)
else:
exists = os.path.isfile(path)

if not exists:
errMsg = "File " + path + " does not exist."
logging.debug(errMsg)
Expand Down Expand Up @@ -241,7 +241,7 @@ def scanParent(path):
try:
lvName = os.path.basename(path)
dirname = os.path.dirname(path)
vgName = os.path.basename(dirname)
vgName = os.path.basename(dirname)
vhdInfo = vhdutil.getVHDInfoLVM(lvName, lvhdutil.extractUuid, vgName)
parentUUID = vhdInfo.parentUuid
except:
Expand Down Expand Up @@ -273,7 +273,7 @@ def getParentOfSnapshot(snapshotUuid, primarySRPath, isISCSI):
baseCopyUuid = scanParent(snapshotPath)
else:
baseCopyUuid = getParent(snapshotPath, isISCSI)

logging.debug("Base copy of snapshotUuid: " + snapshotUuid + " is " + baseCopyUuid)
return baseCopyUuid

Expand All @@ -282,7 +282,7 @@ def setParent(parent, child):
cmd = [VHDUTIL, "modify", "-p", parent, "-n", child]
txt = util.pread2(cmd)
except:
errMsg = "Unexpected error while trying to set parent of " + child + " to " + parent
errMsg = "Unexpected error while trying to set parent of " + child + " to " + parent
logging.debug(errMsg)
raise xs_errors.XenError(errMsg)
logging.debug("Successfully set parent of " + child + " to " + parent)
Expand Down Expand Up @@ -315,32 +315,32 @@ def mount(remoteDir, localDir, nfsVersion=None):
options = "soft,tcp,timeo=133,retrans=1"
if nfsVersion:
options += ",vers=" + nfsVersion
try:
try:
cmd = ['mount', '-o', options, remoteDir, localDir]
txt = util.pread2(cmd)
except:
txt = ''
errMsg = "Unexpected error while trying to mount " + remoteDir + " to " + localDir
errMsg = "Unexpected error while trying to mount " + remoteDir + " to " + localDir
logging.debug(errMsg)
raise xs_errors.XenError(errMsg)
logging.debug("Successfully mounted " + remoteDir + " to " + localDir)

return

def umount(localDir):
try:
try:
cmd = ['umount', localDir]
util.pread2(cmd)
except CommandException:
errMsg = "CommandException raised while trying to umount " + localDir
errMsg = "CommandException raised while trying to umount " + localDir
logging.debug(errMsg)
raise xs_errors.XenError(errMsg)

logging.debug("Successfully unmounted " + localDir)
return

def mountSnapshotsDir(secondaryStorageMountPath, localMountPointPath, path):
# The aim is to mount secondaryStorageMountPath on
# The aim is to mount secondaryStorageMountPath on
# And create <accountId>/<instanceId> dir on it, if it doesn't exist already.
# Assuming that secondaryStorageMountPath exists remotely

Expand Down Expand Up @@ -410,7 +410,7 @@ def getIsTrueString(stringValue):
booleanValue = False
if (stringValue and stringValue == 'true'):
booleanValue = True
return booleanValue
return booleanValue

def makeUnavailable(uuid, primarySRPath, isISCSI):
if not isISCSI:
Expand All @@ -433,7 +433,7 @@ def manageAvailability(path, value):
logging.debug(errMsg)
if value == "-ay":
# Raise an error only if we are trying to make it available.
# Just warn if we are trying to make it unavailable after the
# Just warn if we are trying to make it unavailable after the
# snapshot operation is done.
raise xs_errors.XenError(errMsg)
return
Expand All @@ -450,7 +450,7 @@ def checkVolumeAvailability(path):
errMsg = "Could not determine status of ISCSI path: " + path
logging.debug(errMsg)
raise xs_errors.XenError(errMsg)

success = False
i = 0
while i < 6:
Expand Down Expand Up @@ -482,20 +482,20 @@ def isVolumeAvailable(path):
logging.debug(errMsg)
raise xs_errors.XenError(errMsg)

return (status == "1")
return (status == "1")

def getVhdParent(session, args):
logging.debug("getParent with " + str(args))
primaryStorageSRUuid = args['primaryStorageSRUuid']
snapshotUuid = args['snapshotUuid']
isISCSI = getIsTrueString(args['isISCSI'])
isISCSI = getIsTrueString(args['isISCSI'])

primarySRPath = getPrimarySRPath(primaryStorageSRUuid, isISCSI)
logging.debug("primarySRPath: " + primarySRPath)

baseCopyUuid = getParentOfSnapshot(snapshotUuid, primarySRPath, isISCSI)

return baseCopyUuid
return baseCopyUuid

def getSnapshotSize(session, args):
primaryStorageSRUuid = args['primaryStorageSRUuid']
Expand Down Expand Up @@ -545,15 +545,15 @@ def backupSnapshot(session, args):
isfile(prevBackupFile, False)

# copy baseCopyPath to backupsDir with new uuid
backupVHD = getBackupVHD(backupUuid)
backupVHD = getBackupVHD(backupUuid)
backupFile = os.path.join(backupsDir, backupVHD)
logging.debug("Back up " + baseCopyUuid + " to Secondary Storage as " + backupUuid)
copyfile(baseCopyPath, backupFile, isISCSI)
vhdutil.setHidden(backupFile, False)

# Because the primary storage is always scanned, the parent of this base copy is always the first base copy.
# We don't want that, we want a chain of VHDs each of which is a delta from the previous.
# So set the parent of the current baseCopyVHD to prevBackupVHD
# So set the parent of the current baseCopyVHD to prevBackupVHD
if prevBackupUuid:
# If there was a previous snapshot
setParent(prevBackupFile, backupFile)
Expand Down Expand Up @@ -581,7 +581,7 @@ def deleteSnapshotBackup(session, args):
logging.debug("backupVHD " + backupVHD + "does not exist. Not trying to delete it")
return "1"
logging.debug("backupVHD " + backupVHD + " exists.")

# Just delete the backupVHD
try:
os.remove(backupVHD)
Expand All @@ -591,7 +591,7 @@ def deleteSnapshotBackup(session, args):
raise xs_errors.XenError(errMsg)

return "1"

@echo
def revert_memory_snapshot(session, args):
logging.debug("Calling revert_memory_snapshot with " + str(args))
Expand Down Expand Up @@ -620,4 +620,3 @@ def revert_memory_snapshot(session, args):

if __name__ == "__main__":
XenAPIPlugin.dispatch({"getVhdParent":getVhdParent, "create_secondary_storage_folder":create_secondary_storage_folder, "delete_secondary_storage_folder":delete_secondary_storage_folder, "post_create_private_template":post_create_private_template, "backupSnapshot": backupSnapshot, "deleteSnapshotBackup": deleteSnapshotBackup, "unmountSnapshotsDir": unmountSnapshotsDir, "revert_memory_snapshot":revert_memory_snapshot, "getSnapshotSize":getSnapshotSize})

Binary file modified systemvm/agent/images/left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified systemvm/agent/images/right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified systemvm/agent/images/right2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified systemvm/agent/images/winlog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading