Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Openstack Gitlab Executor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Pi-Lab
Infrastructure
Openstack Gitlab Executor
Commits
ae33a1a6
Commit
ae33a1a6
authored
2 years ago
by
istmxrein
Browse files
Options
Downloads
Patches
Plain Diff
add error handling to get ip address
parent
ede891e6
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
prepare.py
+10
-10
10 additions, 10 deletions
prepare.py
with
10 additions
and
10 deletions
prepare.py
+
10
−
10
View file @
ae33a1a6
#!/usr/bin/env python
#!/usr/bin/env python
import
sys
import
sys
import
time
import
traceback
import
traceback
import
ipaddress
import
ipaddress
import
openstack
import
openstack
...
@@ -26,7 +27,6 @@ def provision_server(
...
@@ -26,7 +27,6 @@ def provision_server(
name
=
env
.
VM_NAME
,
name
=
env
.
VM_NAME
,
flavor
=
flavor
.
id
,
flavor
=
flavor
.
id
,
image
=
image
.
id
,
image
=
image
.
id
,
auto_ip
=
False
,
boot_from_volume
=
True
,
boot_from_volume
=
True
,
terminate_volume
=
True
,
terminate_volume
=
True
,
wait
=
True
,
wait
=
True
,
...
@@ -37,10 +37,6 @@ def provision_server(
...
@@ -37,10 +37,6 @@ def provision_server(
)
)
server
=
conn
.
wait_for_server
(
server
,
timeout
=
180
)
server
=
conn
.
wait_for_server
(
server
,
timeout
=
180
)
# if env.SSH_IP_VERSION == "4":
# ips = conn.available_floating_ip(network=env.FLOATING_IP_NETWORK, server=server)
# conn.compute.add_floating_ip_to_server(server, ips.floating_ip_address, fixed_address=None)
return
server
return
server
...
@@ -48,11 +44,15 @@ def provision_server(
...
@@ -48,11 +44,15 @@ def provision_server(
def
get_server_ip
(
def
get_server_ip
(
conn
:
openstack
.
connection
.
Connection
,
server
:
openstack
.
compute
.
v2
.
server
.
Server
conn
:
openstack
.
connection
.
Connection
,
server
:
openstack
.
compute
.
v2
.
server
.
Server
)
->
str
:
)
->
str
:
ips
=
[
ipaddress
.
ip_address
(
ip
.
address
)
for
ip
in
list
(
conn
.
compute
.
server_ips
(
server
.
id
))]
for
i
in
range
(
3
):
print
(
ips
)
ips
=
[
ipaddress
.
ip_address
(
ip
.
address
)
for
ip
in
list
(
conn
.
compute
.
server_ips
(
server
.
id
))]
for
ip
in
ips
:
print
(
ips
)
if
env
.
SSH_IP_VERSION
==
str
(
ip
.
version
)
and
ip
.
is_global
:
for
ip
in
ips
:
return
str
(
ip
)
if
env
.
SSH_IP_VERSION
==
str
(
ip
.
version
)
and
ip
.
is_global
:
return
str
(
ip
)
time
.
sleep
(
10
)
raise
RuntimeError
(
"
No working ip address found
"
)
def
check_ssh
(
ip
:
str
)
->
None
:
def
check_ssh
(
ip
:
str
)
->
None
:
...
...
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