Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snf-ganeti
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
itminedu
snf-ganeti
Commits
59a5de9e
Commit
59a5de9e
authored
12 years ago
by
Dimitris Aragiorgis
Browse files
Options
Downloads
Patches
Plain Diff
Fixes to pass pylint (make lint)
Signed-off-by:
Dimitris Aragiorgis
<
dimara@grnet.gr
>
parent
9650d658
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/cmdlib.py
+9
-8
9 additions, 8 deletions
lib/cmdlib.py
lib/hypervisor/hv_kvm.py
+22
-25
22 additions, 25 deletions
lib/hypervisor/hv_kvm.py
with
31 additions
and
33 deletions
lib/cmdlib.py
+
9
−
8
View file @
59a5de9e
...
@@ -12821,11 +12821,12 @@ class LUInstanceSetParams(LogicalUnit):
...
@@ -12821,11 +12821,12 @@ class LUInstanceSetParams(LogicalUnit):
if self.op.hotplug and disk.pci:
if self.op.hotplug and disk.pci:
self.LogInfo("Trying to hotplug device.")
self.LogInfo("Trying to hotplug device.")
disk_ok
, device_info = _AssembleInstanceDisks(self, self.instance,
_
, device_info = _AssembleInstanceDisks(self, self.instance,
[disk], check=False)
[disk], check=False)
_, _, dev_path = device_info[0]
_, _, dev_path = device_info[0]
result = self.rpc.call_hot_add_disk(self.instance.primary_node,
#TODO: handle result
self.instance, disk, dev_path, idx)
self.rpc.call_hot_add_disk(self.instance.primary_node,
self.instance, disk, dev_path, idx)
return (disk, [
return (disk, [
("disk/%d" % idx, "add:size=%s,mode=%s" % (disk.size, disk.mode)),
("disk/%d" % idx, "add:size=%s,mode=%s" % (disk.size, disk.mode)),
])
])
...
@@ -12890,8 +12891,8 @@ class LUInstanceSetParams(LogicalUnit):
...
@@ -12890,8 +12891,8 @@ class LUInstanceSetParams(LogicalUnit):
if pci is not None:
if pci is not None:
nic.idx = nic_idx
nic.idx = nic_idx
nic.pci = pci
nic.pci = pci
result =
self.rpc.call_hot_add_nic(self.instance.primary_node,
self.rpc.call_hot_add_nic(self.instance.primary_node,
self.instance, nic, idx)
self.instance, nic, idx)
desc = [
desc = [
("nic.%d" % idx,
("nic.%d" % idx,
"add:mac=%s,ip=%s,mode=%s,link=%s" %
"add:mac=%s,ip=%s,mode=%s,link=%s" %
...
@@ -12923,11 +12924,11 @@ class LUInstanceSetParams(LogicalUnit):
...
@@ -12923,11 +12924,11 @@ class LUInstanceSetParams(LogicalUnit):
self.LogInfo("Trying to hotplug device.")
self.LogInfo("Trying to hotplug device.")
self.rpc.call_hot_del_nic(self.instance.primary_node,
self.rpc.call_hot_del_nic(self.instance.primary_node,
self.instance, nic, idx)
self.instance, nic, idx)
result =
self.rpc.call_hot_add_nic(self.instance.primary_node,
self.rpc.call_hot_add_nic(self.instance.primary_node,
self.instance, nic, idx)
self.instance, nic, idx)
return changes
return changes
def _RemoveNic(self, idx, nic,
private
):
def _RemoveNic(self, idx, nic,
_
):
if nic.pci and not self.op.hotplug:
if nic.pci and not self.op.hotplug:
raise errors.OpPrereqError("Cannot remove a nic that has been hotplugged"
raise errors.OpPrereqError("Cannot remove a nic that has been hotplugged"
" without removing it with hotplug",
" without removing it with hotplug",
...
...
This diff is collapsed.
Click to expand it.
lib/hypervisor/hv_kvm.py
+
22
−
25
View file @
59a5de9e
...
@@ -1039,9 +1039,8 @@ class KVMHypervisor(hv_base.BaseHypervisor):
...
@@ -1039,9 +1039,8 @@ class KVMHypervisor(hv_base.BaseHypervisor):
hvp
=
instance
.
hvparams
hvp
=
instance
.
hvparams
kernel_path
=
hvp
[
constants
.
HV_KERNEL_PATH
]
kernel_path
=
hvp
[
constants
.
HV_KERNEL_PATH
]
if
kernel_path
:
if
kernel_path
:
boot_disk
=
boot_cdrom
=
boot_floppy
=
boot_network
=
False
boot_cdrom
=
boot_floppy
=
boot_network
=
False
else
:
else
:
boot_disk
=
hvp
[
constants
.
HV_BOOT_ORDER
]
==
constants
.
HT_BO_DISK
boot_cdrom
=
hvp
[
constants
.
HV_BOOT_ORDER
]
==
constants
.
HT_BO_CDROM
boot_cdrom
=
hvp
[
constants
.
HV_BOOT_ORDER
]
==
constants
.
HT_BO_CDROM
boot_floppy
=
hvp
[
constants
.
HV_BOOT_ORDER
]
==
constants
.
HT_BO_FLOPPY
boot_floppy
=
hvp
[
constants
.
HV_BOOT_ORDER
]
==
constants
.
HT_BO_FLOPPY
boot_network
=
hvp
[
constants
.
HV_BOOT_ORDER
]
==
constants
.
HT_BO_NETWORK
boot_network
=
hvp
[
constants
.
HV_BOOT_ORDER
]
==
constants
.
HT_BO_NETWORK
...
@@ -1400,7 +1399,6 @@ class KVMHypervisor(hv_base.BaseHypervisor):
...
@@ -1400,7 +1399,6 @@ class KVMHypervisor(hv_base.BaseHypervisor):
conf_hvp
=
instance
.
hvparams
conf_hvp
=
instance
.
hvparams
name
=
instance
.
name
name
=
instance
.
name
self
.
_CheckDown
(
name
)
self
.
_CheckDown
(
name
)
boot_disk
=
conf_hvp
[
constants
.
HV_BOOT_ORDER
]
==
constants
.
HT_BO_DISK
temp_files
=
[]
temp_files
=
[]
...
@@ -1627,12 +1625,12 @@ class KVMHypervisor(hv_base.BaseHypervisor):
...
@@ -1627,12 +1625,12 @@ class KVMHypervisor(hv_base.BaseHypervisor):
return
result
return
result
def
HotAddDisk
(
self
,
instance
,
disk
,
dev_path
,
seq
):
def
HotAddDisk
(
self
,
instance
,
disk
,
dev_path
,
_
):
"""
Hotadd new disk to the VM
"""
Hotadd new disk to the VM
"""
"""
if
not
self
.
_InstancePidAlive
(
instance
.
name
)[
2
]:
if
not
self
.
_InstancePidAlive
(
instance
.
name
)[
2
]:
logging
.
info
(
"
Cannot hotplug. Instance %s not alive
"
%
instance
.
name
)
logging
.
info
(
"
Cannot hotplug. Instance %s not alive
"
,
instance
.
name
)
return
disk
.
ToDict
()
return
disk
.
ToDict
()
_
,
v_major
,
v_min
,
_
=
self
.
_GetKVMVersion
()
_
,
v_major
,
v_min
,
_
=
self
.
_GetKVMVersion
()
...
@@ -1641,16 +1639,16 @@ class KVMHypervisor(hv_base.BaseHypervisor):
...
@@ -1641,16 +1639,16 @@ class KVMHypervisor(hv_base.BaseHypervisor):
command
=
(
"
drive_add dummy file=%s,if=none,id=drive%d,format=raw
"
%
command
=
(
"
drive_add dummy file=%s,if=none,id=drive%d,format=raw
"
%
(
dev_path
,
idx
))
(
dev_path
,
idx
))
logging
.
info
(
"
%s
"
%
command
)
logging
.
info
(
"
Run cmd
%s
"
,
command
)
output
=
self
.
_CallMonitorCommand
(
instance
.
name
,
command
)
output
=
self
.
_CallMonitorCommand
(
instance
.
name
,
command
)
command
=
(
"
device_add virtio-blk-pci,bus=pci.0,addr=%s,
"
command
=
(
"
device_add virtio-blk-pci,bus=pci.0,addr=%s,
"
"
drive=drive%d,id=virtio-blk-pci.%d
"
"
drive=drive%d,id=virtio-blk-pci.%d
"
%
(
hex
(
disk
.
pci
),
idx
,
idx
))
%
(
hex
(
disk
.
pci
),
idx
,
idx
))
logging
.
info
(
"
%s
"
%
command
)
logging
.
info
(
"
Run cmd
%s
"
,
command
)
output
=
self
.
_CallMonitorCommand
(
instance
.
name
,
command
)
output
=
self
.
_CallMonitorCommand
(
instance
.
name
,
command
)
for
line
in
output
.
stdout
.
splitlines
():
for
line
in
output
.
stdout
.
splitlines
():
logging
.
info
(
"
%s
"
%
line
)
logging
.
info
(
"
%s
"
,
line
)
(
kvm_cmd
,
kvm_nics
,
(
kvm_cmd
,
kvm_nics
,
hvparams
,
block_devices
)
=
self
.
_LoadKVMRuntime
(
instance
)
hvparams
,
block_devices
)
=
self
.
_LoadKVMRuntime
(
instance
)
...
@@ -1660,12 +1658,12 @@ class KVMHypervisor(hv_base.BaseHypervisor):
...
@@ -1660,12 +1658,12 @@ class KVMHypervisor(hv_base.BaseHypervisor):
return
disk
.
ToDict
()
return
disk
.
ToDict
()
def
HotDelDisk
(
self
,
instance
,
disk
,
seq
):
def
HotDelDisk
(
self
,
instance
,
disk
,
_
):
"""
Hotdel disk to the VM
"""
Hotdel disk to the VM
"""
"""
if
not
self
.
_InstancePidAlive
(
instance
.
name
)[
2
]:
if
not
self
.
_InstancePidAlive
(
instance
.
name
)[
2
]:
logging
.
info
(
"
Cannot hotplug. Instance %s not alive
"
%
instance
.
name
)
logging
.
info
(
"
Cannot hotplug. Instance %s not alive
"
,
instance
.
name
)
return
disk
.
ToDict
()
return
disk
.
ToDict
()
_
,
v_major
,
v_min
,
_
=
self
.
_GetKVMVersion
()
_
,
v_major
,
v_min
,
_
=
self
.
_GetKVMVersion
()
...
@@ -1673,13 +1671,13 @@ class KVMHypervisor(hv_base.BaseHypervisor):
...
@@ -1673,13 +1671,13 @@ class KVMHypervisor(hv_base.BaseHypervisor):
idx
=
disk
.
idx
idx
=
disk
.
idx
command
=
"
device_del virtio-blk-pci.%d
"
%
idx
command
=
"
device_del virtio-blk-pci.%d
"
%
idx
logging
.
info
(
"
%s
"
%
command
)
logging
.
info
(
"
Run cmd
%s
"
,
command
)
output
=
self
.
_CallMonitorCommand
(
instance
.
name
,
command
)
output
=
self
.
_CallMonitorCommand
(
instance
.
name
,
command
)
for
line
in
output
.
stdout
.
splitlines
():
for
line
in
output
.
stdout
.
splitlines
():
logging
.
info
(
"
%s
"
%
line
)
logging
.
info
(
"
%s
"
,
line
)
command
=
"
drive_del drive%d
"
%
idx
command
=
"
drive_del drive%d
"
%
idx
logging
.
info
(
"
%s
"
%
command
)
logging
.
info
(
"
Run cmd
%s
"
,
command
)
#output = self._CallMonitorCommand(instance.name, command)
#output = self._CallMonitorCommand(instance.name, command)
#for line in output.stdout.splitlines():
#for line in output.stdout.splitlines():
# logging.info("%s" % line)
# logging.info("%s" % line)
...
@@ -1702,7 +1700,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
...
@@ -1702,7 +1700,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
"""
"""
if
not
self
.
_InstancePidAlive
(
instance
.
name
)[
2
]:
if
not
self
.
_InstancePidAlive
(
instance
.
name
)[
2
]:
logging
.
info
(
"
Cannot hotplug. Instance %s not alive
"
%
instance
.
name
)
logging
.
info
(
"
Cannot hotplug. Instance %s not alive
"
,
instance
.
name
)
return
nic
.
ToDict
()
return
nic
.
ToDict
()
_
,
v_major
,
v_min
,
_
=
self
.
_GetKVMVersion
()
_
,
v_major
,
v_min
,
_
=
self
.
_GetKVMVersion
()
...
@@ -1717,18 +1715,18 @@ class KVMHypervisor(hv_base.BaseHypervisor):
...
@@ -1717,18 +1715,18 @@ class KVMHypervisor(hv_base.BaseHypervisor):
command
=
(
"
netdev_add tap,id=netdev%d,fd=netdev%d
"
command
=
(
"
netdev_add tap,id=netdev%d,fd=netdev%d
"
%
(
idx
,
idx
))
%
(
idx
,
idx
))
logging
.
info
(
"
%s
"
%
command
)
logging
.
info
(
"
Run cmd
%s
"
,
command
)
output
=
self
.
_CallMonitorCommand
(
instance
.
name
,
command
)
output
=
self
.
_CallMonitorCommand
(
instance
.
name
,
command
)
for
line
in
output
.
stdout
.
splitlines
():
for
line
in
output
.
stdout
.
splitlines
():
logging
.
info
(
"
%s
"
%
line
)
logging
.
info
(
"
%s
"
,
line
)
command
=
(
"
device_add virtio-net-pci,bus=pci.0,addr=%s,mac=%s,
"
command
=
(
"
device_add virtio-net-pci,bus=pci.0,addr=%s,mac=%s,
"
"
netdev=netdev%d,id=virtio-net-pci.%d
"
"
netdev=netdev%d,id=virtio-net-pci.%d
"
%
(
hex
(
nic
.
pci
),
mac
,
idx
,
idx
))
%
(
hex
(
nic
.
pci
),
mac
,
idx
,
idx
))
logging
.
info
(
"
%s
"
%
command
)
logging
.
info
(
"
Run cmd
%s
"
,
command
)
output
=
self
.
_CallMonitorCommand
(
instance
.
name
,
command
)
output
=
self
.
_CallMonitorCommand
(
instance
.
name
,
command
)
for
line
in
output
.
stdout
.
splitlines
():
for
line
in
output
.
stdout
.
splitlines
():
logging
.
info
(
"
%s
"
%
line
)
logging
.
info
(
"
%s
"
,
line
)
self
.
_ConfigureNIC
(
instance
,
seq
,
nic
,
tap
)
self
.
_ConfigureNIC
(
instance
,
seq
,
nic
,
tap
)
...
@@ -1740,30 +1738,29 @@ class KVMHypervisor(hv_base.BaseHypervisor):
...
@@ -1740,30 +1738,29 @@ class KVMHypervisor(hv_base.BaseHypervisor):
return
nic
.
ToDict
()
return
nic
.
ToDict
()
def
HotDelNic
(
self
,
instance
,
nic
,
seq
):
def
HotDelNic
(
self
,
instance
,
nic
,
_
):
"""
Hotadd new nic to the VM
"""
Hotadd new nic to the VM
"""
"""
if
not
self
.
_InstancePidAlive
(
instance
.
name
)[
2
]:
if
not
self
.
_InstancePidAlive
(
instance
.
name
)[
2
]:
logging
.
info
(
"
Cannot hotplug. Instance %s not alive
"
%
instance
.
name
)
logging
.
info
(
"
Cannot hotplug. Instance %s not alive
"
,
instance
.
name
)
return
nic
.
ToDict
()
return
nic
.
ToDict
()
_
,
v_major
,
v_min
,
_
=
self
.
_GetKVMVersion
()
_
,
v_major
,
v_min
,
_
=
self
.
_GetKVMVersion
()
if
(
v_major
,
v_min
)
>=
(
1
,
0
)
and
nic
.
pci
:
if
(
v_major
,
v_min
)
>=
(
1
,
0
)
and
nic
.
pci
:
mac
=
nic
.
mac
idx
=
nic
.
idx
idx
=
nic
.
idx
command
=
"
device_del virtio-net-pci.%d
"
%
idx
command
=
"
device_del virtio-net-pci.%d
"
%
idx
logging
.
info
(
"
%s
"
%
command
)
logging
.
info
(
"
Run cmd
%s
"
,
command
)
output
=
self
.
_CallMonitorCommand
(
instance
.
name
,
command
)
output
=
self
.
_CallMonitorCommand
(
instance
.
name
,
command
)
for
line
in
output
.
stdout
.
splitlines
():
for
line
in
output
.
stdout
.
splitlines
():
logging
.
info
(
"
%s
"
%
line
)
logging
.
info
(
"
%s
"
,
line
)
command
=
"
netdev_del netdev%d
"
%
idx
command
=
"
netdev_del netdev%d
"
%
idx
logging
.
info
(
"
%s
"
%
command
)
logging
.
info
(
"
Run cmd
%s
"
,
command
)
output
=
self
.
_CallMonitorCommand
(
instance
.
name
,
command
)
output
=
self
.
_CallMonitorCommand
(
instance
.
name
,
command
)
for
line
in
output
.
stdout
.
splitlines
():
for
line
in
output
.
stdout
.
splitlines
():
logging
.
info
(
"
%s
"
%
line
)
logging
.
info
(
"
%s
"
,
line
)
(
kvm_cmd
,
kvm_nics
,
(
kvm_cmd
,
kvm_nics
,
hvparams
,
block_devices
)
=
self
.
_LoadKVMRuntime
(
instance
)
hvparams
,
block_devices
)
=
self
.
_LoadKVMRuntime
(
instance
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment