Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
devops
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
1
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
osm
devops
Commits
efe9e06a
Commit
efe9e06a
authored
8 years ago
by
Philip Joseph
Browse files
Options
Downloads
Patches
Plain Diff
Bug 159 : Change to first do ssh and then do http
Signed-off-by:
Philip Joseph
<
philip.joseph@riftio.com
>
parent
0efe584c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
layers/pingpong/reactive/pingpong.py
+8
-24
8 additions, 24 deletions
layers/pingpong/reactive/pingpong.py
with
8 additions
and
24 deletions
layers/pingpong/reactive/pingpong.py
+
8
−
24
View file @
efe9e06a
...
...
@@ -49,22 +49,6 @@ def get_port():
return
port
def
run
(
cmd
):
"""
Run a command on the local machine.
"""
if
isinstance
(
cmd
,
str
):
cmd
=
cmd
.
split
()
if
'
'
in
cmd
else
[
cmd
]
p
=
Popen
(
cmd
,
stdout
=
PIPE
,
stderr
=
PIPE
)
stdout
,
stderr
=
p
.
communicate
()
retcode
=
p
.
poll
()
if
retcode
>
0
:
raise
CalledProcessError
(
returncode
=
retcode
,
cmd
=
cmd
,
output
=
stderr
.
decode
(
"
utf-8
"
).
strip
())
return
(
stdout
.
decode
(
'
utf-8
'
).
strip
(),
stderr
.
decode
(
'
utf-8
'
).
strip
())
@when
(
'
pingpong.configured
'
)
@when
(
'
actions.start
'
)
def
start
():
...
...
@@ -149,7 +133,7 @@ def set_server():
data
,
)
result
,
err
=
run
(
cmd
)
result
,
err
=
charms
.
sshproxy
.
_
run
(
cmd
)
except
Exception
as
e
:
action_fail
(
'
command failed: {}, errors: {}
'
.
format
(
e
,
e
.
output
))
else
:
...
...
@@ -167,7 +151,7 @@ def set_rate():
rate
=
action_get
(
'
rate
'
)
cmd
=
format_curl
(
'
POST
'
,
'
/rate
'
,
'
{{
"
rate
"
: {}}}
'
.
format
(
rate
))
result
,
err
=
run
(
cmd
)
result
,
err
=
charms
.
sshproxy
.
_
run
(
cmd
)
except
Exception
as
e
:
err
=
"
{}
"
.
format
(
e
)
action_fail
(
'
command failed: {}, errors: {}
'
.
format
(
err
,
e
.
output
))
...
...
@@ -185,7 +169,7 @@ def get_rate():
if
is_ping
():
cmd
=
format_curl
(
'
GET
'
,
'
/rate
'
)
result
,
err
=
run
(
cmd
)
result
,
err
=
charms
.
sshproxy
.
_
run
(
cmd
)
except
Exception
as
e
:
action_fail
(
'
command failed: {}, errors: {}
'
.
format
(
e
,
e
.
output
))
else
:
...
...
@@ -201,7 +185,7 @@ def get_state():
try
:
cmd
=
format_curl
(
'
GET
'
,
'
/state
'
)
result
,
err
=
run
(
cmd
)
result
,
err
=
charms
.
sshproxy
.
_
run
(
cmd
)
except
Exception
as
e
:
action_fail
(
'
command failed: {}, errors: {}
'
.
format
(
e
,
e
.
output
))
else
:
...
...
@@ -217,7 +201,7 @@ def get_stats():
try
:
cmd
=
format_curl
(
'
GET
'
,
'
/stats
'
)
result
,
err
=
run
(
cmd
)
result
,
err
=
charms
.
sshproxy
.
_
run
(
cmd
)
except
Exception
as
e
:
action_fail
(
'
command failed: {}, errors: {}
'
.
format
(
e
,
e
.
output
))
else
:
...
...
@@ -233,7 +217,7 @@ def start_traffic():
try
:
cmd
=
format_curl
(
'
POST
'
,
'
/adminstatus/state
'
,
'
{
"
enable
"
: true}
'
)
result
,
err
=
run
(
cmd
)
result
,
err
=
charms
.
sshproxy
.
_
run
(
cmd
)
except
Exception
as
e
:
action_fail
(
'
command failed: {}, errors: {}
'
.
format
(
e
,
e
.
output
))
else
:
...
...
@@ -249,7 +233,7 @@ def stop_traffic():
try
:
cmd
=
format_curl
(
'
POST
'
,
'
/adminstatus/state
'
,
'
{
"
enable
"
: false}
'
)
result
,
err
=
run
(
cmd
)
result
,
err
=
charms
.
sshproxy
.
_
run
(
cmd
)
except
Exception
as
e
:
action_fail
(
'
command failed: {}, errors: {}
'
.
format
(
e
,
e
.
output
))
else
:
...
...
@@ -268,7 +252,7 @@ def format_curl(method, path, data=None):
return
None
# Get our service info
host
=
cfg
[
'
ssh-hostname
'
]
host
=
'
127.0.0.1
'
port
=
get_port
()
mode
=
cfg
[
'
mode
'
]
...
...
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