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

init

parent b01e7e46
...@@ -78,7 +78,7 @@ async function init() { ...@@ -78,7 +78,7 @@ async function init() {
} }
async function addIPs(ip) { async function addIPs(ip) {
await aruba.attachedToServerByIp(ip) // await aruba.attachedToServerByIp(ip)
addBaship(ip) addBaship(ip)
await postFloatingIps([ip]) await postFloatingIps([ip])
} }
...@@ -100,7 +100,7 @@ async function checkIps() { ...@@ -100,7 +100,7 @@ async function checkIps() {
await addIPs(ips[i].Value) await addIPs(ips[i].Value)
break break
case 0: case 0:
await aruba.RemovedByIp(ips[i].Value) // await aruba.RemovedByIp(ips[i].Value)
break break
case 1: case 1:
await addIPs(ips[i].Value) await addIPs(ips[i].Value)
......
...@@ -9,11 +9,11 @@ let networkId ...@@ -9,11 +9,11 @@ let networkId
let serverId let serverId
let initData = false let initData = false
//test() test()
async function test() { async function test() {
masterIp = '195.231.67.55' masterIp = '195.231.73.236'
for (let i = 0; i < AvailDc.length; i++) { for (let i = 0; i < AvailDc.length; i++) {
let servers = await getAllServers(AvailDc[i]) let servers = await getAllServers(AvailDc[i])
servers = servers.Value servers = servers.Value
...@@ -43,8 +43,8 @@ async function test() { ...@@ -43,8 +43,8 @@ async function test() {
console.log('networkId ->' + networkId) console.log('networkId ->' + networkId)
console.log('serverId ->' + serverId) console.log('serverId ->' + serverId)
let a=await RemovedByIp('195.231.67.35') let ips = await getAllIps('195.231.67.35')
console.log(a) console.log(ips)
} }
...@@ -105,7 +105,7 @@ async function getDetailsofServer(dc, id) { ...@@ -105,7 +105,7 @@ async function getDetailsofServer(dc, id) {
} }
async function createFloatingIp() { async function createFloatingIp() {
let ips=await getAllIps() let ips = await getAllIps()
let url = generateUrl(foundDc, 'SetPurchaseIpAddress') let url = generateUrl(foundDc, 'SetPurchaseIpAddress')
let d = await doRequest(url, auth) let d = await doRequest(url, auth)
...@@ -121,19 +121,17 @@ async function getAllIps() { ...@@ -121,19 +121,17 @@ async function getAllIps() {
let arr = [] let arr = []
d = d.Value d = d.Value
for (let i = 0; i < d.length; i++) { 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]) arr.push(d[i])
} }
return arr return arr
} }
async function canAddFloatingIp() async function canAddFloatingIp() {
{ let ips = await getAllIps()
let ips=await getAllIps() let count = 0
let count=0 for (let i = 0; i < ips.length; i++) {
for (let i=0;i<ips.length;i++)
{
} }
} }
...@@ -145,7 +143,7 @@ async function deleteAllIps() { ...@@ -145,7 +143,7 @@ async function deleteAllIps() {
for (let i = 0; i < ips.length; i++) { for (let i = 0; i < ips.length; i++) {
if (ips[i].Value !== masterIp) { if (ips[i].Value !== masterIp) {
let d = await deleteIp(foundDc, ips[i].ResourceId) let d = await deleteIp(foundDc, ips[i].ResourceId)
console.log(d) // console.log(d)
} }
} }
...@@ -190,7 +188,7 @@ async function attachedToServerByIp(ip) { ...@@ -190,7 +188,7 @@ async function attachedToServerByIp(ip) {
for (let i = 0; i < ips.length; i++) { for (let i = 0; i < ips.length; i++) {
if (ips[i].Value === ip) { if (ips[i].Value === ip) {
console.log(ips[i]) // console.log(ips[i])
await attachedToServer(foundDc, ips[i].ResourceId) await attachedToServer(foundDc, ips[i].ResourceId)
break break
} }
...@@ -214,16 +212,12 @@ async function RemovedByIp(ip) { ...@@ -214,16 +212,12 @@ async function RemovedByIp(ip) {
} }
} }
async function deleteIp(id) { async function deleteIp(id) {
try { try {
await unAttachedToServer(foundDc, id) await unAttachedToServer(foundDc, id)
} } catch (e) {
catch (e) {
} }
...@@ -260,8 +254,7 @@ async function doRequest(url, body) { ...@@ -260,8 +254,7 @@ async function doRequest(url, body) {
if (error) reject('Problem ->' + options.url) if (error) reject('Problem ->' + options.url)
try { try {
console.log(url)
console.log(body)
resolve(JSON.parse(body)) resolve(JSON.parse(body))
} catch (e) { } 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