Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
itminedu
okeanos-LoD
Commits
78e83d94
Unverified
Commit
78e83d94
authored
Jul 03, 2015
by
efikalti
Committed by
Avraam Tsantekidis
Jul 17, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LAM-39 method to assign public ip to vm
parent
12c1528b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
4 deletions
+23
-4
kamaki/vm_setup_library.py
kamaki/vm_setup_library.py
+23
-4
No files found.
kamaki/vm_setup_library.py
View file @
78e83d94
...
...
@@ -133,11 +133,11 @@ class Provisioner:
def
reserve_ip
(
self
):
"""
Reserve ip
:return: the i
d
o
f the ip
if successfull
:return: the i
p
o
bject
if successfull
"""
try
:
ip
=
self
.
network_client
.
create_floatingip
()
return
ip
[
'id'
]
return
ip
except
ClientError
as
ex
:
raise
ex
return
okeanos_response
...
...
@@ -168,12 +168,29 @@ class Provisioner:
"""
try
:
port
=
self
.
network_client
.
create_port
(
network_id
=
net_id
,
device_id
=
vm_id
,
)
device_id
=
vm_id
)
return
True
except
ClientError
as
ex
:
raise
ex
return
okeanos_response
def
attach_public_ip
(
self
,
ip
,
vm_id
):
"""
Attach the public ip with this id to the vm
:param fnet_id: id of the floating network of the ip
:param vm_id: id of the vm
:return: returns True if successfull
"""
try
:
port
=
self
.
network_client
.
create_port
(
network_id
=
ip
[
'floating_network_id'
],
device_id
=
vm_id
,
fixed_ips
=
[
dict
(
ip_address
=
ip
[
'floating_ip_address'
]),
])
return
True
except
ClientError
as
ex
:
raise
ex
return
okeanos_response
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
(
description
=
"Okeanos VM provisioning"
)
parser
.
add_argument
(
'--cloud'
,
type
=
str
,
dest
=
"cloud"
,
default
=
"lambda"
)
...
...
@@ -187,5 +204,7 @@ if __name__ == "__main__":
# net_id = provisioner.create_vpn("test")
# print provisioner.create_private_subnet(net_id)
# provisioner.connect_vm(663972,net_id)
# provisioner.reserve_ip()
# ip = provisioner.reserve_ip()
# print ip['id']
# provisioner.attach_public_ip(ip,663972)
# provisioner.attach_vm_to_network(663972,net_id)
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