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

init

parent 5554ee7b
...@@ -76,16 +76,16 @@ async function getDetailsofServer(dc, id) { ...@@ -76,16 +76,16 @@ async function getDetailsofServer(dc, id) {
} }
async function createFloatingIp(dc) { async function createFloatingIp(dc) {
let url = generateUrl(dc, 'SetPurchaseIpAddress') let url = generateUrl(foundDc, 'SetPurchaseIpAddress')
let d = await doRequest(url, auth) let d = await doRequest(url, auth)
d = d.Value d = d.Value
await attachedToServer(dc, d.ResourceId) await attachedToServer(foundDc, d.ResourceId)
return d return d
} }
async function getAllIps(dc) { async function getAllIps(dc) {
let url = generateUrl(dc, 'GetPurchasedIpAddresses') let url = generateUrl(foundDc, 'GetPurchasedIpAddresses')
let d = await doRequest(url, auth) let d = await doRequest(url, auth)
...@@ -93,12 +93,12 @@ async function getAllIps(dc) { ...@@ -93,12 +93,12 @@ async function getAllIps(dc) {
} }
async function deleteAllIps(dc) { async function deleteAllIps(dc) {
let ips=await getAllIps(dc) let ips=await getAllIps(foundDc)
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(dc,ips[i].ResourceId) let d=await deleteIp(foundDc,ips[i].ResourceId)
console.log(d) console.log(d)
} }
...@@ -112,7 +112,7 @@ async function deleteAllIps(dc) { ...@@ -112,7 +112,7 @@ async function deleteAllIps(dc) {
async function attachedToServer(dc, resourceId) { async function attachedToServer(dc, resourceId) {
let url = generateUrl(dc, 'SetEnqueueAssociateIpAddress') let url = generateUrl(foundDc, 'SetEnqueueAssociateIpAddress')
let body = auth let body = auth
body.IpRequest = {NetworkAdapterId: networkId, IpAddressResourceIds: [resourceId]} body.IpRequest = {NetworkAdapterId: networkId, IpAddressResourceIds: [resourceId]}
...@@ -125,7 +125,7 @@ async function attachedToServer(dc, resourceId) { ...@@ -125,7 +125,7 @@ async function attachedToServer(dc, resourceId) {
async function unAttachedToServer(dc, resourceId) { async function unAttachedToServer(dc, resourceId) {
let url = generateUrl(dc, 'SetEnqueueDeassociateIpAddress') let url = generateUrl(foundDc, 'SetEnqueueDeassociateIpAddress')
let body = auth let body = auth
body.IpRequest = {NetworkAdapterId: networkId, IpAddressResourceIds: [resourceId]} body.IpRequest = {NetworkAdapterId: networkId, IpAddressResourceIds: [resourceId]}
...@@ -138,13 +138,13 @@ async function unAttachedToServer(dc, resourceId) { ...@@ -138,13 +138,13 @@ async function unAttachedToServer(dc, resourceId) {
async function attachedToServerByIp(dc, ip) { async function attachedToServerByIp(dc, ip) {
let ips=await getAllIps(dc) let ips=await getAllIps(foundDc)
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)
{ {
await attachedToServer(dc,ips[i].ResourceId) await attachedToServer(foundDc,ips[i].ResourceId)
break break
} }
} }
...@@ -163,7 +163,7 @@ async function RemovedByIp(dc, ip) { ...@@ -163,7 +163,7 @@ async function RemovedByIp(dc, ip) {
{ {
if (ips[i].Value === ip) if (ips[i].Value === ip)
{ {
await deleteIp(dc,ips[i].ResourceId) await deleteIp(foundDc,ips[i].ResourceId)
break break
} }
} }
...@@ -175,8 +175,8 @@ async function RemovedByIp(dc, ip) { ...@@ -175,8 +175,8 @@ async function RemovedByIp(dc, ip) {
} }
async function deleteIp(dc, id) { async function deleteIp(dc, id) {
await unAttachedToServer(dc, id) await unAttachedToServer(foundDc, id)
let url = generateUrl(dc, 'SetRemoveIpAddress') let url = generateUrl(foundDc, 'SetRemoveIpAddress')
let body = auth let body = auth
body.IpAddressResourceId = id body.IpAddressResourceId = id
let d = await doRequest(url, body) let d = await doRequest(url, body)
......
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