Commit 03e739ff authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent b01e7e46
......@@ -78,7 +78,7 @@ async function init() {
}
async function addIPs(ip) {
await aruba.attachedToServerByIp(ip)
// await aruba.attachedToServerByIp(ip)
addBaship(ip)
await postFloatingIps([ip])
}
......@@ -100,7 +100,7 @@ async function checkIps() {
await addIPs(ips[i].Value)
break
case 0:
await aruba.RemovedByIp(ips[i].Value)
// await aruba.RemovedByIp(ips[i].Value)
break
case 1:
await addIPs(ips[i].Value)
......
......@@ -9,11 +9,11 @@ let networkId
let serverId
let initData = false
//test()
test()
async function test() {
masterIp = '195.231.67.55'
masterIp = '195.231.73.236'
for (let i = 0; i < AvailDc.length; i++) {
let servers = await getAllServers(AvailDc[i])
servers = servers.Value
......@@ -43,8 +43,8 @@ async function test() {
console.log('networkId ->' + networkId)
console.log('serverId ->' + serverId)
let a=await RemovedByIp('195.231.67.35')
console.log(a)
let ips = await getAllIps('195.231.67.35')
console.log(ips)
}
......@@ -52,7 +52,7 @@ async function test() {
async function init() {
if (initData === true)
return true
masterIp = getIp()
masterIp = getIp()
for (let i = 0; i < AvailDc.length; i++) {
let servers = await getAllServers(AvailDc[i])
......@@ -105,7 +105,7 @@ async function getDetailsofServer(dc, id) {
}
async function createFloatingIp() {
let ips=await getAllIps()
let ips = await getAllIps()
let url = generateUrl(foundDc, 'SetPurchaseIpAddress')
let d = await doRequest(url, auth)
......@@ -121,19 +121,17 @@ async function getAllIps() {
let arr = []
d = d.Value
for (let i = 0; i < d.length; i++) {
if (d[i].Value !== masterIp)
if (d[i].Value !== masterIp && d[i].ServerId === serverId)
arr.push(d[i])
}
return arr
}
async function canAddFloatingIp()
{
let ips=await getAllIps()
let count=0
for (let i=0;i<ips.length;i++)
{
async function canAddFloatingIp() {
let ips = await getAllIps()
let count = 0
for (let i = 0; i < ips.length; i++) {
}
}
......@@ -145,7 +143,7 @@ async function deleteAllIps() {
for (let i = 0; i < ips.length; i++) {
if (ips[i].Value !== masterIp) {
let d = await deleteIp(foundDc, ips[i].ResourceId)
console.log(d)
// console.log(d)
}
}
......@@ -190,7 +188,7 @@ async function attachedToServerByIp(ip) {
for (let i = 0; i < ips.length; i++) {
if (ips[i].Value === ip) {
console.log(ips[i])
// console.log(ips[i])
await attachedToServer(foundDc, ips[i].ResourceId)
break
}
......@@ -208,22 +206,18 @@ async function RemovedByIp(ip) {
for (let i = 0; i < ips.length; i++) {
if (ips[i].Value === ip && ip !== masterIp) {
return await deleteIp(foundDc, ips[i].ResourceId)
return await deleteIp(foundDc, ips[i].ResourceId)
}
}
}
async function deleteIp(id) {
try {
await unAttachedToServer(foundDc, id)
}
catch (e) {
} catch (e) {
}
......@@ -260,8 +254,7 @@ async function doRequest(url, body) {
if (error) reject('Problem ->' + options.url)
try {
console.log(url)
console.log(body)
resolve(JSON.parse(body))
} catch (e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment