Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE3
/
gpuvirt
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
dad51817
authored
Aug 08, 2023
by
Zoltan Karsa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ip sup
parent
fb783689
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
0 deletions
+26
-0
port_forward.sh
+3
-0
utils.py
+16
-0
vm.py
+7
-0
No files found.
port_forward.sh
0 → 100644
View file @
dad51817
iptables
-I
FORWARD
-m
state
-d
$1
--state
NEW,RELATED,ESTABLISHED
-j
ACCEPT
iptables
-t
nat
-I
PREROUTING
-p
tcp
-d
10.5.1.3
--dport
3389
-j
DNAT
--to-destination
192.168.122.28:3389
\ No newline at end of file
utils.py
0 → 100644
View file @
dad51817
import
libvirt
def
fwd_port
(
dom
,
guest_port
,
host_port
):
ifaces
=
dom
.
interfaceAddresses
(
libvirt
.
VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT
,
0
)
def
show_ip
(
dom
):
ifaces
=
dom
.
interfaceAddresses
(
libvirt
.
VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT
,
0
)
for
(
name
,
val
)
in
ifaces
.
iteritems
():
if
val
[
'addrs'
]:
for
ipaddr
in
val
[
'addrs'
]:
if
ipaddr
[
'type'
]
==
libvirt
.
VIR_IP_ADDR_TYPE_IPV4
:
print
(
ipaddr
[
'addr'
]
+
" VIR_IP_ADDR_TYPE_IPV4"
)
elif
ipaddr
[
'type'
]
==
libvirt
.
VIR_IP_ADDR_TYPE_IPV6
:
print
(
ipaddr
[
'addr'
]
+
" VIR_IP_ADDR_TYPE_IPV6"
)
\ No newline at end of file
vm.py
View file @
dad51817
...
@@ -4,6 +4,8 @@ import uuid
...
@@ -4,6 +4,8 @@ import uuid
from
jinja2
import
Environment
,
select_autoescape
,
FileSystemLoader
from
jinja2
import
Environment
,
select_autoescape
,
FileSystemLoader
import
subprocess
import
subprocess
from
utils
import
fwd_port
,
show_ip
try
:
try
:
conn
=
libvirt
.
open
(
"qemu:///system"
)
conn
=
libvirt
.
open
(
"qemu:///system"
)
except
libvirt
.
libvirtError
:
except
libvirt
.
libvirtError
:
...
@@ -68,6 +70,11 @@ print(dom.info())
...
@@ -68,6 +70,11 @@ print(dom.info())
print
(
"Type stop, to shutdown vm!"
)
print
(
"Type stop, to shutdown vm!"
)
cmd
=
input
()
cmd
=
input
()
while
cmd
!=
"stop"
:
while
cmd
!=
"stop"
:
cmdarr
=
cmd
.
split
()
if
cmdarr
[
0
]
==
"fwd"
:
fwd_port
(
dom
,
int
(
cmdarr
[
1
]),
int
(
cmdarr
[
2
]))
elif
cmdarr
[
0
]
==
"showip"
:
show_ip
(
dom
)
cmd
=
input
()
cmd
=
input
()
try
:
try
:
...
...
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