Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
K
kvm.kvm_tool
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Paul John King
kvm.kvm_tool
Commits
4aa5accf
Commit
4aa5accf
authored
Nov 25, 2016
by
Paul John King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Examine domain outputs shell assignments and verify domain uses them --
parent
9a10240d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
42 deletions
+23
-42
kvm_tool
kvm_tool
+23
-42
No files found.
kvm_tool
View file @
4aa5accf
...
...
@@ -182,9 +182,10 @@ print_domain_usage_message(){
${
0
##*/
}
examine domain <name>
outputs the CPU count, RAM, file-system image, bridge device and MAC address of
the KVM domain with name <name> and returns 0 if the domain exists, and returns
1 otherwise.
outputs the CPU count, the RAM, the RAM units, a path to the file-system image,
the bridge device and the MAC address of the KVM domain with name <name> as
Bourne-shell variable assignments (suitable for shell evaluation) and returns 0
if the domain exists, and returns 1 otherwise.
The command call
...
...
@@ -301,7 +302,9 @@ examine_domain(){
local
_interface_xml
;
local
_cpu_count
;
local
_ram
;
local
_ram_unit
;
local
_path
;
local
_bridge
;
local
_mac_address
;
if
_domain_xml
=
$(
virsh
-q
dumpxml
"
${
_NAME
}
"
2> /dev/null
)
;
...
...
@@ -315,16 +318,17 @@ examine_domain(){
_cpu_count
=
$(
_get_content_by_tag_from_xml
"
${
_domain_xml
}
"
"vcpu"
)
;
_ram
=
$(
_get_content_by_tag_from_xml
"
${
_domain_xml
}
"
"memory"
)
;
_ram_unit
s
=
$(
_get_value_by_tag_and_attribute_from_xml
"
${
_domain_xml
}
"
"memory"
"unit"
)
;
_ram_unit
=
$(
_get_value_by_tag_and_attribute_from_xml
"
${
_domain_xml
}
"
"memory"
"unit"
)
;
_path
=
$(
_get_value_by_tag_and_attribute_from_xml
"
${
_disk_vda_xml
}
"
"source"
"file"
)
;
_bridge
=
$(
_get_value_by_tag_and_attribute_from_xml
"
${
_interface_xml
}
"
"source"
"bridge"
)
;
_mac_address
=
$(
_get_value_by_tag_and_attribute_from_xml
"
${
_interface_xml
}
"
"mac"
"address"
)
;
echo
"CPU count:
${
_cpu_count
}
"
;
echo
"RAM:
${
_ram
}
${
_ram_units
}
"
;
echo
"Path:
${
_path
}
"
;
echo
"Bridge:
${
_bridge
}
"
;
echo
"MAC address:
${
_mac_address
}
"
;
echo
"DOMAIN_CPU_COUNT='
${
_cpu_count
}
'"
;
echo
"DOMAIN_RAM='
${
_ram
}
'"
;
echo
"DOMAIN_RAM_UNIT='
${
_ram_unit
}
'"
;
echo
"DOMAIN_PATH='
${
_path
}
'"
;
echo
"DOMAIN_BRIDGE='
${
_bridge
}
'"
;
echo
"DOMAIN_MAC_ADDRESS='
${
_mac_address
}
'"
;
return
0
;
else
...
...
@@ -364,44 +368,26 @@ verify_domain(){
local
_BRIDGE
=
"
${
5
}
"
;
shift
5
;
local
_domain_xml
;
local
_disk_vda_xml
;
local
_interface_xml
;
local
_cpu_count
;
local
_ram
;
local
_path
;
local
_mac_address
;
local
_PARAMETERS
;
if
_
domain_xml
=
$(
virsh
-q
dumpxml
"
${
_NAME
}
"
2> /dev/null
)
;
if
_
PARAMETERS
=
$(
examine_domain
"
${
_NAME
}
"
)
;
then
# The domain exists.
_disk_vda_xml
=
$(
_get_elements_by_tag_and_sub_tag_and_attribute_from_xml
\
"
${
_domain_xml
}
"
"disk"
"target"
"dev"
"vda"
)
;
_interface_xml
=
$(
_get_elements_by_tag_and_attribute_from_xml
\
"
${
_domain_xml
}
"
"interface"
"type"
"bridge"
)
;
_cpu_count
=
$(
_get_content_by_tag_from_xml
"
${
_domain_xml
}
"
"vcpu"
)
;
_ram
=
$(
_get_content_by_tag_from_xml
"
${
_domain_xml
}
"
"memory"
)
;
_path
=
$(
_get_value_by_tag_and_attribute_from_xml
"
${
_disk_vda_xml
}
"
"source"
"file"
)
;
_bridge
=
$(
_get_value_by_tag_and_attribute_from_xml
"
${
_interface_xml
}
"
"source"
"bridge"
)
;
_mac_address
=
$(
_get_value_by_tag_and_attribute_from_xml
"
${
_interface_xml
}
"
"mac"
"address"
)
;
eval
"
${
_PARAMETERS
}
"
;
if
\
test
$((
_cpu_count
))
-eq
$((
_CPU_COUNT
))
&&
test
$((
_ram
))
-eq
$((
_RAM
*
1024
))
&&
test
"
${
_path
}
"
=
"
${
_PATH
}
"
&&
test
"
${
_bridge
}
"
=
"
${
_BRIDGE
}
"
&&
(
test
!
"
${
_MAC_ADDRESS
}
"
||
test
"
${
_mac_address
}
"
=
"
${
_MAC_ADDRESS
}
"
)
&&
true
;
test
"
${
DOMAIN_CPU_COUNT
}
"
=
"
${
_CPU_COUNT
}
"
&&
test
"
${
DOMAIN_RAM
}
"
=
$((
_RAM
*
1024
))
&&
test
"
${
DOMAIN_PATH
}
"
=
"
${
_PATH
}
"
&&
test
"
${
DOMAIN_BRIDGE
}
"
=
"
${
_BRIDGE
}
"
&&
(
test
!
"
${
_MAC_ADDRESS
}
"
||
test
"
${
DOMAIN_MAC_ADDRESS
}
"
=
"
${
_MAC_ADDRESS
}
"
)
;
then
# The domain exists and is verified.
return
0
;
else
# The domain exists b
i
t is not verified.
# The domain exists b
u
t is not verified.
return
1
;
fi
;
...
...
@@ -551,15 +537,10 @@ verify_machine(){
local
_path
;
exit
0
;
_path
=
$(
get_image_path
"
${
_NAME
}
"
"default"
)
echo
"_path: [
${
_path
}
]"
;
echo
"_path: [
${
_path
}
]"
;
#verify_domain${_ipv4_address:+ -m $(get_mac_address "${_ipv4_address}")} "${_NAME}" "${_CPU_COUNT}" "${_RAM}" "${_path}" "${_BRIDGE}" ;
}
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment