Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
S
scvmm_client_py
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nova
scvmm_client_py
Commits
9f7c0df3
Commit
9f7c0df3
authored
Sep 27, 2019
by
Sigmund Augdal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added method to get vm by mac
parent
fbc9b557
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
scvmm_client/odata.py
scvmm_client/odata.py
+8
-3
No files found.
scvmm_client/odata.py
View file @
9f7c0df3
...
@@ -97,7 +97,7 @@ class Client(object):
...
@@ -97,7 +97,7 @@ class Client(object):
self
.
principal
=
principal
self
.
principal
=
principal
def
_format_url
(
self
,
resource
,
query
=
None
,
args
=
None
,
subresource
=
None
,
def
_format_url
(
self
,
resource
,
query
=
None
,
args
=
None
,
subresource
=
None
,
expand
=
None
):
expand
=
None
,
raw_filter
=
None
):
url
=
self
.
baseurl
url
=
self
.
baseurl
if
self
.
subscription
:
if
self
.
subscription
:
url
+=
"/"
+
self
.
subscription
url
+=
"/"
+
self
.
subscription
...
@@ -113,6 +113,8 @@ class Client(object):
...
@@ -113,6 +113,8 @@ class Client(object):
if
query
:
if
query
:
argstr
=
" and "
.
join
((
"{key} eq {value}"
.
format
(
key
=
key
,
value
=
type_encode_argvalue
(
query
[
key
]))
for
key
in
query
))
argstr
=
" and "
.
join
((
"{key} eq {value}"
.
format
(
key
=
key
,
value
=
type_encode_argvalue
(
query
[
key
]))
for
key
in
query
))
fragments
[
"$filter"
]
=
argstr
fragments
[
"$filter"
]
=
argstr
elif
raw_filter
:
fragments
[
'$filter'
]
=
raw_filter
if
expand
:
if
expand
:
fragments
[
"$expand"
]
=
expand
fragments
[
"$expand"
]
=
expand
if
fragments
:
if
fragments
:
...
@@ -158,8 +160,8 @@ class Client(object):
...
@@ -158,8 +160,8 @@ class Client(object):
collections
=
self
.
_do_request
(
url
)
collections
=
self
.
_do_request
(
url
)
return
(
collection
for
collection
in
collections
.
xpath
(
'/b:service/b:workspace/b:collection/atom:title/text()'
,
namespaces
=
namespaces
))
return
(
collection
for
collection
in
collections
.
xpath
(
'/b:service/b:workspace/b:collection/atom:title/text()'
,
namespaces
=
namespaces
))
def
query_collection
(
self
,
collection
,
query
=
None
,
expand
=
None
,
**
kw_args
):
def
query_collection
(
self
,
collection
,
query
=
None
,
expand
=
None
,
raw_filter
=
None
,
**
kw_args
):
url
=
self
.
_format_url
(
collection
,
query
,
kw_args
,
expand
=
expand
)
url
=
self
.
_format_url
(
collection
,
query
,
kw_args
,
expand
=
expand
,
raw_filter
=
raw_filter
)
result
=
[]
result
=
[]
while
url
:
while
url
:
collection
=
self
.
_do_request
(
url
)
collection
=
self
.
_do_request
(
url
)
...
@@ -386,6 +388,9 @@ class VMMClient(Client):
...
@@ -386,6 +388,9 @@ class VMMClient(Client):
def
restore_checkpoint
(
self
,
stampid
,
_id
):
def
restore_checkpoint
(
self
,
stampid
,
_id
):
self
.
update_entry
(
"VMCheckPoints"
,
stampid
,
_id
,
VMCheckPointAction
=
"Restore"
)
self
.
update_entry
(
"VMCheckPoints"
,
stampid
,
_id
,
VMCheckPointAction
=
"Restore"
)
def
get_vm_by_mac
(
self
,
stampid
,
mac
):
return
self
.
query_collection
(
"VirtualMachines"
,
raw_filter
=
"VirtualNetworkAdapters/any(nic: nic/MACAddress eq '{}')"
)
def
get_config
():
def
get_config
():
cfg
=
SafeConfigParser
()
cfg
=
SafeConfigParser
()
...
...
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