Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
noc
noc
Commits
b5365f43
Commit
b5365f43
authored
Aug 19, 2022
by
Michael R
Browse files
Add ability to use multiple models with same profile to workflow-migrate command
parent
e1e328bf
Pipeline
#37259
passed with stages
in 15 minutes and 45 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
commands/workflow.py
View file @
b5365f43
...
...
@@ -28,7 +28,7 @@ class Command(BaseCommand):
"phone.PhoneRangeProfile"
:
"phone.PhoneRange"
,
"vc.L2DomainProfile"
:
"vc.L2Domain"
,
"vc.VLANProfile"
:
"vc.VLAN"
,
"vc.VPNProfile"
:
"vc.VPN"
,
"vc.VPNProfile"
:
[
"vc.VPN"
,
"ip.VRF"
],
"inv.SensorProfile"
:
"inv.Sensor"
,
"pm.AgentProfile"
:
"pm.Agent"
,
"sa.ServiceProfile"
:
"sa.Service"
,
...
...
@@ -76,7 +76,10 @@ class Command(BaseCommand):
if
not
wfm
:
self
.
die
(
"Invalid migration %s"
%
wfm
.
name
)
pmodel
=
get_model
(
profile
)
imodel
=
get_model
(
self
.
PROFILE_MAP
[
profile
])
models
=
self
.
PROFILE_MAP
[
profile
]
if
isinstance
(
models
,
str
):
models
=
[
models
]
imodels
=
[
get_model
(
model
)
for
model
in
models
]
for
pid
in
profiles
:
p
=
pmodel
.
get_by_id
(
pid
)
if
not
p
:
...
...
@@ -87,11 +90,14 @@ class Command(BaseCommand):
self
.
print
(
"No translations"
)
continue
for
ostate
in
tr
:
c
=
imodel
.
objects
.
filter
(
state
=
ostate
.
id
,
profile
=
pid
).
count
()
self
.
print
(
" %s -> %s: %d records"
%
(
ostate
,
tr
[
ostate
],
c
))
if
c
and
not
dry_run
:
for
o
in
imodel
.
objects
.
filter
(
state
=
ostate
.
id
,
profile
=
pid
):
o
.
set_state
(
tr
[
ostate
])
for
imodel
in
imodels
:
c
=
imodel
.
objects
.
filter
(
state
=
ostate
.
id
,
profile
=
pid
).
count
()
self
.
print
(
f
"
{
ostate
}
->
{
tr
[
ostate
]
}
:
{
c
}
records in model '
{
imodel
.
__name__
}
'"
)
if
c
and
not
dry_run
:
for
o
in
imodel
.
objects
.
filter
(
state
=
ostate
.
id
,
profile
=
pid
):
o
.
set_state
(
tr
[
ostate
])
def
handle_expire
(
self
,
dry_run
=
False
,
model
=
None
,
*
args
,
**
kwargs
):
model
=
model
or
self
.
EXPIRE_MODELS
...
...
Andrey Vertiprahov
@aversant
mentioned in commit
2c0d7169
·
Aug 19, 2022
mentioned in commit
2c0d7169
mentioned in commit 2c0d7169d9442300c62d911546ea263ca2ce3cce
Toggle commit list
Andrey Vertiprahov
@aversant
mentioned in merge request
!6589 (merged)
·
Aug 19, 2022
mentioned in merge request
!6589 (merged)
mentioned in merge request !6589
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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