Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
fogbow
fogbow4j
Commits
e04310a0
Commit
e04310a0
authored
Apr 15, 2015
by
Abmar Barros
Browse files
deleting request and instance
parent
b73350c3
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/fogbowcloud/cli/FogbowClient.java
View file @
e04310a0
...
...
@@ -23,10 +23,12 @@ public class FogbowClient {
private
String
managerHost
;
private
Integer
managerPort
;
private
HttpWrapper
httpWrapper
;
private
String
federationAuthToken
;
public
FogbowClient
(
String
managerHost
,
Integer
managerPort
)
{
public
FogbowClient
(
String
managerHost
,
Integer
managerPort
,
String
federationAuthToken
)
{
this
.
managerHost
=
managerHost
;
this
.
managerPort
=
managerPort
;
this
.
federationAuthToken
=
federationAuthToken
;
this
.
httpWrapper
=
new
HttpWrapper
();
}
...
...
@@ -35,22 +37,20 @@ public class FogbowClient {
}
public
String
createRequest
(
int
minCPU
,
int
minRAM
,
String
imageName
,
String
pubKeyFilePath
,
String
federationAuthToken
,
String
localAuthToken
)
throws
Exception
{
String
imageName
,
String
pubKeyFilePath
,
String
localAuthToken
)
throws
Exception
{
return
createRequests
(
1
,
true
,
null
,
"Glue2vCPU >= "
+
minCPU
+
" Glue2RAM >= "
+
minRAM
,
imageName
,
pubKeyFilePath
,
federationAuthToken
,
localAuthToken
);
imageName
,
pubKeyFilePath
,
localAuthToken
);
}
public
String
createRequest
(
String
requirements
,
String
imageName
,
String
pubKeyFilePath
,
String
federationAuthToken
,
String
localAuthToken
)
throws
Exception
{
String
imageName
,
String
pubKeyFilePath
,
String
localAuthToken
)
throws
Exception
{
return
createRequests
(
1
,
true
,
null
,
requirements
,
imageName
,
pubKeyFilePath
,
federationAuthToken
,
localAuthToken
);
imageName
,
pubKeyFilePath
,
localAuthToken
);
}
public
String
createRequests
(
int
instanceCount
,
boolean
isOneTime
,
String
flavour
,
String
requirements
,
String
imageName
,
String
pubKeyFilePath
,
String
federationAuthToken
,
String
localAuthToken
)
throws
Exception
{
String
localAuthToken
)
throws
Exception
{
String
pubKey
=
null
;
if
(
pubKeyFilePath
!=
null
)
{
...
...
@@ -102,16 +102,16 @@ public class FogbowClient {
return
getRequestId
(
response
);
}
public
Request
getRequest
(
String
requestId
,
String
federationAuthToken
)
throws
Exception
{
public
Request
getRequest
(
String
requestId
)
throws
Exception
{
String
getRequestResponse
=
httpWrapper
.
doRequest
(
"get"
,
getManagerURL
()
+
"/"
+
RequestConstants
.
TERM
+
"/"
+
requestId
,
federationAuthToken
,
new
LinkedList
<
Header
>());
Map
<
String
,
String
>
attrs
=
parseAttributes
(
getRequestResponse
);
String
instanceId
=
attrs
.
get
(
FOGBOW_INSTANCE_ID_TERM
);
return
new
Request
(
instanceId
);
return
new
Request
(
requestId
,
instanceId
);
}
public
Instance
getInstance
(
String
instanceId
,
String
federationAuthToken
)
throws
Exception
{
public
Instance
getInstance
(
String
instanceId
)
throws
Exception
{
String
instanceInfoStr
=
httpWrapper
.
doRequest
(
"get"
,
getManagerURL
()
+
"/compute/"
+
instanceId
,
federationAuthToken
,
new
LinkedList
<
Header
>());
...
...
@@ -125,6 +125,18 @@ public class FogbowClient {
return
new
Instance
(
publicAddressSplit
[
0
],
Integer
.
parseInt
(
publicAddressSplit
[
1
]));
}
public
void
deleteRequest
(
String
requestId
)
throws
Exception
{
httpWrapper
.
doRequest
(
"delete"
,
getManagerURL
()
+
"/"
+
RequestConstants
.
TERM
+
"/"
+
requestId
,
federationAuthToken
,
new
LinkedList
<
Header
>());
}
public
void
deleteInstance
(
String
instanceId
)
throws
Exception
{
httpWrapper
.
doRequest
(
"delete"
,
getManagerURL
()
+
"/compute/"
+
instanceId
,
federationAuthToken
,
new
LinkedList
<
Header
>());
}
private
static
String
getRequestId
(
String
createRequestResponse
)
{
String
[]
requestRes
=
createRequestResponse
.
split
(
":"
);
String
[]
requestId
=
requestRes
[
requestRes
.
length
-
1
].
split
(
"/"
);
...
...
@@ -147,4 +159,5 @@ public class FogbowClient {
}
return
atts
;
}
}
src/main/java/org/fogbowcloud/cli/Request.java
View file @
e04310a0
...
...
@@ -2,12 +2,18 @@ package org.fogbowcloud.cli;
public
class
Request
{
private
String
id
;
private
String
instanceId
;
public
Request
(
String
instanceId
)
{
public
Request
(
String
id
,
String
instanceId
)
{
this
.
id
=
id
;
this
.
instanceId
=
instanceId
;
}
public
String
getId
()
{
return
id
;
}
public
String
getInstanceId
()
{
return
instanceId
;
}
...
...
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