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
af25290c
Commit
af25290c
authored
Apr 17, 2020
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
3f1eb744
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
10 deletions
+15
-10
app.js
app.js
+8
-7
aruba.js
aruba.js
+7
-3
No files found.
app.js
View file @
af25290c
...
...
@@ -32,7 +32,7 @@ app.get('/ip/:ip/', (req, res) => {
async
function
addBaship
(
ip
)
{
let
command
=
'
sudo ifconfig eth0:
'
+
randomInt
(
0
,
99999
)
+
'
'
+
ip
+
'
netmask 255.255.255.0 up && /etc/init.d/networking restart
'
let
command
=
'
sudo ifconfig eth0:
'
+
randomInt
(
0
,
99999
)
+
'
'
+
ip
+
'
netmask 255.255.255.0 up && /etc/init.d/networking restart
'
console
.
log
(
command
)
return
shell
.
exec
(
command
).
stderr
;
...
...
@@ -68,7 +68,7 @@ cronRemover.schedule(' */2 * * * *', () => {
init
()
});
init
()
async
function
init
()
{
await
initToken
()
...
...
@@ -77,13 +77,12 @@ async function init() {
}
async
function
addIPs
(
ip
)
{
await
aruba
.
attachedToServerByIp
(
ip
)
await
aruba
.
attachedToServerByIp
(
ip
)
addBaship
(
ip
)
await
postFloatingIps
([
ip
])
}
async
function
justDoIp
(
ip
)
{
async
function
justDoIp
(
ip
)
{
addBaship
(
ip
)
await
postFloatingIps
([
ip
])
...
...
@@ -107,7 +106,7 @@ async function checkIps() {
await
aruba
.
RemovedByIp
(
ips
[
i
].
Value
)
break
case
1
:
await
justDoIp
(
ips
[
i
].
Value
)
await
justDoIp
(
ips
[
i
].
Value
)
break
}
...
...
@@ -121,7 +120,9 @@ async function sleep(millis) {
async
function
initToken
()
{
await
aruba
.
init
()
let
d
=
aruba
.
getDc
()
if
(
typeof
d
===
"
undefined
"
)
await
aruba
.
init
()
// remover()
...
...
aruba.js
View file @
af25290c
...
...
@@ -105,7 +105,6 @@ async function getAllIps() {
let
url
=
generateUrl
(
foundDc
,
'
GetPurchasedIpAddresses
'
)
let
d
=
await
doRequest
(
url
,
auth
)
masterIp
=
await
getIp
()
let
arr
=
[]
d
=
d
.
Value
for
(
let
i
=
0
;
i
<
d
.
length
;
i
++
)
{
...
...
@@ -118,7 +117,7 @@ async function getAllIps() {
async
function
deleteAllIps
()
{
masterIp
=
await
getIp
()
let
ips
=
await
getAllIps
(
foundDc
)
for
(
let
i
=
0
;
i
<
ips
.
length
;
i
++
)
{
if
(
ips
[
i
].
Value
!==
masterIp
)
{
...
...
@@ -158,6 +157,10 @@ async function unAttachedToServer(resourceId) {
}
function
getDc
()
{
return
foundDc
}
async
function
attachedToServerByIp
(
ip
)
{
let
ips
=
await
getAllIps
(
foundDc
)
...
...
@@ -178,7 +181,7 @@ async function attachedToServerByIp(ip) {
async
function
RemovedByIp
(
ip
)
{
let
ips
=
await
getAllIps
(
foundDc
)
masterIp
=
await
getIp
()
for
(
let
i
=
0
;
i
<
ips
.
length
;
i
++
)
{
if
(
ips
[
i
].
Value
===
ip
&&
ip
!==
masterIp
)
{
await
deleteIp
(
foundDc
,
ips
[
i
].
ResourceId
)
...
...
@@ -302,6 +305,7 @@ module.exports =
getAllIps
:
getAllIps
,
attachedToServerByIp
:
attachedToServerByIp
,
RemovedByIp
:
RemovedByIp
,
getDc
:
getDc
,
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