Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
35ca047f
Unverified
Commit
35ca047f
authored
Jan 14, 2025
by
Jakob Görgen
Browse files
symphony/client: added resource group client
parent
733acead
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
6 deletions
+32
-6
symphony/client/simbricks/client/client.py
symphony/client/simbricks/client/client.py
+19
-0
symphony/client/simbricks/client/provider.py
symphony/client/simbricks/client/provider.py
+13
-6
No files found.
symphony/client/simbricks/client/client.py
View file @
35ca047f
...
...
@@ -368,6 +368,25 @@ class SimBricksClient:
return
await
resp
.
json
()
class
ResourceGroupClient
:
def
__init__
(
self
,
ns_client
)
->
None
:
self
.
_ns_client
:
NSClient
=
ns_client
async
def
create_rg
(
self
,
label
:
str
,
available_cores
:
int
,
available_memory
:
int
)
->
dict
:
obj
=
{
"label"
:
label
,
"available_cores"
:
available_cores
,
"available_memory"
:
available_memory
}
async
with
self
.
_ns_client
.
post
(
url
=
"/resource_group"
,
json
=
obj
)
as
resp
:
return
await
resp
.
json
()
async
def
get_rg
(
self
,
rg_id
:
int
)
->
dict
:
async
with
self
.
_ns_client
.
get
(
url
=
f
"/resource_group/
{
rg_id
}
"
)
as
resp
:
return
await
resp
.
json
()
async
def
filter_get_rg
(
self
)
->
dict
:
# TODO: add filtering object...
async
with
self
.
_ns_client
.
get
(
url
=
f
"/resource_group"
)
as
resp
:
return
await
resp
.
json
()
class
RunnerClient
:
def
__init__
(
self
,
ns_client
,
id
:
int
)
->
None
:
...
...
symphony/client/simbricks/client/provider.py
View file @
35ca047f
...
...
@@ -20,7 +20,7 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from
.client
import
BaseClient
,
AdminClient
,
NSClient
,
SimBricksClient
,
RunnerClient
from
.client
import
BaseClient
,
AdminClient
,
NSClient
,
SimBricksClient
,
RunnerClient
,
ResourceGroupClient
from
.settings
import
client_settings
...
...
@@ -33,36 +33,43 @@ class ClientProvider:
self
.
_ns_client
:
NSClient
|
None
=
None
self
.
_simbricks_client
:
SimBricksClient
|
None
=
None
self
.
_runner_client
:
RunnerClient
|
None
=
None
self
.
_resource_group_client
:
ResourceGroupClient
|
None
=
None
@
property
def
base_client
(
self
):
def
base_client
(
self
)
->
BaseClient
:
if
self
.
_base_client
is
None
:
self
.
_base_client
=
BaseClient
()
return
self
.
_base_client
@
property
def
admin_client
(
self
):
def
admin_client
(
self
)
->
AdminClient
:
if
self
.
_admin_client
is
None
:
self
.
_admin_client
=
AdminClient
(
base_client
=
self
.
base_client
)
return
self
.
_admin_client
@
property
def
ns_client
(
self
):
def
ns_client
(
self
)
->
NSClient
:
if
self
.
_ns_client
is
None
:
self
.
_ns_client
=
NSClient
(
base_client
=
self
.
base_client
,
namespace
=
self
.
namespace
)
return
self
.
_ns_client
@
property
def
simbricks_client
(
self
):
def
simbricks_client
(
self
)
->
SimBricksClient
:
if
self
.
_simbricks_client
is
None
:
self
.
_simbricks_client
=
SimBricksClient
(
self
.
ns_client
)
return
self
.
_simbricks_client
@
property
def
runner_client
(
self
):
def
runner_client
(
self
)
->
RunnerClient
:
if
self
.
_runner_client
is
None
:
self
.
_runner_client
=
RunnerClient
(
self
.
ns_client
,
id
=
self
.
runner_id
)
return
self
.
_runner_client
@
property
def
resource_group_client
(
self
)
->
ResourceGroupClient
:
if
self
.
_resource_group_client
is
None
:
self
.
_resource_group_client
=
ResourceGroupClient
(
self
.
ns_client
)
return
self
.
_resource_group_client
client_provider
=
ClientProvider
()
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