Commit 9b1ab22d authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 0f52ecbf
......@@ -9,9 +9,10 @@ let networkId
let serverId
let initData = false
//init()
test()
async function test() {
masterIp = '195.231.67.55'
for (let i = 0; i < AvailDc.length; i++) {
let servers = await getAllServers(AvailDc[i])
......@@ -42,6 +43,9 @@ async function test() {
console.log('networkId ->' + networkId)
console.log('serverId ->' + serverId)
let a=await RemovedByIp('195.231.67.35')
console.log(a)
}
......@@ -101,6 +105,7 @@ async function getDetailsofServer(dc, id) {
}
async function createFloatingIp() {
let ips=await getAllIps()
let url = generateUrl(foundDc, 'SetPurchaseIpAddress')
let d = await doRequest(url, auth)
......@@ -123,6 +128,16 @@ async function getAllIps() {
return arr
}
async function canAddFloatingIp()
{
let ips=await getAllIps()
let count=0
for (let i=0;i<ips.length;i++)
{
}
}
async function deleteAllIps() {
......@@ -175,6 +190,7 @@ async function attachedToServerByIp(ip) {
for (let i = 0; i < ips.length; i++) {
if (ips[i].Value === ip) {
console.log(ips[i])
await attachedToServer(foundDc, ips[i].ResourceId)
break
}
......@@ -192,19 +208,25 @@ async function RemovedByIp(ip) {
for (let i = 0; i < ips.length; i++) {
if (ips[i].Value === ip && ip !== masterIp) {
await deleteIp(foundDc, ips[i].ResourceId)
break
return await deleteIp(foundDc, ips[i].ResourceId)
}
}
return 'Done'
}
async function deleteIp(id) {
await unAttachedToServer(foundDc, id)
try {
await unAttachedToServer(foundDc, id)
}
catch (e) {
}
let url = generateUrl(foundDc, 'SetRemoveIpAddress')
let body = auth
body.IpAddressResourceId = id
......@@ -238,8 +260,8 @@ async function doRequest(url, body) {
if (error) reject('Problem ->' + options.url)
try {
console.log(url)
console.log(body)
resolve(JSON.parse(body))
} catch (e) {
......
console.log(ip)
\ No newline at end of file
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