MCPcopy Create free account
hub / github.com/apache/cloudstack / checkVolumeSize

Function checkVolumeSize

tools/marvin/marvin/lib/utils.py:537–573  ·  view source on GitHub ↗

@Name : getDiskUsage @Desc : provides facility to verify the volume size against the size to verify @Input: 1. ssh_handle : machine against which to execute the disk size cmd 2. volume_name : The name of the volume against which to verify the size 3. cmd_inp : In

(ssh_handle=None,
                    volume_name="/dev/sda",
                    cmd_inp="/sbin/fdisk -l | grep Disk",
                    size_to_verify=0)

Source from the content-addressed store, hash-verified

535 return [FAIL, MATCH_NOT_FOUND]
536
537def checkVolumeSize(ssh_handle=None,
538 volume_name="/dev/sda",
539 cmd_inp="/sbin/fdisk -l | grep Disk",
540 size_to_verify=0):
541 '''
542 @Name : getDiskUsage
543 @Desc : provides facility to verify the volume size against the size to verify
544 @Input: 1. ssh_handle : machine against which to execute the disk size cmd
545 2. volume_name : The name of the volume against which to verify the size
546 3. cmd_inp : Input command used to verify the size
547 4. size_to_verify: size against which to compare.
548 @Output: Returns FAILED in case of an issue, else SUCCESS
549 '''
550 try:
551 if ssh_handle is None or cmd_inp is None or volume_name is None:
552 return INVALID_INPUT
553
554 cmd = cmd_inp
555 '''
556 Retrieve the cmd output
557 '''
558 if system().lower() != "windows":
559 fdisk_output = ssh_handle.runCommand(cmd_inp)
560 if fdisk_output["status"] != SUCCESS:
561 return FAILED
562 for line in fdisk_output["stdout"]:
563 if volume_name in line:
564 # Get the bytes from the output
565 # Disk /dev/xvdb: 1 GiB, 1073741824 bytes, 2097152 sectors
566 m = re.match('.*?(\d+) bytes.*', line)
567 if m and str(m.group(1)) == str(size_to_verify):
568 return [SUCCESS,str(m.group(1))]
569 return [FAILED,"Volume Not Found"]
570 except Exception as e:
571 print("\n Exception Occurred under getDiskUsage: " \
572 "%s" %GetDetailExceptionInfo(e))
573 return [FAILED,GetDetailExceptionInfo(e)]
574
575
576def verifyRouterState(apiclient, routerid, allowedstates):

Calls 4

GetDetailExceptionInfoFunction · 0.90
runCommandMethod · 0.80
matchMethod · 0.45
groupMethod · 0.45