Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
RECIRCLE
/
interface-openstack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
2
Merge Requests
4
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a5a2ad01
authored
Apr 24, 2020
by
Arnau Comas Codina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port Forwarding interface & resources classes
parent
9adbf711
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
0 deletions
+72
-0
interface/network/port_forwarding.py
+17
-0
interface/network/resources.py
+55
-0
No files found.
interface/network/port_forwarding.py
0 → 100644
View file @
a5a2ad01
"""
General interface for using the CIRCLE portal API
It should be implemented for using other providers e. g. OpenStack
"""
class
PortForwardingInterface
:
def
create_port_forwarding
(
self
,
instance_id
,
internal_port_number
,
protocol
):
raise
NotImplementedError
def
remove_port_forwarding
(
self
,
instance_id
,
internal_port_number
):
raise
NotImplementedError
def
list_instance_port_forwardings
(
self
,
instance_id
):
raise
NotImplementedError
interface/network/resources.py
0 → 100644
View file @
a5a2ad01
import
json
class
FloatingIP
:
""" From the OpenStack Floating IP source data:
- Releveant attributes are stored
- Some methods regarding class representation
"""
def
__init__
(
self
,
data
):
self
.
id
=
data
[
'id'
]
# str
self
.
address
=
data
[
'floating_ip_address'
]
# str
self
.
status
=
data
[
'status'
]
# str e.g. 'ACTIVE'
self
.
floating_network_id
=
data
[
'floating_network_id'
]
# str
self
.
router_id
=
data
[
'router_id'
]
# str
self
.
port_forwardings
=
[]
# objects come w/o id here, are fetched after
# [PortForwarding(item) for item in data['port_forwardings']]
self
.
created_at
=
data
[
'created_at'
]
# str
self
.
updated_at
=
data
[
'updated_at'
]
# str
def
__repr__
(
self
):
return
f
"FloatingIP({self.address})"
def
__str__
(
self
):
return
f
"FloatingIP({self.address})"
def
JSON
(
self
):
return
json
.
dumps
(
self
.
__dict__
)
class
PortForwarding
:
""" From the OpenStack Port Forwarding source data:
- Releveant attributes are stored
- Some methods regarding class representation
"""
def
__init__
(
self
,
data
):
self
.
id
=
data
[
'id'
]
# str
self
.
protocol
=
data
[
'protocol'
]
# str
self
.
internal_ip_address
=
data
[
'internal_ip_address'
]
# str
self
.
internal_port
=
data
[
'internal_port'
]
# number
self
.
external_port
=
data
[
'external_port'
]
# number
def
__repr__
(
self
):
return
(
f
"PortForwarding({self.internal_ip_address}:{self.internal_port}"
f
" -> {self.external_port})"
)
def
__str__
(
self
):
return
(
f
"PortForwarding({self.internal_ip_address}:{self.internal_port}"
f
" -> {self.external_port})"
)
def
JSON
(
self
):
return
json
.
dumps
(
self
.
__dict__
)
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