⚲
Project
Profile
Help
Tour this page
Frequent Planio Questions
Learning Resources
Sign in
Register
Switch Planio account
Open in Planio App
Share current page
Search
:
Projects
All Projects
Help
Tour this page
Frequent Planio Questions
Learning Resources
Sign in
Register
Switch Planio account
Open in Planio App
Share current page
Pulp
Overview
Roadmap
Issues
Gantt
Agile board
Calendar
Wiki
Repository
Download (1.49 KB)
Issue #2170
ยป test.py
martin@hatchlane.com
, 04/25/2016 04:37 PM
#!/bin/env python
import
json
import
requests
from
requests.auth
import
HTTPBasicAuth
# We know it's insecure, don't warn:
from
requests.packages.urllib3.exceptions
import
InsecureRequestWarning
requests
.
packages
.
urllib3
.
disable_warnings
(
InsecureRequestWarning
)
# Repos to copy from to
from_repo
=
'centos7-live-debug'
to_repo
=
'centos7-development-debug'
base_url
=
'https://localhost/pulp/api/v2'
auth
=
HTTPBasicAuth
(
'admin'
,
'admin'
)
filters
=
{
"unit"
:
{
'$or'
:
[
{
"name"
:
{
"$not"
:
'^(ipa.*)(?<!fonts)$'
}
},
{
"version"
:
'4.1.0'
}
]
}
}
# Search Units
search_data
=
{
"criteria"
:
{
"fields"
:
{
"unit"
:
[
"name"
,
"version"
,
"release"
,
"arch"
]
},
"filters"
:
filters
,
"type_ids"
:
[
"rpm"
]
}
}
r
=
requests
.
post
(
"%s/repositories/%s/search/units/"
%
(
base_url
,
from_repo
),
verify
=
False
,
auth
=
auth
,
data
=
json
.
dumps
(
search_data
))
print
"Search Status: %i
\n
"
%
r
.
status_code
d
=
json
.
loads
(
r
.
text
)
for
pkg
in
d
:
if
'metadata'
in
pkg
:
m
=
pkg
[
'metadata'
]
print
"%s-%s-%s.%s"
%
(
m
[
'name'
],
m
[
'version'
],
m
[
'release'
],
m
[
'arch'
])
print
"
\n
==================
\n
"
# Assosiate Units
assoc_data
=
{
"source_repo_id"
:
from_repo
,
"criteria"
:
{
"filters"
:
filters
}
}
r
=
requests
.
post
(
"%s/repositories/%s/actions/associate/"
%
(
base_url
,
to_repo
),
verify
=
False
,
auth
=
auth
,
data
=
json
.
dumps
(
assoc_data
))
print
"Associate Status: %i"
%
r
.
status_code
d
=
json
.
loads
(
r
.
text
)
print
json
.
dumps
(
d
,
indent
=
2
)
(1-1/1)
Loading...