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
36ed0e99
authored
May 08, 2020
by
Arnau Comas Codina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Network Interfaces
parent
d0818f18
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
5 deletions
+26
-5
implementation/network/interfaces.py
+26
-5
No files found.
implementation/network/interfaces.py
View file @
36ed0e99
...
@@ -16,7 +16,9 @@ class OSNetworkInterfacesManager(NetworkInterfacesInterface, OpenStackConnection
...
@@ -16,7 +16,9 @@ class OSNetworkInterfacesManager(NetworkInterfacesInterface, OpenStackConnection
def
create_interface
(
self
):
def
create_interface
(
self
):
""" Creates a set of OpenStack resources to provide the functionality of
""" Creates a set of OpenStack resources to provide the functionality of
a "vlan". These resources consists of a router connected to public
a "vlan". These resources consists of a router connected to public
network, a network and a subnet, where the instance gets the local ip
network, a network and a subnet, where the instance gets the local ip.
Returns the ID of the network resource, representing the interface.
"""
"""
project_id
=
self
.
openstack
.
auth
[
'project_id'
]
project_id
=
self
.
openstack
.
auth
[
'project_id'
]
...
@@ -89,26 +91,45 @@ class OSNetworkInterfacesManager(NetworkInterfacesInterface, OpenStackConnection
...
@@ -89,26 +91,45 @@ class OSNetworkInterfacesManager(NetworkInterfacesInterface, OpenStackConnection
@OpenStackError
@OpenStackError
def
add_vm_to_interface
(
self
,
interface_id
):
def
add_vm_to_interface
(
self
,
device_id
,
interface_id
):
""" Attaches the specified device to a "vlan" identified by the
""" Attaches the specified device to a "vlan" identified by the
"interface_id" param. This translates on creating a network port into
"interface_id" param. This translates on creating a network port into
the corresponding "vlan" and thus assign an ip to the device.
the corresponding "vlan" and thus assign an ip to the device.
Note that further actions may be required depending on the "vm" to
Note that further actions may be required depending on the "vm" to
activate and configure the new interface.
activate and configure the new interface.
Returns the ID of the Neutron port.
"""
"""
pass
project_id
=
self
.
openstack
.
auth
[
'project_id'
]
#for subnet in self.openstack.network.subnets(network_id=interface_id):
port
=
self
.
openstack
.
network
.
create_port
(
project_id
=
project_id
,
network_id
=
interface_id
,
is_admin_state_up
=
True
,
device_id
=
device_id
,
device_owner
=
"compute:nova"
,
is_port_security_enabled
=
True
,
binding_vnic_type
=
"normal"
)
#fixed_ips=[{
# 'subnet_id': subnet.id,
# 'ip_address': '29.29.29.29'}]
# adds a fixed IP address from the network (interface_id) to a server
# instance (device_id)
#self.openstack.compute.add_fixed_ip_to_server(device_id, interface_id)
return
port
.
id
@OpenStackError
@OpenStackError
def
remove_vm_from_interface
(
self
,
interface
_id
):
def
remove_vm_from_interface
(
self
,
port
_id
):
""" Detaches the specified device from the "vlan" identified by the
""" Detaches the specified device from the "vlan" identified by the
"interface_id" param.
"interface_id" param.
Note that further actions may be required depending on the "vm" to
Note that further actions may be required depending on the "vm" to
activate and configure the new interface.
activate and configure the new interface.
"""
"""
pass
self
.
openstack
.
network
.
delete_port
(
port_id
)
@OpenStackError
@OpenStackError
...
...
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