Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Aruba-Master
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Aruba-Master
Commits
07875a82
Commit
07875a82
authored
Jan 01, 2020
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
9b582bdd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
33 deletions
+30
-33
app.js
app.js
+1
-1
aruba.js
aruba.js
+29
-32
No files found.
app.js
View file @
07875a82
...
...
@@ -79,7 +79,7 @@ cron.schedule('*/10 * * * * *', () => {
});
postRequest
()
cronRemover
.
schedule
(
'
*/
1
* * * *
'
,
()
=>
{
cronRemover
.
schedule
(
'
*/
5
* * * *
'
,
()
=>
{
init
()
});
...
...
aruba.js
View file @
07875a82
...
...
@@ -29,7 +29,6 @@ async function test() {
}
async
function
init
()
{
ip
=
await
getIp
()
for
(
let
i
=
0
;
i
<
AvailDc
.
length
;
i
++
)
{
...
...
@@ -80,7 +79,7 @@ async function createFloatingIp(dc) {
let
d
=
await
doRequest
(
url
,
auth
)
d
=
d
.
Value
await
attachedToServer
(
foundDc
,
d
.
ResourceId
)
await
attachedToServer
(
foundDc
,
d
.
ResourceId
)
return
d
}
...
...
@@ -89,16 +88,21 @@ async function getAllIps(dc) {
let
d
=
await
doRequest
(
url
,
auth
)
return
d
.
Value
let
arr
=
[]
d
=
d
.
Value
for
(
let
i
=
0
;
i
<
d
.
length
;
i
++
)
{
if
(
d
[
i
].
Value
!==
masterIp
)
arr
.
push
(
d
[
i
])
}
return
arr
}
async
function
deleteAllIps
(
dc
)
{
let
ips
=
await
getAllIps
(
foundDc
)
for
(
let
i
=
0
;
i
<
ips
.
length
;
i
++
)
{
if
(
ips
[
i
].
Value
!==
masterIp
)
{
let
d
=
await
deleteIp
(
foundDc
,
ips
[
i
].
ResourceId
)
let
ips
=
await
getAllIps
(
foundDc
)
for
(
let
i
=
0
;
i
<
ips
.
length
;
i
++
)
{
if
(
ips
[
i
].
Value
!==
masterIp
)
{
let
d
=
await
deleteIp
(
foundDc
,
ips
[
i
].
ResourceId
)
console
.
log
(
d
)
}
...
...
@@ -109,8 +113,6 @@ async function deleteAllIps(dc) {
}
async
function
attachedToServer
(
dc
,
resourceId
)
{
let
url
=
generateUrl
(
foundDc
,
'
SetEnqueueAssociateIpAddress
'
)
...
...
@@ -138,13 +140,11 @@ async function unAttachedToServer(dc, resourceId) {
async
function
attachedToServerByIp
(
dc
,
ip
)
{
let
ips
=
await
getAllIps
(
foundDc
)
let
ips
=
await
getAllIps
(
foundDc
)
for
(
let
i
=
0
;
i
<
ips
.
length
;
i
++
)
{
if
(
ips
[
i
].
Value
===
ip
)
{
await
attachedToServer
(
foundDc
,
ips
[
i
].
ResourceId
)
for
(
let
i
=
0
;
i
<
ips
.
length
;
i
++
)
{
if
(
ips
[
i
].
Value
===
ip
)
{
await
attachedToServer
(
foundDc
,
ips
[
i
].
ResourceId
)
break
}
}
...
...
@@ -157,13 +157,11 @@ async function attachedToServerByIp(dc, ip) {
async
function
RemovedByIp
(
dc
,
ip
)
{
let
ips
=
await
getAllIps
(
dc
)
let
ips
=
await
getAllIps
(
dc
)
for
(
let
i
=
0
;
i
<
ips
.
length
;
i
++
)
{
if
(
ips
[
i
].
Value
===
ip
)
{
await
deleteIp
(
foundDc
,
ips
[
i
].
ResourceId
)
for
(
let
i
=
0
;
i
<
ips
.
length
;
i
++
)
{
if
(
ips
[
i
].
Value
===
ip
)
{
await
deleteIp
(
foundDc
,
ips
[
i
].
ResourceId
)
break
}
}
...
...
@@ -186,8 +184,7 @@ async function deleteIp(dc, id) {
}
function
getDc
()
{
function
getDc
()
{
return
foundDc
}
...
...
@@ -213,7 +210,7 @@ async function doRequest(url, body) {
return
new
Promise
(
function
(
resolve
,
reject
)
{
request
(
options
,
function
(
error
,
response
,
body
)
{
if
(
error
)
reject
(
'
Problem ->
'
+
options
.
url
)
if
(
error
)
reject
(
'
Problem ->
'
+
options
.
url
)
try
{
...
...
@@ -285,12 +282,12 @@ function getIp() {
module
.
exports
=
{
init
:
init
,
getAllIps
:
getAllIps
,
getDc
:
getDc
,
attachedToServerByIp
:
attachedToServerByIp
,
RemovedByIp
:
RemovedByIp
,
createFloatingIp
:
createFloatingIp
init
:
init
,
getAllIps
:
getAllIps
,
getDc
:
getDc
,
attachedToServerByIp
:
attachedToServerByIp
,
RemovedByIp
:
RemovedByIp
,
createFloatingIp
:
createFloatingIp
}
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