author | Bart Smaalders <Bart.Smaalders@Sun.COM> |
Wed, 18 Nov 2009 15:53:48 -0800 | |
changeset 1505 | cc598d70bbbe |
parent 1504 | 265a1d6b86bd |
child 1516 | 8c950a3b4171 |
permissions | -rw-r--r-- |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.4 |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
2 |
# |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
4 |
# |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
8 |
# |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
13 |
# |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
19 |
# |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
21 |
# |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
22 |
|
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
23 |
# |
835
34ec4401dc48
686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents:
786
diff
changeset
|
24 |
# Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
25 |
# Use is subject to license terms. |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
26 |
# |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
27 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
28 |
import copy |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
29 |
import os |
1072
66ce6aa346d7
8132 __licenses should use StringIO
Rich Burridge <rich.burridge@sun.com>
parents:
1053
diff
changeset
|
30 |
import StringIO |
1032
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
31 |
import sys |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
32 |
import urllib |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
33 |
|
1019
e61c57c724c9
7663 disable_fmri should be synchronous
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
996
diff
changeset
|
34 |
import pkg.client.actuator as actuator |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
35 |
import pkg.client.api_errors as api_errors |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
36 |
import pkg.client.bootenv as bootenv |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
37 |
import pkg.client.history as history |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
38 |
import pkg.client.image as image |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
39 |
import pkg.client.indexer as indexer |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
40 |
import pkg.client.publisher as publisher |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
41 |
import pkg.client.query_parser as query_p |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
42 |
import pkg.fmri as fmri |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
43 |
import pkg.misc as misc |
1257
d911e4542c41
9025 pkg.client.api needs to use p5i module
Shawn Walker <srw@sun.com>
parents:
1256
diff
changeset
|
44 |
import pkg.p5i as p5i |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
45 |
import pkg.search_errors as search_errors |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
46 |
import pkg.nrlock |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
47 |
|
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
48 |
from pkg.client.imageplan import EXECUTED_OK |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
49 |
from pkg.client import global_settings |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
50 |
|
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
51 |
CURRENT_API_VERSION = 24 |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
52 |
CURRENT_P5I_VERSION = 1 |
696
6bbfd2dece6f
4371 user-agent string needs to be different for different client front-ends
Danek Duvall <danek.duvall@sun.com>
parents:
688
diff
changeset
|
53 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
54 |
logger = global_settings.logger |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
55 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
56 |
class ImageInterface(object): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
57 |
"""This class presents an interface to images that clients may use. |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
58 |
There is a specific order of methods which must be used to install |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
59 |
or uninstall packages, or update an image. First, plan_install, |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
60 |
plan_uninstall, plan_update_all or plan_change_variant must be |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
61 |
called. After that method completes successfully, describe may be |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
62 |
called, and prepare must be called. Finally, execute_plan may be |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
63 |
called to implement the previous created plan. The other methods |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
64 |
do not have an ordering imposed upon them, and may be used as |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
65 |
needed. Cancel may only be invoked while a cancelable method is |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
66 |
running.""" |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
67 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
68 |
# Constants used to reference specific values that info can return. |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
69 |
INFO_FOUND = 0 |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
70 |
INFO_MISSING = 1 |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
71 |
INFO_MULTI_MATCH = 2 |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
72 |
INFO_ILLEGALS = 3 |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
73 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
74 |
# Private constants used for tracking which type of plan was made. |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
75 |
__INSTALL = 1 |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
76 |
__UNINSTALL = 2 |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
77 |
__IMAGE_UPDATE = 3 |
696
6bbfd2dece6f
4371 user-agent string needs to be different for different client front-ends
Danek Duvall <danek.duvall@sun.com>
parents:
688
diff
changeset
|
78 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
79 |
def __init__(self, img_path, version_id, progresstracker, |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
80 |
cancel_state_callable, pkg_client_name): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
81 |
"""Constructs an ImageInterface. img_path should point to an |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
82 |
existing image. version_id indicates the version of the api |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
83 |
the client is expecting to use. progresstracker is the |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
84 |
progresstracker the client wants the api to use for UI |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
85 |
callbacks. cancel_state_callable is a function which the client |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
86 |
wishes to have called each time whether the operation can be |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
87 |
canceled changes. It can raise VersionException and |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
88 |
ImageNotFoundException.""" |
696
6bbfd2dece6f
4371 user-agent string needs to be different for different client front-ends
Danek Duvall <danek.duvall@sun.com>
parents:
688
diff
changeset
|
89 |
|
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
90 |
compatible_versions = set([CURRENT_API_VERSION]) |
696
6bbfd2dece6f
4371 user-agent string needs to be different for different client front-ends
Danek Duvall <danek.duvall@sun.com>
parents:
688
diff
changeset
|
91 |
|
598
c53f6107fdb6
2863 pkg install should have a way to disable indexing
Brock Pytlik <bpytlik@sun.com>
parents:
594
diff
changeset
|
92 |
if version_id not in compatible_versions: |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
93 |
raise api_errors.VersionException(CURRENT_API_VERSION, |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
94 |
version_id) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
95 |
|
696
6bbfd2dece6f
4371 user-agent string needs to be different for different client front-ends
Danek Duvall <danek.duvall@sun.com>
parents:
688
diff
changeset
|
96 |
# The image's History object will use client_name from |
6bbfd2dece6f
4371 user-agent string needs to be different for different client front-ends
Danek Duvall <danek.duvall@sun.com>
parents:
688
diff
changeset
|
97 |
# global_settings, but if the program forgot to set it, |
6bbfd2dece6f
4371 user-agent string needs to be different for different client front-ends
Danek Duvall <danek.duvall@sun.com>
parents:
688
diff
changeset
|
98 |
# we'll go ahead and do so here. |
6bbfd2dece6f
4371 user-agent string needs to be different for different client front-ends
Danek Duvall <danek.duvall@sun.com>
parents:
688
diff
changeset
|
99 |
if global_settings.client_name is None: |
6bbfd2dece6f
4371 user-agent string needs to be different for different client front-ends
Danek Duvall <danek.duvall@sun.com>
parents:
688
diff
changeset
|
100 |
global_settings.client_name = pkg_client_name |
6bbfd2dece6f
4371 user-agent string needs to be different for different client front-ends
Danek Duvall <danek.duvall@sun.com>
parents:
688
diff
changeset
|
101 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
102 |
if isinstance(img_path, basestring): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
103 |
# Store this for reset(). |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
104 |
self.__img_path = img_path |
1370
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1360
diff
changeset
|
105 |
self.__img = image.Image(img_path, |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
106 |
progtrack=progresstracker) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
107 |
elif isinstance(img_path, image.Image): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
108 |
# This is a temporary, special case for client.py |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
109 |
# until the image api is complete. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
110 |
self.__img = img_path |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
111 |
self.__img_path = img_path.get_root() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
112 |
else: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
113 |
# API consumer passed an unknown type for img_path. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
114 |
raise TypeError(_("Unknown img_path type.")) |
1242
f6aa06e1c391
6758 api should recreate image object on reset
Shawn Walker <srw@sun.com>
parents:
1240
diff
changeset
|
115 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
116 |
self.__progresstracker = progresstracker |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
117 |
self.__cancel_state_callable = cancel_state_callable |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
118 |
self.__plan_type = None |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
119 |
self.__plan_desc = None |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
120 |
self.__prepared = False |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
121 |
self.__executed = False |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
122 |
self.__be_name = None |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
123 |
self.__can_be_canceled = False |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
124 |
self.__canceling = False |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
125 |
self.__activity_lock = pkg.nrlock.NRLock() |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
126 |
|
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
127 |
@property |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
128 |
def img(self): |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
129 |
"""Private; public access to this property will be removed at |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
130 |
a later date. Do not use.""" |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
131 |
return self.__img |
884
d780afc023ff
3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents:
838
diff
changeset
|
132 |
|
1255
13914487fd06
8854 access to ImageInterface img root desired
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
133 |
@property |
13914487fd06
8854 access to ImageInterface img root desired
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
134 |
def root(self): |
13914487fd06
8854 access to ImageInterface img root desired
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
135 |
"""The absolute pathname of the filesystem root of the image. |
13914487fd06
8854 access to ImageInterface img root desired
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
136 |
This property is read-only.""" |
13914487fd06
8854 access to ImageInterface img root desired
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
137 |
if not self.__img: |
13914487fd06
8854 access to ImageInterface img root desired
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
138 |
return None |
13914487fd06
8854 access to ImageInterface img root desired
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
139 |
return self.__img.root |
13914487fd06
8854 access to ImageInterface img root desired
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
140 |
|
884
d780afc023ff
3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents:
838
diff
changeset
|
141 |
@staticmethod |
d780afc023ff
3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents:
838
diff
changeset
|
142 |
def check_be_name(be_name): |
1076
db86977aa656
8048 image update doesn't check to see if specified be-name already exists
Rich Burridge <rich.burridge@sun.com>
parents:
1072
diff
changeset
|
143 |
bootenv.BootEnv.check_be_name(be_name) |
1080
147a665c552c
8394 image-update without a --be-name fails.
Rich Burridge <rich.burridge@sun.com>
parents:
1076
diff
changeset
|
144 |
return True |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
145 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
146 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
147 |
def __cert_verify(self, log_op_end=None): |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
148 |
"""Verify validity of certificates. Any |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
149 |
api_errors.ExpiringCertificate exceptions are caught |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
150 |
here, a message is displayed, and execution continues. |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
151 |
All other exceptions will be passed to the calling |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
152 |
context. The caller can also set log_op_end to a list |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
153 |
of exceptions that should result in a call to |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
154 |
self.log_operation_end() before the exception is passed |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
155 |
on.""" |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
156 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
157 |
if log_op_end == None: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
158 |
log_op_end = [] |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
159 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
160 |
# we always explicitly handle api_errors.ExpiringCertificate |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
161 |
assert api_errors.ExpiringCertificate not in log_op_end |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
162 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
163 |
try: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
164 |
self.__img.check_cert_validity() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
165 |
except api_errors.ExpiringCertificate, e: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
166 |
logger.error(e) |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
167 |
except: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
168 |
exc_type, exc_value, exc_traceback = sys.exc_info() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
169 |
if exc_type in log_op_end: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
170 |
self.log_operation_end(error=exc_value) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
171 |
raise |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
172 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
173 |
def __refresh_publishers(self): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
174 |
"""Refresh publisher metadata.""" |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
175 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
176 |
# |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
177 |
# Verify validity of certificates before possibly |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
178 |
# attempting network operations. |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
179 |
# |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
180 |
self.__cert_verify() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
181 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
182 |
try: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
183 |
self.__img.refresh_publishers( |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
184 |
progtrack=self.__progresstracker) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
185 |
except KeyboardInterrupt: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
186 |
raise |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
187 |
except api_errors.InvalidDepotResponseException: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
188 |
raise |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
189 |
except: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
190 |
# Since this is not a refresh |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
191 |
# that was explicitly requested, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
192 |
# it doesn't matter if it fails. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
193 |
pass |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
194 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
195 |
def __plan_common_start(self, operation): |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
196 |
"""Start planning an operation. Aquire locks and log |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
197 |
the start of the operation.""" |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
198 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
199 |
self.__activity_lock.acquire() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
200 |
try: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
201 |
self.__set_can_be_canceled(True) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
202 |
if self.__plan_type is not None: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
203 |
raise api_errors.PlanExistsException( |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
204 |
self.__plan_type) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
205 |
except: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
206 |
self.__activity_lock.release() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
207 |
raise |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
208 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
209 |
assert self.__activity_lock._is_owned() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
210 |
self.log_operation_start(operation) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
211 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
212 |
def __plan_common_finish(self): |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
213 |
"""Finish planning an operation.""" |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
214 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
215 |
assert self.__activity_lock._is_owned() |
1503
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
216 |
self.__img.cleanup_downloads() |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
217 |
self.__activity_lock.release() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
218 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
219 |
def __plan_common_exception(self, log_op_end=None): |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
220 |
"""Deal with exceptions that can occur while planning an |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
221 |
operation. Any exceptions generated here are passed |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
222 |
onto the calling context. By default all exceptions |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
223 |
will result in a call to self.log_operation_end() before |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
224 |
they are passed onto the calling context. Optionally, |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
225 |
the caller can specify the exceptions that should result |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
226 |
in a call to self.log_operation_end() by setting |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
227 |
log_op_end.""" |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
228 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
229 |
if log_op_end == None: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
230 |
log_op_end = [] |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
231 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
232 |
# we always explicity handle api_errors.PlanCreationException |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
233 |
assert api_errors.PlanCreationException not in log_op_end |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
234 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
235 |
exc_type, exc_value, exc_traceback = sys.exc_info() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
236 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
237 |
if exc_type == api_errors.PlanCreationException: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
238 |
self.__set_history_PlanCreationException(exc_value) |
1346
c4d21b460a66
10539 Package Manager hangs after canceling Update All
Padraig O'Briain <padraig.obriain@sun.com>
parents:
1337
diff
changeset
|
239 |
elif not log_op_end or exc_type in log_op_end: |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
240 |
self.log_operation_end(error=exc_value) |
1346
c4d21b460a66
10539 Package Manager hangs after canceling Update All
Padraig O'Briain <padraig.obriain@sun.com>
parents:
1337
diff
changeset
|
241 |
self.__reset_unlock() |
c4d21b460a66
10539 Package Manager hangs after canceling Update All
Padraig O'Briain <padraig.obriain@sun.com>
parents:
1337
diff
changeset
|
242 |
self.__activity_lock.release() |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
243 |
raise |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
244 |
|
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
245 |
def plan_install(self, pkg_list, refresh_catalogs=True, |
598
c53f6107fdb6
2863 pkg install should have a way to disable indexing
Brock Pytlik <bpytlik@sun.com>
parents:
594
diff
changeset
|
246 |
noexecute=False, verbose=False, update_index=True): |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
247 |
"""Contructs a plan to install the packages provided in |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
248 |
pkg_list. pkg_list is a list of packages to install. |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
249 |
refresh_catalogs controls whether the catalogs will |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
250 |
automatically be refreshed. noexecute determines whether the |
1279
12624144230f
10419 client api revisions doc update required
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
251 |
history will be recorded after planning is finished. verbose |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
252 |
controls whether verbose debugging output will be printed to the |
1279
12624144230f
10419 client api revisions doc update required
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
253 |
terminal. Its existence is temporary. It returns a boolean |
12624144230f
10419 client api revisions doc update required
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
254 |
which tells the client whether there is anything to do. It can |
12624144230f
10419 client api revisions doc update required
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
255 |
raise PlanCreationException, PermissionsException and |
12624144230f
10419 client api revisions doc update required
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
256 |
InventoryException. The noexecute argument is included for |
12624144230f
10419 client api revisions doc update required
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
257 |
compatibility with operational history. The hope is it can be |
12624144230f
10419 client api revisions doc update required
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
258 |
removed in the future.""" |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
259 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
260 |
self.__plan_common_start("install") |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
261 |
try: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
262 |
if refresh_catalogs: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
263 |
self.__refresh_publishers() |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
264 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
265 |
self.__img.make_install_plan(pkg_list, |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
266 |
self.__progresstracker, |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
267 |
self.__check_cancelation, noexecute, |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
268 |
verbose=verbose) |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
269 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
270 |
assert self.__img.imageplan |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
271 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
272 |
if self.__canceling: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
273 |
raise api_errors.CanceledException() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
274 |
self.__set_can_be_canceled(False) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
275 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
276 |
if not noexecute: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
277 |
self.__plan_type = self.__INSTALL |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
278 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
279 |
self.__plan_desc = PlanDescription(self.__img.imageplan) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
280 |
if self.__img.imageplan.nothingtodo() or noexecute: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
281 |
self.log_operation_end( |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
282 |
result=history.RESULT_NOTHING_TO_DO) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
283 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
284 |
self.__img.imageplan.update_index = update_index |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
285 |
except: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
286 |
self.__plan_common_exception(log_op_end=[ |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
287 |
api_errors.CanceledException, fmri.IllegalFmri, |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
288 |
Exception]) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
289 |
# NOTREACHED |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
290 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
291 |
self.__plan_common_finish() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
292 |
res = not self.__img.imageplan.nothingtodo() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
293 |
return res |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
294 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
295 |
def plan_uninstall(self, pkg_list, recursive_removal, noexecute=False, |
598
c53f6107fdb6
2863 pkg install should have a way to disable indexing
Brock Pytlik <bpytlik@sun.com>
parents:
594
diff
changeset
|
296 |
verbose=False, update_index=True): |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
297 |
"""Contructs a plan to uninstall the packages provided in |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
298 |
pkg_list. pkg_list is a list of packages to install. |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
299 |
recursive_removal controls whether recursive removal is |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
300 |
allowed. noexecute determines whether the history will be |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
301 |
recorded after planning is finished. verbose controls whether |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
302 |
verbose debugging output will be printed to the terminal. Its |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
303 |
existence is temporary. If there are things to do to complete |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
304 |
the uninstall, it returns True, otherwise it returns False. It |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
305 |
can raise NonLeafPackageException and PlanCreationException.""" |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
306 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
307 |
self.__plan_common_start("uninstall") |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
308 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
309 |
try: |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
310 |
self.__img.make_uninstall_plan(pkg_list, |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
311 |
recursive_removal, self.__progresstracker, |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
312 |
self.__check_cancelation, noexecute, |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
313 |
verbose=verbose) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
314 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
315 |
assert self.__img.imageplan |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
316 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
317 |
if self.__canceling: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
318 |
raise api_errors.CanceledException() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
319 |
self.__set_can_be_canceled(False) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
320 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
321 |
if not noexecute: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
322 |
self.__plan_type = self.__UNINSTALL |
1032
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
323 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
324 |
self.__plan_desc = PlanDescription(self.__img.imageplan) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
325 |
if noexecute: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
326 |
self.log_operation_end( |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
327 |
result=history.RESULT_NOTHING_TO_DO) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
328 |
self.__img.imageplan.update_index = update_index |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
329 |
except: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
330 |
self.__plan_common_exception() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
331 |
# NOTREACHED |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
332 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
333 |
self.__plan_common_finish() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
334 |
res = not self.__img.imageplan.nothingtodo() |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
335 |
return res |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
336 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
337 |
def plan_update_all(self, actual_cmd, refresh_catalogs=True, |
884
d780afc023ff
3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents:
838
diff
changeset
|
338 |
noexecute=False, force=False, verbose=False, update_index=True, |
d780afc023ff
3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents:
838
diff
changeset
|
339 |
be_name=None): |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
340 |
"""Creates a plan to update all packages on the system to the |
1279
12624144230f
10419 client api revisions doc update required
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
341 |
latest known versions. actual_cmd is the command used to start |
12624144230f
10419 client api revisions doc update required
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
342 |
the client. It is used to determine the image to check whether |
12624144230f
10419 client api revisions doc update required
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
343 |
SUNWipkg is up to date. refresh_catalogs controls whether the |
12624144230f
10419 client api revisions doc update required
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
344 |
catalogs will automatically be refreshed. noexecute determines |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
345 |
whether the history will be recorded after planning is finished. |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
346 |
force controls whether update should proceed even if ipkg is not |
1279
12624144230f
10419 client api revisions doc update required
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
347 |
up to date. verbose controls whether verbose debugging output |
12624144230f
10419 client api revisions doc update required
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
348 |
will be printed to the terminal. Its existence is temporary. It |
12624144230f
10419 client api revisions doc update required
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
349 |
returns a tuple of two things. The first is a boolean which |
12624144230f
10419 client api revisions doc update required
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
350 |
tells the client whether there is anything to do. The second |
12624144230f
10419 client api revisions doc update required
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
351 |
tells whether the image is an opensolaris image. It can raise |
12624144230f
10419 client api revisions doc update required
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
352 |
CatalogRefreshException, IpkgOutOfDateException, |
12624144230f
10419 client api revisions doc update required
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
353 |
PlanCreationException and PermissionsException.""" |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
354 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
355 |
self.__plan_common_start("image-update") |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
356 |
try: |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
357 |
self.check_be_name(be_name) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
358 |
self.__be_name = be_name |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
359 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
360 |
if refresh_catalogs: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
361 |
self.__refresh_publishers() |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
362 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
363 |
# If we can find SUNWipkg and SUNWcs in the |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
364 |
# target image, then we assume this is a valid |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
365 |
# opensolaris image, and activate some |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
366 |
# special case behaviors. |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
367 |
opensolaris_image = True |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
368 |
fmris, notfound, illegals = \ |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
369 |
self.__img.installed_fmris_from_args( |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
370 |
["SUNWipkg", "SUNWcs"]) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
371 |
assert(len(illegals) == 0) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
372 |
if notfound: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
373 |
opensolaris_image = False |
625
e46b345645d6
3799 need to start progress tracker going early on
Brock Pytlik <bpytlik@sun.com>
parents:
615
diff
changeset
|
374 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
375 |
if opensolaris_image and not force: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
376 |
try: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
377 |
if not self.__img.ipkg_is_up_to_date( |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
378 |
actual_cmd, |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
379 |
self.__check_cancelation, |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
380 |
noexecute, |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
381 |
refresh_allowed=refresh_catalogs, |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
382 |
progtrack=self.__progresstracker): |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
383 |
raise api_errors.IpkgOutOfDateException() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
384 |
except api_errors.ImageNotFoundException: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
385 |
# Can't do anything in this |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
386 |
# case; so proceed. |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
387 |
pass |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
388 |
|
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
389 |
self.__img.make_update_plan(self.__progresstracker, |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
390 |
self.__check_cancelation, noexecute, |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
391 |
verbose=verbose) |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
392 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
393 |
assert self.__img.imageplan |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
394 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
395 |
if self.__canceling: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
396 |
raise api_errors.CanceledException() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
397 |
self.__set_can_be_canceled(False) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
398 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
399 |
if not noexecute: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
400 |
self.__plan_type = self.__IMAGE_UPDATE |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
401 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
402 |
self.__plan_desc = PlanDescription(self.__img.imageplan) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
403 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
404 |
if self.__img.imageplan.nothingtodo() or noexecute: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
405 |
self.log_operation_end( |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
406 |
result=history.RESULT_NOTHING_TO_DO) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
407 |
self.__img.imageplan.update_index = update_index |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
408 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
409 |
except: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
410 |
self.__plan_common_exception( |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
411 |
log_op_end=[api_errors.IpkgOutOfDateException]) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
412 |
# NOTREACHED |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
413 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
414 |
self.__plan_common_finish() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
415 |
res = not self.__img.imageplan.nothingtodo() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
416 |
return res, opensolaris_image |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
417 |
|
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
418 |
def plan_change_varcets(self, variants=None, facets=None, |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
419 |
noexecute=False, verbose=False, be_name=None): |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
420 |
"""Creates a plan to change the specified variants/facets on an image. |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
421 |
verbose controls |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
422 |
whether verbose debugging output will be printed to the |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
423 |
terminal. This function has two return values. The first is |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
424 |
a boolean which tells the client whether there is anything to |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
425 |
do. The third is either None, or an exception which indicates |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
426 |
partial success. This is currently used to indicate a failure |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
427 |
in refreshing catalogs. It can raise CatalogRefreshException, |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
428 |
IpkgOutOfDateException, NetworkUnavailableException, |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
429 |
PlanCreationException and PermissionsException.""" |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
430 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
431 |
self.__plan_common_start("change-variant") |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
432 |
if not variants and not facets: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
433 |
raise ValueError, "Nothing to do" |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
434 |
try: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
435 |
self.check_be_name(be_name) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
436 |
self.be_name = be_name |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
437 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
438 |
self.__refresh_publishers() |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
439 |
|
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
440 |
self.__img.image_change_varcets(variants, |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
441 |
facets, |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
442 |
self.__progresstracker, |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
443 |
self.__check_cancelation, |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
444 |
noexecute, verbose=verbose) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
445 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
446 |
assert self.__img.imageplan |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
447 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
448 |
if self.__canceling: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
449 |
raise api_errors.CanceledException() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
450 |
self.__set_can_be_canceled(False) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
451 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
452 |
if not noexecute: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
453 |
self.__plan_type = self.__IMAGE_UPDATE |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
454 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
455 |
self.plan_desc = PlanDescription(self.__img.imageplan) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
456 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
457 |
if self.__img.imageplan.nothingtodo() or noexecute: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
458 |
self.log_operation_end( |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
459 |
result=history.RESULT_NOTHING_TO_DO) |
1032
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
460 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
461 |
# |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
462 |
# We always rebuild the search index after a |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
463 |
# variant change |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
464 |
# |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
465 |
self.__img.imageplan.update_index = True |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
466 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
467 |
except: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
468 |
self.__plan_common_exception() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
469 |
# NOTREACHED |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
470 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
471 |
self.__plan_common_finish() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
472 |
res = not self.__img.imageplan.nothingtodo() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
473 |
return res |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
474 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
475 |
def describe(self): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
476 |
"""Returns None if no plan is ready yet, otherwise returns |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
477 |
a PlanDescription""" |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
478 |
return self.__plan_desc |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
479 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
480 |
def prepare(self): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
481 |
"""Takes care of things which must be done before the plan |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
482 |
can be executed. This includes downloading the packages to |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
483 |
disk and preparing the indexes to be updated during |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
484 |
execution. It can raise ProblematicPermissionsIndexException, |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
485 |
and PlanMissingException. Should only be called once a |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
486 |
plan_X method has been called.""" |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
487 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
488 |
self.__activity_lock.acquire() |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
489 |
self.__set_can_be_canceled(True) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
490 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
491 |
try: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
492 |
try: |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
493 |
if not self.__img.imageplan: |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
494 |
raise api_errors.PlanMissingException() |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
495 |
|
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
496 |
if self.__prepared: |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
497 |
raise api_errors.AlreadyPreparedException() |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
498 |
assert self.__plan_type == self.__INSTALL or \ |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
499 |
self.__plan_type == self.__UNINSTALL or \ |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
500 |
self.__plan_type == self.__IMAGE_UPDATE |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
501 |
try: |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
502 |
self.__img.imageplan.preexecute() |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
503 |
except search_errors.ProblematicPermissionsIndexException, e: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
504 |
raise api_errors.ProblematicPermissionsIndexException(e) |
1032
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
505 |
except: |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
506 |
raise |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
507 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
508 |
if self.__canceling: |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
509 |
self.__img.transport.reset() |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
510 |
raise api_errors.CanceledException() |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
511 |
self.__prepared = True |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
512 |
except Exception, e: |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
513 |
if self.__img.history.operation_name: |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
514 |
# If an operation is in progress, log |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
515 |
# the error and mark its end. |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
516 |
self.log_operation_end(error=e) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
517 |
raise |
1032
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
518 |
except: |
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
519 |
# Handle exceptions that are not subclasses of |
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
520 |
# Exception. |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
521 |
if self.__img.history.operation_name: |
1032
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
522 |
# If an operation is in progress, log |
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
523 |
# the error and mark its end. |
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
524 |
exc_type, exc_value, exc_traceback = \ |
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
525 |
sys.exc_info() |
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
526 |
self.log_operation_end(error=exc_type) |
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
527 |
raise |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
528 |
finally: |
1503
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
529 |
self.__img.cleanup_downloads() |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
530 |
self.__set_can_be_canceled(False) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
531 |
self.__activity_lock.release() |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
532 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
533 |
def execute_plan(self): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
534 |
"""Executes the plan. This is uncancelable one it begins. It |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
535 |
can raise CorruptedIndexException, |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
536 |
ProblematicPermissionsIndexException, ImageplanStateException, |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
537 |
ImageUpdateOnLiveImageException, and PlanMissingException. |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
538 |
Should only be called after the prepare method has been |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
539 |
called.""" |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
540 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
541 |
self.__activity_lock.acquire() |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
542 |
self.__set_can_be_canceled(False) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
543 |
try: |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
544 |
if not self.__img.imageplan: |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
545 |
raise api_errors.PlanMissingException() |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
546 |
|
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
547 |
if not self.__prepared: |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
548 |
raise api_errors.PrematureExecutionException() |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
549 |
|
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
550 |
if self.__executed: |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
551 |
raise api_errors.AlreadyExecutedException() |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
552 |
|
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
553 |
assert self.__plan_type == self.__INSTALL or \ |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
554 |
self.__plan_type == self.__UNINSTALL or \ |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
555 |
self.__plan_type == self.__IMAGE_UPDATE |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
556 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
557 |
try: |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
558 |
be = bootenv.BootEnv(self.__img.get_root()) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
559 |
except RuntimeError: |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
560 |
be = bootenv.BootEnvNull(self.__img.get_root()) |
1306
9a02ddf28dea
10630 driver action gets confused by driver_aliases entries not covered by an action
Danek Duvall <danek.duvall@sun.com>
parents:
1286
diff
changeset
|
561 |
self.__img.bootenv = be |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
562 |
|
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
563 |
if self.__plan_type is self.__IMAGE_UPDATE: |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
564 |
try: |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
565 |
be.init_image_recovery(self.__img, |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
566 |
self.__be_name) |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
567 |
except Exception, e: |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
568 |
self.log_operation_end(error=e) |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
569 |
raise |
1032
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
570 |
except: |
1102
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
571 |
# Handle exceptions that are not |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
572 |
# subclasses of Exception. |
1032
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
573 |
exc_type, exc_value, exc_traceback = \ |
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
574 |
sys.exc_info() |
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
575 |
self.log_operation_end(error=exc_type) |
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
576 |
raise |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
577 |
|
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
578 |
if self.__img.is_liveroot(): |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
579 |
e = api_errors.ImageUpdateOnLiveImageException() |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
580 |
self.log_operation_end(error=e) |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
581 |
raise e |
1328
5c3747a4fe0a
9387 pkg fix should honor reboot-needed flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1314
diff
changeset
|
582 |
else: |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
583 |
if self.__img.imageplan.reboot_needed() and \ |
1328
5c3747a4fe0a
9387 pkg fix should honor reboot-needed flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1314
diff
changeset
|
584 |
self.__img.is_liveroot(): |
5c3747a4fe0a
9387 pkg fix should honor reboot-needed flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1314
diff
changeset
|
585 |
e = api_errors.RebootNeededOnLiveImageException() |
5c3747a4fe0a
9387 pkg fix should honor reboot-needed flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1314
diff
changeset
|
586 |
self.log_operation_end(error=e) |
5c3747a4fe0a
9387 pkg fix should honor reboot-needed flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1314
diff
changeset
|
587 |
raise e |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
588 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
589 |
try: |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
590 |
self.__img.imageplan.execute() |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
591 |
except RuntimeError, e: |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
592 |
if self.__plan_type is self.__IMAGE_UPDATE: |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
593 |
be.restore_image() |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
594 |
else: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
595 |
be.restore_install_uninstall() |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
596 |
# Must be done after bootenv restore. |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
597 |
self.log_operation_end(error=e) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
598 |
raise |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
599 |
except search_errors.ProblematicPermissionsIndexException, e: |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
600 |
error = api_errors.ProblematicPermissionsIndexException(e) |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
601 |
self.log_operation_end(error=error) |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
602 |
raise error |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
603 |
except (search_errors.InconsistentIndexException, |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
604 |
search_errors.PartialIndexingException), e: |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
605 |
error = api_errors.CorruptedIndexException(e) |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
606 |
self.log_operation_end(error=error) |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
607 |
raise error |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
608 |
except search_errors.MainDictParsingException, e: |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
609 |
error = api_errors.MainDictParsingException(e) |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
610 |
self.log_operation_end(error=error) |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
611 |
raise error |
1019
e61c57c724c9
7663 disable_fmri should be synchronous
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
996
diff
changeset
|
612 |
except actuator.NonzeroExitException, e: |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
613 |
# Won't happen during image-update |
1019
e61c57c724c9
7663 disable_fmri should be synchronous
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
996
diff
changeset
|
614 |
be.restore_install_uninstall() |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
615 |
error = api_errors.ActuatorException(e) |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
616 |
self.log_operation_end(error=error) |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
617 |
raise error |
1286
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
618 |
except api_errors.WrapIndexingException, e: |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
619 |
self.__finished_execution(be) |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
620 |
raise |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
621 |
except Exception, e: |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
622 |
if self.__plan_type is self.__IMAGE_UPDATE: |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
623 |
be.restore_image() |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
624 |
else: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
625 |
be.restore_install_uninstall() |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
626 |
# Must be done after bootenv restore. |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
627 |
self.log_operation_end(error=e) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
628 |
raise |
1032
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
629 |
except: |
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
630 |
# Handle exceptions that are not subclasses of |
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
631 |
# Exception. |
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
632 |
exc_type, exc_value, exc_traceback = \ |
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
633 |
sys.exc_info() |
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
634 |
|
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
635 |
if self.__plan_type is self.__IMAGE_UPDATE: |
1032
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
636 |
be.restore_image() |
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
637 |
else: |
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
638 |
be.restore_install_uninstall() |
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
639 |
# Must be done after bootenv restore. |
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
640 |
self.log_operation_end(error=exc_type) |
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
641 |
raise |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
642 |
|
1286
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
643 |
self.__finished_execution(be) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
644 |
finally: |
1503
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
645 |
self.__img.cleanup_downloads() |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
646 |
self.__activity_lock.release() |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
647 |
|
1286
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
648 |
def __finished_execution(self, be): |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
649 |
if self.__img.imageplan.state != EXECUTED_OK: |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
650 |
if self.__plan_type is self.__IMAGE_UPDATE: |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
651 |
be.restore_image() |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
652 |
else: |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
653 |
be.restore_install_uninstall() |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
654 |
|
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
655 |
error = api_errors.ImageplanStateException( |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
656 |
self.__img.imageplan.state) |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
657 |
# Must be done after bootenv restore. |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
658 |
self.log_operation_end(error=error) |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
659 |
raise error |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
660 |
if self.__plan_type is self.__IMAGE_UPDATE: |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
661 |
be.activate_image() |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
662 |
else: |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
663 |
be.activate_install_uninstall() |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
664 |
self.__img.cleanup_cached_content() |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
665 |
# If the end of the operation wasn't already logged |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
666 |
# by one of the previous operations, then log it as |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
667 |
# ending now. |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
668 |
if self.__img.history.operation_name: |
1286
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
669 |
self.log_operation_end() |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
670 |
self.__executed = True |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
671 |
try: |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
672 |
if int(os.environ.get("PKG_DUMP_STATS", 0)) > 0: |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
673 |
self.__img.transport.stats.dump() |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
674 |
except ValueError: |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
675 |
# Don't generate stats if an invalid value |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
676 |
# is supplied. |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
677 |
pass |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1279
diff
changeset
|
678 |
|
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
679 |
def refresh(self, full_refresh=False, pubs=None, immediate=False): |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
680 |
"""Refreshes the metadata (e.g. catalog) for one or more |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
681 |
publishers. |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
682 |
|
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
683 |
'full_refresh' is an optional boolean value indicating whether |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
684 |
a full retrieval of publisher metadata (e.g. catalogs) or only |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
685 |
an update to the existing metadata should be performed. When |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
686 |
True, 'immediate' is also set to True. |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
687 |
|
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
688 |
'pubs' is a list of publisher prefixes or publisher objects |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
689 |
to refresh. Passing an empty list or using the default value |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
690 |
implies all publishers. |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
691 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
692 |
'immediate' is an optional boolean value indicating whether |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
693 |
a refresh should occur now. If False, a publisher's selected |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
694 |
repository will only be checked for updates if the update |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
695 |
interval period recorded in the image configuration has been |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
696 |
exceeded. |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
697 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
698 |
Currently returns an image object, allowing existing code to |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
699 |
work while the rest of the API is put into place.""" |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
700 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
701 |
self.__activity_lock.acquire() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
702 |
self.__set_can_be_canceled(False) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
703 |
try: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
704 |
self.__img.refresh_publishers(full_refresh=full_refresh, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
705 |
immediate=immediate, pubs=pubs, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
706 |
progtrack=self.__progresstracker) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
707 |
return self.__img |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
708 |
finally: |
1472
c50eb141435a
12128 client should pipeline manifest retrieval
johansen <johansen@sun.com>
parents:
1461
diff
changeset
|
709 |
self.__img.cleanup_downloads() |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
710 |
self.__activity_lock.release() |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
711 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
712 |
def __licenses(self, mfst, local): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
713 |
"""Private function. Returns the license info from the |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
714 |
manifest mfst. Local controls whether the information is |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
715 |
retrieved locally.""" |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
716 |
license_lst = [] |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
717 |
for lic in mfst.gen_actions_by_type("license"): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
718 |
if not local: |
1072
66ce6aa346d7
8132 __licenses should use StringIO
Rich Burridge <rich.burridge@sun.com>
parents:
1053
diff
changeset
|
719 |
s = StringIO.StringIO() |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
720 |
hash_val = misc.gunzip_from_stream( |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
721 |
lic.get_remote_opener(self.__img, |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
722 |
mfst.fmri)(), s) |
1072
66ce6aa346d7
8132 __licenses should use StringIO
Rich Burridge <rich.burridge@sun.com>
parents:
1053
diff
changeset
|
723 |
text = s.getvalue() |
66ce6aa346d7
8132 __licenses should use StringIO
Rich Burridge <rich.burridge@sun.com>
parents:
1053
diff
changeset
|
724 |
s.close() |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
725 |
else: |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
726 |
text = lic.get_local_opener(self.__img, |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
727 |
mfst.fmri)().read()[:-1] |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
728 |
license_lst.append(LicenseInfo(text)) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
729 |
return license_lst |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
730 |
|
917
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
731 |
def info(self, fmri_strings, local, info_needed): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
732 |
"""Gathers information about fmris. fmri_strings is a list |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
733 |
of fmri_names for which information is desired. local |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
734 |
determines whether to retrieve the information locally. It |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
735 |
returns a dictionary of lists. The keys for the dictionary are |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
736 |
the constants specified in the class definition. The values are |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
737 |
lists of PackageInfo objects or strings.""" |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
738 |
|
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
739 |
# Currently, this is mostly a wapper for activity locking. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
740 |
self.__activity_lock.acquire() |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
741 |
try: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
742 |
i = self._info_op(fmri_strings, local, info_needed) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
743 |
finally: |
1503
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
744 |
self.__img.cleanup_downloads() |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
745 |
self.__activity_lock.release() |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
746 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
747 |
return i |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
748 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
749 |
def _info_op(self, fmri_strings, local, info_needed): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
750 |
"""Performs the actual info operation. The external |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
751 |
interface to the API's consumers is defined in info().""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
752 |
|
917
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
753 |
bad_opts = info_needed - PackageInfo.ALL_OPTIONS |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
754 |
if bad_opts: |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
755 |
raise api_errors.UnrecognizedOptionsToInfo(bad_opts) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
756 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
757 |
self.log_operation_start("info") |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
758 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
759 |
fmris = [] |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
760 |
notfound = [] |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
761 |
multiple_matches = [] |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
762 |
illegals = [] |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
763 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
764 |
ppub = self.__img.get_preferred_publisher() |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
765 |
if local: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
766 |
fmris, notfound, illegals = \ |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
767 |
self.__img.installed_fmris_from_args(fmri_strings) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
768 |
if not fmris and not notfound and not illegals: |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
769 |
self.log_operation_end( |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
770 |
result=history.RESULT_NOTHING_TO_DO) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
771 |
raise api_errors.NoPackagesInstalledException() |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
772 |
else: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
773 |
# Verify validity of certificates before attempting |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
774 |
# network operations. |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
775 |
self.__cert_verify( |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
776 |
log_op_end=[api_errors.CertificateError]) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
777 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
778 |
# XXX This loop really needs not to be copied from |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
779 |
# Image.make_install_plan()! |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
780 |
for p in fmri_strings: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
781 |
try: |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
782 |
matches = list(self.__img.inventory([p], |
1045
62656c214151
8135 plan creation could be faster for install and uninstall
Shawn Walker <srw@sun.com>
parents:
1044
diff
changeset
|
783 |
all_known=True, ordered=False)) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
784 |
except api_errors.InventoryException, e: |
707
d37b19989de2
4878 pkg info traceback when given invalid input
Brock Pytlik <bpytlik@sun.com>
parents:
696
diff
changeset
|
785 |
assert(len(e.notfound) == 1 or \ |
d37b19989de2
4878 pkg info traceback when given invalid input
Brock Pytlik <bpytlik@sun.com>
parents:
696
diff
changeset
|
786 |
len(e.illegal) == 1) |
d37b19989de2
4878 pkg info traceback when given invalid input
Brock Pytlik <bpytlik@sun.com>
parents:
696
diff
changeset
|
787 |
if e.notfound: |
d37b19989de2
4878 pkg info traceback when given invalid input
Brock Pytlik <bpytlik@sun.com>
parents:
696
diff
changeset
|
788 |
notfound.append(e.notfound[0]) |
d37b19989de2
4878 pkg info traceback when given invalid input
Brock Pytlik <bpytlik@sun.com>
parents:
696
diff
changeset
|
789 |
else: |
d37b19989de2
4878 pkg info traceback when given invalid input
Brock Pytlik <bpytlik@sun.com>
parents:
696
diff
changeset
|
790 |
illegals.append(e.illegal[0]) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
791 |
err = 1 |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
792 |
continue |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
793 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
794 |
pnames = {} |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
795 |
pmatch = [] |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
796 |
npnames = {} |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
797 |
npmatch = [] |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
798 |
for m, state in matches: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
799 |
if m.get_publisher() == ppub: |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
800 |
pnames[m.get_pkg_stem()] = 1 |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
801 |
pmatch.append(m) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
802 |
else: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
803 |
npnames[m.get_pkg_stem()] = 1 |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
804 |
npmatch.append(m) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
805 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
806 |
if len(pnames.keys()) > 1: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
807 |
multiple_matches.append( |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
808 |
(p, pnames.keys())) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
809 |
error = 1 |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
810 |
continue |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
811 |
elif len(pnames.keys()) < 1 and \ |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
812 |
len(npnames.keys()) > 1: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
813 |
multiple_matches.append( |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
814 |
(p, pnames.keys())) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
815 |
error = 1 |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
816 |
continue |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
817 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
818 |
# matches is a list reverse sorted by version, |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
819 |
# so take the first; i.e., the latest. |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
820 |
if len(pmatch) > 0: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
821 |
fmris.append(pmatch[0]) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
822 |
else: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
823 |
fmris.append(npmatch[0]) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
824 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
825 |
if local: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
826 |
img_cat = self.__img.get_catalog( |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
827 |
self.__img.IMG_CATALOG_INSTALLED) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
828 |
else: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
829 |
img_cat = self.__img.get_catalog( |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
830 |
self.__img.IMG_CATALOG_KNOWN) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
831 |
excludes = self.__img.list_excludes() |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
832 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
833 |
# Set of summary-related options that are in catalog data. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
834 |
summ_opts = frozenset([PackageInfo.SUMMARY, |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
835 |
PackageInfo.CATEGORIES, PackageInfo.DESCRIPTION]) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
836 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
837 |
# Set of all options that are in catalog data. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
838 |
cat_opts = summ_opts | frozenset([PackageInfo.DEPENDENCIES]) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
839 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
840 |
# Set of options that require manifest retrieval. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
841 |
act_opts = PackageInfo.ACTION_OPTIONS - \ |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
842 |
frozenset([PackageInfo.DEPENDENCIES]) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
843 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
844 |
def get_pkg_cat_data(f): |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
845 |
# XXX this doesn't handle locale. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
846 |
get_summ = summ = desc = cat_info = deps = None |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
847 |
cat_data = [] |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
848 |
if summ_opts & info_needed: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
849 |
cat_data.append(img_cat.SUMMARY) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
850 |
get_summ = PackageInfo.SUMMARY in info_needed |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
851 |
if PackageInfo.CATEGORIES in info_needed: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
852 |
cat_info = [] |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
853 |
if PackageInfo.DEPENDENCIES in info_needed: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
854 |
cat_data.append(img_cat.DEPENDENCY) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
855 |
deps = [] |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
856 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
857 |
for a in img_cat.get_entry_actions(f, cat_data, |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
858 |
excludes=excludes): |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
859 |
if a.name == "depend": |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
860 |
deps.append(a.attrs.get(a.key_attr)) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
861 |
elif a.attrs["name"] == "pkg.summary": |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
862 |
if get_summ: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
863 |
summ = a.attrs["value"] |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
864 |
elif a.attrs["name"] in ("description", |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
865 |
"pkg.description"): |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
866 |
desc = a.attrs["value"] |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
867 |
elif cat_info != None and a.has_category_info(): |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
868 |
cat_info.extend( |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
869 |
PackageCategory(scheme, cat) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
870 |
for scheme, cat |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
871 |
in a.parse_category_info()) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
872 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
873 |
if get_summ and summ == None: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
874 |
summ = desc |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
875 |
if not PackageInfo.DESCRIPTION in info_needed: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
876 |
desc = None |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
877 |
return summ, desc, cat_info, deps |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
878 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
879 |
pis = [] |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
880 |
for f in fmris: |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
881 |
pub = name = version = release = states = None |
917
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
882 |
build_release = branch = packaging_date = None |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
883 |
if PackageInfo.IDENTITY in info_needed: |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
884 |
pub, name, version = f.tuple() |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
885 |
pub = fmri.strip_pub_pfx(pub) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
886 |
release = version.release |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
887 |
build_release = version.build_release |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
888 |
branch = version.branch |
1150
2b8aaf0b0b4e
4346 use of ctime() creates non-localized time strings
Rich Burridge <rich.burridge@sun.com>
parents:
1141
diff
changeset
|
889 |
packaging_date = \ |
2b8aaf0b0b4e
4346 use of ctime() creates non-localized time strings
Rich Burridge <rich.burridge@sun.com>
parents:
1141
diff
changeset
|
890 |
version.get_timestamp().strftime("%c") |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
891 |
pref_pub = None |
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
892 |
if PackageInfo.PREF_PUBLISHER in info_needed: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
893 |
pref_pub = f.get_publisher() == ppub |
917
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
894 |
state = None |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
895 |
if PackageInfo.STATE in info_needed: |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
896 |
states = self.__img.get_pkg_state(f) |
615
aeeeb9f31173
4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents:
610
diff
changeset
|
897 |
links = hardlinks = files = dirs = dependencies = None |
1389
1827f487a235
8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents:
1370
diff
changeset
|
898 |
summary = size = licenses = cat_info = description = \ |
1827f487a235
8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents:
1370
diff
changeset
|
899 |
None |
917
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
900 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
901 |
if frozenset([PackageInfo.SUMMARY, |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
902 |
PackageInfo.CATEGORIES, |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
903 |
PackageInfo.DESCRIPTION, |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
904 |
PackageInfo.DEPENDENCIES]) & info_needed: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
905 |
summary, description, cat_info, dependencies = \ |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
906 |
get_pkg_cat_data(f) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
907 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
908 |
if (frozenset([PackageInfo.SIZE, |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
909 |
PackageInfo.LICENSES]) | act_opts) & info_needed: |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
910 |
mfst = self.__img.get_manifest(f) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
911 |
if PackageInfo.LICENSES in info_needed: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
912 |
licenses = self.__licenses(mfst, local) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
913 |
|
917
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
914 |
if PackageInfo.SIZE in info_needed: |
1044
046981c42149
8102 pkg.client.api info reports size of zero for packages with cached manifests
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
1032
diff
changeset
|
915 |
size = mfst.get_size(excludes=excludes) |
917
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
916 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
917 |
if act_opts & info_needed: |
917
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
918 |
if PackageInfo.LINKS in info_needed: |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
919 |
links = list( |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
920 |
mfst.gen_key_attribute_value_by_type( |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
921 |
"link", excludes)) |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
922 |
if PackageInfo.HARDLINKS in info_needed: |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
923 |
hardlinks = list( |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
924 |
mfst.gen_key_attribute_value_by_type( |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
925 |
"hardlink", excludes)) |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
926 |
if PackageInfo.FILES in info_needed: |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
927 |
files = list( |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
928 |
mfst.gen_key_attribute_value_by_type( |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
929 |
"file", excludes)) |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
930 |
if PackageInfo.DIRS in info_needed: |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
931 |
dirs = list( |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
932 |
mfst.gen_key_attribute_value_by_type( |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
933 |
"dir", excludes)) |
615
aeeeb9f31173
4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents:
610
diff
changeset
|
934 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
935 |
pis.append(PackageInfo(pkg_stem=name, summary=summary, |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
936 |
category_info_list=cat_info, states=states, |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
937 |
publisher=pub, preferred_publisher=pref_pub, |
917
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
938 |
version=release, build_release=build_release, |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
939 |
branch=branch, packaging_date=packaging_date, |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
940 |
size=size, pfmri=str(f), licenses=licenses, |
615
aeeeb9f31173
4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents:
610
diff
changeset
|
941 |
links=links, hardlinks=hardlinks, files=files, |
1389
1827f487a235
8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents:
1370
diff
changeset
|
942 |
dirs=dirs, dependencies=dependencies, |
1827f487a235
8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents:
1370
diff
changeset
|
943 |
description=description)) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
944 |
if pis: |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
945 |
self.log_operation_end() |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
946 |
elif illegals or multiple_matches: |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
947 |
self.log_operation_end( |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
948 |
result=history.RESULT_FAILED_BAD_REQUEST) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
949 |
else: |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
950 |
self.log_operation_end( |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
951 |
result=history.RESULT_NOTHING_TO_DO) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
952 |
return { |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
953 |
self.INFO_FOUND: pis, |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
954 |
self.INFO_MISSING: notfound, |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
955 |
self.INFO_MULTI_MATCH: multiple_matches, |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
956 |
self.INFO_ILLEGALS: illegals |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
957 |
} |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
958 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
959 |
def can_be_canceled(self): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
960 |
"""Returns true if the API is in a cancelable state.""" |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
961 |
return self.__can_be_canceled |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
962 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
963 |
def __set_can_be_canceled(self, status): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
964 |
"""Private method. Handles the details of changing the |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
965 |
cancelable state.""" |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
966 |
if self.__can_be_canceled != status: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
967 |
self.__can_be_canceled = status |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
968 |
if self.__cancel_state_callable: |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
969 |
self.__cancel_state_callable( |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
970 |
self.__can_be_canceled) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
971 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
972 |
def reset(self): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
973 |
"""Resets the API back the the initial state. Note: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
974 |
this does not necessarily return the disk to its initial state |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
975 |
since the indexes or download cache may have been changed by |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
976 |
the prepare method.""" |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
977 |
self.__activity_lock.acquire() |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
978 |
self.__reset_unlock() |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
979 |
self.__activity_lock.release() |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
980 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
981 |
def __reset_unlock(self): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
982 |
"""Private method. Provides a way to reset without taking the |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
983 |
activity lock. Should only be called by a thread which already |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
984 |
holds the activity lock.""" |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
985 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
986 |
assert self.__activity_lock._is_owned() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
987 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
988 |
# This needs to be done first so that find_root can use it. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
989 |
self.__progresstracker.reset() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
990 |
|
1503
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
991 |
self.__img.cleanup_downloads() |
1242
f6aa06e1c391
6758 api should recreate image object on reset
Shawn Walker <srw@sun.com>
parents:
1240
diff
changeset
|
992 |
# Recreate the image object using the path the api |
f6aa06e1c391
6758 api should recreate image object on reset
Shawn Walker <srw@sun.com>
parents:
1240
diff
changeset
|
993 |
# object was created with instead of the current path. |
1370
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1360
diff
changeset
|
994 |
self.__img = image.Image(self.__img_path, |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
995 |
progtrack=self.__progresstracker) |
1242
f6aa06e1c391
6758 api should recreate image object on reset
Shawn Walker <srw@sun.com>
parents:
1240
diff
changeset
|
996 |
|
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
997 |
self.__plan_desc = None |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
998 |
self.__plan_type = None |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
999 |
self.__prepared = False |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1000 |
self.__executed = False |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1001 |
self.__be_name = None |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1002 |
self.__set_can_be_canceled(False) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1003 |
self.__canceling = False |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1004 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1005 |
def __check_cancelation(self): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1006 |
"""Private method. Provides a callback method for internal |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1007 |
code to use to determine whether the current action has been |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1008 |
canceled.""" |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1009 |
return self.__canceling |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1010 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1011 |
def cancel(self): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1012 |
"""Used for asynchronous cancelation. It returns the API |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1013 |
to the state it was in prior to the current method being |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1014 |
invoked. Canceling during a plan phase returns the API to |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1015 |
its initial state. Canceling during prepare puts the API |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1016 |
into the state it was in just after planning had completed. |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1017 |
Plan execution cannot be canceled. A call to this method blocks |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1018 |
until the canelation has happened. Note: this does not |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1019 |
necessarily return the disk to its initial state since the |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1020 |
indexes or download cache may have been changed by the |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1021 |
prepare method.""" |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1022 |
if not self.__can_be_canceled: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1023 |
return False |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1024 |
self.__set_can_be_canceled(False) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1025 |
self.__canceling = True |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1026 |
# The lock is taken here to make the call block, until |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1027 |
# the activity has been canceled. |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1028 |
self.__activity_lock.acquire() |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1029 |
self.__activity_lock.release() |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1030 |
self.__canceling = False |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1031 |
return True |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1032 |
|
716
b836c1b14137
4639 history result info differs for install and uninstall of nonexistent packages
Brock Pytlik <bpytlik@sun.com>
parents:
707
diff
changeset
|
1033 |
def __set_history_PlanCreationException(self, e): |
1141
a74d6815a7fc
4178 unfound_fmris is a poor name
Rich Burridge <rich.burridge@sun.com>
parents:
1140
diff
changeset
|
1034 |
if e.unmatched_fmris or e.multiple_matches or \ |
716
b836c1b14137
4639 history result info differs for install and uninstall of nonexistent packages
Brock Pytlik <bpytlik@sun.com>
parents:
707
diff
changeset
|
1035 |
e.missing_matches or e.illegal: |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1036 |
self.log_operation_end(error=e, |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1037 |
result=history.RESULT_FAILED_BAD_REQUEST) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1038 |
else: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1039 |
self.log_operation_end(error=e) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1040 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1041 |
def local_search(self, query_lst): |
1100
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1042 |
"""local_search takes a list of Query objects and performs |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1043 |
each query against the installed packages of the image.""" |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1044 |
|
1360
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1045 |
l = query_p.QueryLexer() |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1046 |
l.build() |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1047 |
qp = query_p.QueryParser(l) |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1048 |
ssu = None |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1049 |
for i, q in enumerate(query_lst): |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1050 |
try: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1051 |
query = qp.parse(q.encoded_text()) |
1360
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1052 |
query_rr = qp.parse(q.encoded_text()) |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1053 |
if query_rr.remove_root(self.__img.root): |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1054 |
query.add_or(query_rr) |
1053
00fe9773d072
8098 parsing errors should not cause a stacktrace
Brock Pytlik <bpytlik@sun.com>
parents:
1051
diff
changeset
|
1055 |
except query_p.BooleanQueryException, e: |
00fe9773d072
8098 parsing errors should not cause a stacktrace
Brock Pytlik <bpytlik@sun.com>
parents:
1051
diff
changeset
|
1056 |
raise api_errors.BooleanQueryException(e) |
00fe9773d072
8098 parsing errors should not cause a stacktrace
Brock Pytlik <bpytlik@sun.com>
parents:
1051
diff
changeset
|
1057 |
except query_p.ParseError, e: |
00fe9773d072
8098 parsing errors should not cause a stacktrace
Brock Pytlik <bpytlik@sun.com>
parents:
1051
diff
changeset
|
1058 |
raise api_errors.ParseError(e) |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1059 |
self.__img.update_index_dir() |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1060 |
assert self.__img.index_dir |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1061 |
try: |
1337
52e101b7cc31
9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
1062 |
query.set_info(num_to_return=q.num_to_return, |
52e101b7cc31
9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
1063 |
start_point=q.start_point, |
52e101b7cc31
9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
1064 |
index_dir=self.__img.index_dir, |
52e101b7cc31
9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
1065 |
get_manifest_path=\ |
52e101b7cc31
9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
1066 |
self.__img.get_manifest_path, |
52e101b7cc31
9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
1067 |
gen_installed_pkg_names=\ |
52e101b7cc31
9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
1068 |
self.__img.gen_installed_pkg_names, |
52e101b7cc31
9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
1069 |
case_sensitive=q.case_sensitive) |
52e101b7cc31
9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
1070 |
res = query.search( |
52e101b7cc31
9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
1071 |
self.__img.gen_installed_pkgs, |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1072 |
self.__img.get_manifest_path, |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1073 |
self.__img.list_excludes()) |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1074 |
except search_errors.InconsistentIndexException, e: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1075 |
raise api_errors.InconsistentIndexException(e) |
1100
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1076 |
# i is being inserted to track which query the results |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1077 |
# are for. None is being inserted since there is no |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1078 |
# publisher being searched against. |
1360
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1079 |
try: |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1080 |
for r in res: |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1081 |
yield i, None, r |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1082 |
except api_errors.SlowSearchUsed, e: |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1083 |
ssu = e |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1084 |
if ssu: |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1085 |
raise ssu |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1086 |
|
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1087 |
@staticmethod |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1088 |
def __parse_v_0(line, pub, v): |
1100
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1089 |
"""This function parses the string returned by a version 0 |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1090 |
search server and puts it into the expected format of |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1091 |
(query_number, publisher, (version, return_type, (results))). |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1257
diff
changeset
|
1092 |
|
1100
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1093 |
"query_number" in the return value is fixed at 0 since search |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1094 |
v0 servers cannot accept multiple queries in a single HTTP |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1095 |
request.""" |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1096 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1097 |
line = line.strip() |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1098 |
fields = line.split(None, 3) |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1099 |
return (0, pub, (v, Query.RETURN_ACTIONS, (fields[:4]))) |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1100 |
|
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1101 |
@staticmethod |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1102 |
def __parse_v_1(line, pub, v): |
1100
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1103 |
"""This function parses the string returned by a version 1 |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1104 |
search server and puts it into the expected format of |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1105 |
(query_number, publisher, (version, return_type, (results))) |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1106 |
If it receives a line it can't parse, it raises a |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1107 |
ServerReturnError.""" |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1108 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1109 |
fields = line.split(None, 2) |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1110 |
if len(fields) != 3: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1111 |
raise api_errors.ServerReturnError(line) |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1112 |
try: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1113 |
return_type = int(fields[1]) |
1360
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1114 |
query_num = int(fields[0]) |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1115 |
except ValueError: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1116 |
raise api_errors.ServerReturnError(line) |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1117 |
if return_type == Query.RETURN_ACTIONS: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1118 |
subfields = fields[2].split(None, 2) |
1360
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1119 |
return (query_num, pub, (v, return_type, |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1120 |
(subfields[0], urllib.unquote(subfields[1]), |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1121 |
subfields[2]))) |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1122 |
elif return_type == Query.RETURN_PACKAGES: |
1360
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1123 |
return (query_num, pub, (v, return_type, fields[2])) |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1124 |
else: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1125 |
raise api_errors.ServerReturnError(line) |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1126 |
|
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1127 |
def remote_search(self, query_str_and_args_lst, servers=None): |
1100
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1128 |
"""This function takes a list of Query objects, and optionally |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1129 |
a list of servers to search against. It performs each query |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1130 |
against each server and yields the results in turn. If no |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1131 |
servers are provided, the search is conducted against all |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1132 |
active servers known by the image. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1133 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1134 |
The servers argument is a list of servers in two possible |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1135 |
forms: the old deprecated form of a publisher, in a |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1136 |
dictionary, or a Publisher object. """ |
1100
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1137 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1138 |
failed = [] |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1139 |
invalid = [] |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1140 |
unsupported = [] |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
1141 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1142 |
if not servers: |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1143 |
servers = self.__img.gen_publishers() |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1144 |
|
1360
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1145 |
new_qs = [] |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1146 |
l = query_p.QueryLexer() |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1147 |
l.build() |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1148 |
qp = query_p.QueryParser(l) |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1149 |
for q in query_str_and_args_lst: |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1150 |
try: |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1151 |
query = qp.parse(q.encoded_text()) |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1152 |
query_rr = qp.parse(q.encoded_text()) |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1153 |
if query_rr.remove_root(self.__img.root): |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1154 |
query.add_or(query_rr) |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1155 |
new_qs.append(query_p.Query(str(query), |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1156 |
q.case_sensitive, q.return_type, |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1157 |
q.num_to_return, q.start_point)) |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1158 |
else: |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1159 |
new_qs.append(q) |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1160 |
except query_p.BooleanQueryException, e: |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1161 |
raise api_errors.BooleanQueryException(e) |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1162 |
except query_p.ParseError, e: |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1163 |
raise api_errors.ParseError(e) |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1164 |
query_str_and_args_lst = new_qs |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1165 |
|
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1166 |
for pub in servers: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1167 |
descriptive_name = None |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
1168 |
|
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1169 |
if isinstance(pub, dict): |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1170 |
origin = pub["origin"] |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1171 |
try: |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1172 |
pub = self.__img.get_publisher( |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1173 |
origin=origin) |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1174 |
except api_errors.UnknownPublisher: |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1175 |
pub = publisher.RepositoryURI(origin) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1176 |
descriptive_name = origin |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1177 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1178 |
if not descriptive_name: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1179 |
descriptive_name = pub.prefix |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1180 |
|
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1181 |
try: |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1182 |
res = self.__img.transport.do_search(pub, |
1360
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1183 |
query_str_and_args_lst) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1184 |
except api_errors.NegativeSearchResult: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1185 |
continue |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1186 |
except api_errors.TransportError, e: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1187 |
failed.append((descriptive_name, e)) |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1188 |
continue |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1189 |
except api_errors.UnsupportedSearchError, e: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1190 |
unsupported.append((descriptive_name, e)) |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1191 |
continue |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1192 |
except api_errors.MalformedSearchRequest, e: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1193 |
ex = self._validate_search( |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1194 |
query_str_and_args_lst) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1195 |
if ex: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1196 |
raise ex |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1197 |
failed.append((descriptive_name, e)) |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1198 |
continue |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1199 |
|
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1200 |
try: |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1201 |
if not self.validate_response(res, 1): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1202 |
invalid.append(descriptive_name) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1203 |
continue |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1204 |
for line in res: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1205 |
yield self.__parse_v_1(line, pub, 1) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1206 |
except api_errors.TransportError, e: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1207 |
failed.append((descriptive_name, e)) |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1208 |
continue |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1209 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1210 |
if failed or invalid or unsupported: |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1211 |
raise api_errors.ProblematicSearchServers(failed, |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1212 |
invalid, unsupported) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1213 |
|
1360
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1214 |
@staticmethod |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1215 |
def __unconvert_return_type(v): |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1216 |
return v == query_p.Query.RETURN_ACTIONS |
fbf184c6d55b
1059 search both original input and paths with image root removed
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
1217 |
|
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1218 |
def _validate_search(self, query_str_lst): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1219 |
"""Called by remote search if server responds that the |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1220 |
request was invalid. In this case, parse the query on |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1221 |
the client-side and determine what went wrong.""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1222 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1223 |
for q in query_str_lst: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1224 |
l = query_p.QueryLexer() |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1225 |
l.build() |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1226 |
qp = query_p.QueryParser(l) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1227 |
try: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1228 |
query = qp.parse(q.encoded_text()) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1229 |
except query_p.BooleanQueryException, e: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1230 |
return api_errors.BooleanQueryException(e) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1231 |
except query_p.ParseError, e: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1232 |
return api_errors.ParseError(e) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1233 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
1234 |
return None |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1235 |
|
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1236 |
def rebuild_search_index(self): |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1237 |
"""Rebuilds the search indexes. Removes all |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1238 |
existing indexes and replaces them from scratch rather than |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1239 |
performing the incremental update which is usually used. |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1240 |
This is useful for times when the index for the client has |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1241 |
been corrupted.""" |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1242 |
self.__img.update_index_dir() |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
1243 |
self.log_operation_start("rebuild-index") |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1244 |
if not os.path.isdir(self.__img.index_dir): |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1245 |
self.__img.mkdirs() |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1246 |
try: |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1247 |
ind = indexer.Indexer(self.__img, self.__img.get_manifest, |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1248 |
self.__img.get_manifest_path, |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1249 |
self.__progresstracker, self.__img.list_excludes()) |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1250 |
ind.rebuild_index_from_scratch( |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1251 |
self.__img.gen_installed_pkgs()) |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1252 |
except search_errors.ProblematicPermissionsIndexException, e: |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
1253 |
error = api_errors.ProblematicPermissionsIndexException(e) |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
1254 |
self.log_operation_end(error=error) |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
1255 |
raise error |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1256 |
except search_errors.MainDictParsingException, e: |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
1257 |
error = api_errors.MainDictParsingException(e) |
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
1258 |
self.log_operation_end(error=error) |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1259 |
self.__img.cleanup_downloads() |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
1260 |
raise error |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1261 |
else: |
1027
e827313523d8
7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents:
1019
diff
changeset
|
1262 |
self.log_operation_end() |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
1263 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1264 |
@staticmethod |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1265 |
def validate_response(res, v): |
1100
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1266 |
"""This function is used to determine whether the first |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1267 |
line returned from a server is expected. This ensures that |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1268 |
search is really communicating with a search-enabled server.""" |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1269 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1270 |
try: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1271 |
s = res.next() |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1272 |
return s == Query.VALIDATION_STRING[v] |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1273 |
except StopIteration: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1274 |
return False |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1275 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1276 |
def add_publisher(self, pub, refresh_allowed=True): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1277 |
"""Add the provided publisher object to the image |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1278 |
configuration.""" |
1503
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
1279 |
try: |
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
1280 |
self.__img.add_publisher(pub, |
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
1281 |
refresh_allowed=refresh_allowed, |
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
1282 |
progtrack=self.__progresstracker) |
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
1283 |
finally: |
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
1284 |
self.__img.cleanup_downloads() |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1285 |
|
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1286 |
def get_pub_search_order(self): |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1287 |
"""Return current search order of publishers; includes |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1288 |
disabled publishers""" |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1289 |
return self.__img.cfg_cache.publisher_search_order |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1290 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1291 |
def set_pub_search_after(self, being_moved_prefix, staying_put_prefix): |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1292 |
"""Change the publisher search order so that being_moved is |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1293 |
searched after staying_put""" |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1294 |
self.__img.pub_search_after(being_moved_prefix, staying_put_prefix) |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1295 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1296 |
def set_pub_search_before(self, being_moved_prefix, staying_put_prefix): |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1297 |
"""Change the publisher search order so that being_moved is |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1298 |
searched before staying_put""" |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1299 |
self.__img.pub_search_before(being_moved_prefix, staying_put_prefix) |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1300 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1301 |
def get_preferred_publisher(self): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1302 |
"""Returns the preferred publisher object for the image.""" |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1303 |
return self.get_publisher( |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1304 |
prefix=self.__img.get_preferred_publisher()) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1305 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1306 |
def get_publisher(self, prefix=None, alias=None, duplicate=False): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1307 |
"""Retrieves a publisher object matching the provided prefix |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1308 |
(name) or alias. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1309 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1310 |
'duplicate' is an optional boolean value indicating whether |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1311 |
a copy of the publisher object should be returned instead |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1312 |
of the original. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1313 |
""" |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1314 |
pub = self.__img.get_publisher(prefix=prefix, alias=alias) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1315 |
if duplicate: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1316 |
# Never return the original so that changes to the |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1317 |
# retrieved object are not reflected until |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1318 |
# update_publisher is called. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1319 |
return copy.copy(pub) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1320 |
return pub |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1321 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1322 |
def get_publishers(self, duplicate=False): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1323 |
"""Returns a list of the publisher objects for the current |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1324 |
image. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1325 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1326 |
'duplicate' is an optional boolean value indicating whether |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1327 |
copies of the publisher objects should be returned instead |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1328 |
of the originals. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1329 |
""" |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1330 |
if duplicate: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1331 |
# Return a copy so that changes to the retrieved objects |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1332 |
# are not reflected until update_publisher is called. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1333 |
pubs = [ |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1334 |
copy.copy(p) |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1335 |
for p in self.__img.get_publishers().values() |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1336 |
] |
716
b836c1b14137
4639 history result info differs for install and uninstall of nonexistent packages
Brock Pytlik <bpytlik@sun.com>
parents:
707
diff
changeset
|
1337 |
else: |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1338 |
pubs = self.__img.get_publishers().values() |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1339 |
return misc.get_sorted_publishers(pubs, |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1340 |
preferred=self.__img.get_preferred_publisher()) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1341 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1342 |
def get_publisher_last_update_time(self, prefix=None, alias=None): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1343 |
"""Returns a datetime object representing the last time the |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1344 |
catalog for a publisher was modified or None.""" |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
1345 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1346 |
if alias: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
1347 |
pub = self.get_publisher(alias=alias) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
1348 |
else: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
1349 |
pub = self.get_publisher(prefix=prefix) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
1350 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
1351 |
if pub.disabled: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
1352 |
return None |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
1353 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1354 |
dt = None |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1355 |
self.__activity_lock.acquire() |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1356 |
try: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1357 |
self.__set_can_be_canceled(True) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1358 |
try: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
1359 |
dt = pub.catalog.last_modified |
1032
ff3c6b09f430
8072 history load code needs to be more resilient against unexpected data format
Shawn Walker <srw@sun.com>
parents:
1027
diff
changeset
|
1360 |
except: |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1361 |
self.__reset_unlock() |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1362 |
raise |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1363 |
finally: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1364 |
self.__activity_lock.release() |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1365 |
return dt |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1366 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1367 |
def has_publisher(self, prefix=None, alias=None): |
1252
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
1242
diff
changeset
|
1368 |
"""Returns a boolean value indicating whether a publisher using |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
1242
diff
changeset
|
1369 |
the given prefix or alias exists.""" |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1370 |
return self.__img.has_publisher(prefix=prefix, alias=alias) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1371 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1372 |
def remove_publisher(self, prefix=None, alias=None): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1373 |
"""Removes a publisher object matching the provided prefix |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1374 |
(name) or alias.""" |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1375 |
self.__img.remove_publisher(prefix=prefix, alias=alias, |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1376 |
progtrack=self.__progresstracker) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1377 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1378 |
def set_preferred_publisher(self, prefix=None, alias=None): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1379 |
"""Sets the preferred publisher for the image.""" |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1380 |
self.__img.set_preferred_publisher(prefix=prefix, alias=alias) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1381 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1382 |
def update_publisher(self, pub, refresh_allowed=True): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1383 |
"""Replaces an existing publisher object with the provided one |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1384 |
using the _source_object_id identifier set during copy. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1385 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1386 |
'refresh_allowed' is an optional boolean value indicating |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1387 |
whether a refresh of publisher metadata (such as its catalog) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1388 |
should be performed if transport information is changed for a |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1389 |
repository, mirror, or origin. If False, no attempt will be |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1390 |
made to retrieve publisher metadata.""" |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1391 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1392 |
self.log_operation_start("update-publisher") |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1393 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1394 |
if pub.disabled and \ |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1395 |
pub.prefix == self.__img.get_preferred_publisher(): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1396 |
raise api_errors.SetPreferredPublisherDisabled( |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1397 |
pub.prefix) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1398 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1399 |
def need_refresh(oldo, newo): |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1400 |
if newo.disabled: |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1401 |
# The publisher is disabled, so no refresh |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1402 |
# should be performed. |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1403 |
return False |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1404 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1405 |
if oldo.disabled and not newo.disabled: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1406 |
# The publisher has been re-enabled, so |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1407 |
# retrieve the catalog. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1408 |
return True |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1409 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1410 |
if len(newo.repositories) != len(oldo.repositories): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1411 |
# If there are an unequal number of repositories |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1412 |
# then some have been added or removed. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1413 |
return True |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1414 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1415 |
matched = 0 |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1416 |
for oldr in oldo.repositories: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1417 |
for newr in newo.repositories: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1418 |
if newr._source_object_id == id(oldr): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1419 |
matched += 1 |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1420 |
if oldr.origins != newr.origins: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1421 |
return True |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1422 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1423 |
if matched != len(newo.repositories): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1424 |
# If not all of the repositories match up, then |
1102
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1425 |
# one has been added or removed. |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1426 |
return True |
1102
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1427 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1428 |
return False |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1429 |
|
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
1430 |
refresh_catalog = False |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1431 |
updated = False |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1432 |
disable = False |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1433 |
orig_pub = None |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1434 |
publishers = self.__img.get_publishers() |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1435 |
for key, old in publishers.iteritems(): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1436 |
if pub._source_object_id == id(old): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1437 |
if need_refresh(old, pub): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1438 |
refresh_catalog = True |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1439 |
if not old.disabled and pub.disabled: |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1440 |
disable = True |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1441 |
|
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1442 |
# Store the new publisher's id and the old |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1443 |
# publisher object so it can be restored if the |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1444 |
# update operation fails. |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1445 |
orig_pub = (id(pub), publishers[key]) |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1446 |
|
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1447 |
# Now remove the old publisher object using the |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1448 |
# iterator key since the prefix might be |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1449 |
# different for the new publisher object. |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1450 |
updated = True |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1451 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1452 |
# only if prefix is different - this |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1453 |
# preserves search order |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1454 |
if key != pub.prefix: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1455 |
del publishers[key] |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1456 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
1457 |
# Prepare the new publisher object. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
1458 |
pub.meta_root = \ |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
1459 |
self.__img._get_publisher_meta_root( |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
1460 |
pub.prefix) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
1461 |
pub.transport = self.__img.transport |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
1462 |
|
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1463 |
# Finally, add the new publisher object. |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1464 |
publishers[pub.prefix] = pub |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1465 |
break |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1466 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1467 |
if not updated: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1468 |
# If a matching publisher couldn't be found and |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1469 |
# replaced, something is wrong (client api usage |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1470 |
# error). |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1471 |
e = api_errors.UnknownPublisher(pub) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1472 |
self.log_operation_end(e) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1473 |
raise e |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1474 |
|
1102
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1475 |
def cleanup(): |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1476 |
new_id, old_pub = orig_pub |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1477 |
for new_pfx, new_pub in publishers.iteritems(): |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1478 |
if id(new_pub) == new_id: |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1479 |
del publishers[new_pfx] |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1480 |
publishers[old_pub.prefix] = old_pub |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1481 |
break |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1482 |
|
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
1483 |
repo = pub.selected_repository |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
1484 |
if not repo.origins: |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
1485 |
raise api_errors.PublisherOriginRequired(pub.prefix) |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
1486 |
|
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1487 |
try: |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1488 |
if disable: |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1489 |
# Remove the publisher's metadata (such as |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1490 |
# catalogs, etc.). This only needs to be done |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1491 |
# in the event that a publisher is disabled; in |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1492 |
# any other case (the origin changing, etc.), |
1102
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1493 |
# refresh() will do the right thing. |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1494 |
self.__img.remove_publisher_metadata(pub) |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1495 |
elif not pub.disabled and not refresh_catalog: |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1496 |
refresh_catalog = pub.needs_refresh |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1497 |
|
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1498 |
if refresh_catalog: |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1499 |
if refresh_allowed: |
1102
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1500 |
# One of the publisher's repository |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1501 |
# origins may have changed, so the |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1502 |
# publisher needs to be revalidated. |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1503 |
self.__img.transport.valid_publisher_test( |
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1504 |
pub) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1346
diff
changeset
|
1505 |
self.refresh(pubs=[pub], immediate=True) |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1506 |
else: |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1507 |
# Something has changed (such as a |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1508 |
# repository origin) for the publisher, |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1509 |
# so a refresh should occur, but isn't |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1510 |
# currently allowed. As such, clear the |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1511 |
# last_refreshed time so that the next |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1512 |
# time the client checks to see if a |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1513 |
# refresh is needed and is allowed, one |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1514 |
# will be performed. |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1515 |
pub.last_refreshed = None |
1102
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1516 |
except Exception, e: |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1517 |
# If any of the above fails, the original publisher |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1518 |
# information needs to be restored so that state is |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1519 |
# consistent. |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1520 |
cleanup() |
1503
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
1521 |
self.__img.cleanup_downloads() |
1102
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1522 |
self.log_operation_end(error=e) |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1523 |
raise |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1524 |
except: |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1525 |
# If any of the above fails, the original publisher |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1526 |
# information needs to be restored so that state is |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1527 |
# consistent. |
1102
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1528 |
cleanup() |
1503
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
1529 |
self.__img.cleanup_downloads() |
1102
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1530 |
exc_type, exc_value, exc_traceback = \ |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1531 |
sys.exc_info() |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1100
diff
changeset
|
1532 |
self.log_operation_end(error=exc_type) |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1081
diff
changeset
|
1533 |
raise |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1534 |
|
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
941
diff
changeset
|
1535 |
# Successful; so save configuration. |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1536 |
self.__img.save_config() |
1503
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1472
diff
changeset
|
1537 |
self.__img.cleanup_downloads() |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1538 |
self.log_operation_end() |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1539 |
return |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1540 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1541 |
def log_operation_end(self, error=None, result=None): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1542 |
"""Marks the end of an operation to be recorded in image |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1543 |
history. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1544 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1545 |
'result' should be a pkg.client.history constant value |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1546 |
representing the outcome of an operation. If not provided, |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1547 |
and 'error' is provided, the final result of the operation will |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1548 |
be based on the class of 'error' and 'error' will be recorded |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1549 |
for the current operation. If 'result' and 'error' is not |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1550 |
provided, success is assumed.""" |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1551 |
self.__img.history.log_operation_end(error=error, result=result) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1552 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1553 |
def log_operation_error(self, error): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1554 |
"""Adds an error to the list of errors to be recorded in image |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1555 |
history for the current opreation.""" |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1556 |
self.__img.history.log_operation_error(error) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1557 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1558 |
def log_operation_start(self, name): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1559 |
"""Marks the start of an operation to be recorded in image |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1560 |
history.""" |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1561 |
self.__img.history.log_operation_start(name) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1562 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1563 |
def parse_p5i(self, fileobj=None, location=None): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1564 |
"""Reads the pkg(5) publisher json formatted data at 'location' |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1565 |
or from the provided file-like object 'fileobj' and returns a |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1566 |
list of tuples of the format (publisher object, pkg_names). |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1567 |
pkg_names is a list of strings representing package names or |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1568 |
FMRIs. If any pkg_names not specific to a publisher were |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1569 |
provided, the last tuple returned will be of the format (None, |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1570 |
pkg_names). |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1571 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1572 |
'fileobj' is an optional file-like object that must support a |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1573 |
'read' method for retrieving data. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1574 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1575 |
'location' is an optional string value that should either start |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1576 |
with a leading slash and be pathname of a file or a URI string. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1577 |
If it is a URI string, supported protocol schemes are 'file', |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1578 |
'ftp', 'http', and 'https'. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1579 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1580 |
'fileobj' or 'location' must be provided.""" |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1581 |
|
1257
d911e4542c41
9025 pkg.client.api needs to use p5i module
Shawn Walker <srw@sun.com>
parents:
1256
diff
changeset
|
1582 |
return p5i.parse(fileobj=fileobj, location=location) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1583 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1584 |
def write_p5i(self, fileobj, pkg_names=None, pubs=None): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1585 |
"""Writes the publisher, repository, and provided package names |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1586 |
to the provided file-like object 'fileobj' in json p5i format. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1587 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1588 |
'fileobj' is only required to have a 'write' method that accepts |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1589 |
data to be written as a parameter. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1590 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1591 |
'pkg_names' is a dict of lists, tuples, or sets indexed by |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1592 |
publisher prefix that contain package names, FMRI strings, or |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1593 |
package info objects. A prefix of "" can be used for packages |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1594 |
that are not specific to a publisher. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1595 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1596 |
'pubs' is an optional list of publisher prefixes or Publisher |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1597 |
objects. If not provided, the information for all publishers |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1598 |
(excluding those disabled) will be output.""" |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1599 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1600 |
if not pubs: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1601 |
plist = [ |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1602 |
p for p in self.get_publishers() |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1603 |
if not p.disabled |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1604 |
] |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1605 |
else: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1606 |
plist = [] |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1607 |
for p in pubs: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1608 |
if not isinstance(p, publisher.Publisher): |
1240
b261f33b84bd
10145 ImageInterface client api exposes private attributes
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
1609 |
plist.append(self.__img.get_publisher( |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1610 |
prefix=p, alias=p)) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1611 |
else: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1612 |
plist.append(p) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1613 |
|
1257
d911e4542c41
9025 pkg.client.api needs to use p5i module
Shawn Walker <srw@sun.com>
parents:
1256
diff
changeset
|
1614 |
# Transform PackageInfo object entries into PkgFmri entries |
d911e4542c41
9025 pkg.client.api needs to use p5i module
Shawn Walker <srw@sun.com>
parents:
1256
diff
changeset
|
1615 |
# before passing them to the p5i module. |
d911e4542c41
9025 pkg.client.api needs to use p5i module
Shawn Walker <srw@sun.com>
parents:
1256
diff
changeset
|
1616 |
new_pkg_names = {} |
d911e4542c41
9025 pkg.client.api needs to use p5i module
Shawn Walker <srw@sun.com>
parents:
1256
diff
changeset
|
1617 |
for pub in pkg_names: |
d911e4542c41
9025 pkg.client.api needs to use p5i module
Shawn Walker <srw@sun.com>
parents:
1256
diff
changeset
|
1618 |
pkglist = [] |
d911e4542c41
9025 pkg.client.api needs to use p5i module
Shawn Walker <srw@sun.com>
parents:
1256
diff
changeset
|
1619 |
for p in pkg_names[pub]: |
d911e4542c41
9025 pkg.client.api needs to use p5i module
Shawn Walker <srw@sun.com>
parents:
1256
diff
changeset
|
1620 |
if isinstance(p, PackageInfo): |
d911e4542c41
9025 pkg.client.api needs to use p5i module
Shawn Walker <srw@sun.com>
parents:
1256
diff
changeset
|
1621 |
pkglist.append(p.fmri) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1622 |
else: |
1257
d911e4542c41
9025 pkg.client.api needs to use p5i module
Shawn Walker <srw@sun.com>
parents:
1256
diff
changeset
|
1623 |
pkglist.append(p) |
d911e4542c41
9025 pkg.client.api needs to use p5i module
Shawn Walker <srw@sun.com>
parents:
1256
diff
changeset
|
1624 |
new_pkg_names[pub] = pkglist |
d911e4542c41
9025 pkg.client.api needs to use p5i module
Shawn Walker <srw@sun.com>
parents:
1256
diff
changeset
|
1625 |
p5i.write(fileobj, plist, pkg_names=new_pkg_names) |
716
b836c1b14137
4639 history result info differs for install and uninstall of nonexistent packages
Brock Pytlik <bpytlik@sun.com>
parents:
707
diff
changeset
|
1626 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1627 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1628 |
class Query(query_p.Query): |
1100
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1629 |
"""This class is the object used to pass queries into the api functions. |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1630 |
It encapsulates the possible options available for a query as well as |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1631 |
the text of the query itself.""" |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1087
diff
changeset
|
1632 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1633 |
def __init__(self, text, case_sensitive, return_actions=True, |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1634 |
num_to_return=None, start_point=None): |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1635 |
if return_actions: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1636 |
return_type = query_p.Query.RETURN_ACTIONS |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1637 |
else: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1638 |
return_type = query_p.Query.RETURN_PACKAGES |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1639 |
query_p.Query.__init__(self, text, case_sensitive, return_type, |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1640 |
num_to_return, start_point) |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1641 |
|
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
1642 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1643 |
class PlanDescription(object): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1644 |
"""A class which describes the changes the plan will make. It |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1645 |
provides a list of tuples of PackageInfo's. The first item in the |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1646 |
tuple is the package that is being changed. The second item in the |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1647 |
tuple is the package that will be in the image after the change.""" |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1648 |
def __init__(self, imageplan): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1649 |
self.__pkgs = \ |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1650 |
[ (PackageInfo.build_from_fmri(pp.origin_fmri), |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1651 |
PackageInfo.build_from_fmri(pp.destination_fmri)) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1652 |
for pp |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1653 |
in imageplan.pkg_plans ] |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1654 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1655 |
def get_changes(self): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1656 |
return self.__pkgs |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1657 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1658 |
class LicenseInfo(object): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1659 |
"""A class representing the license information a package |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1660 |
provides.""" |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1661 |
def __init__(self, text): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1662 |
self.__text = text |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1663 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1664 |
def get_text(self): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1665 |
return self.__text |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1666 |
|
610
09641d85df90
4132 Info --license no longer displays a license
Brock Pytlik <bpytlik@sun.com>
parents:
598
diff
changeset
|
1667 |
def __str__(self): |
09641d85df90
4132 Info --license no longer displays a license
Brock Pytlik <bpytlik@sun.com>
parents:
598
diff
changeset
|
1668 |
return self.__text |
09641d85df90
4132 Info --license no longer displays a license
Brock Pytlik <bpytlik@sun.com>
parents:
598
diff
changeset
|
1669 |
|
688
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
1670 |
class PackageCategory(object): |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
1671 |
def __init__(self, scheme, category): |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
1672 |
self.scheme = scheme |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
1673 |
self.category = category |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
1674 |
|
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
1675 |
def __str__(self, verbose=False): |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
1676 |
if verbose: |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
1677 |
return "%s (%s)" % (self.category, self.scheme) |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
1678 |
else: |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
1679 |
return "%s" % self.category |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1680 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1681 |
class PackageInfo(object): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1682 |
"""A class capturing the information about packages that a client |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1683 |
could need. The fmri is guaranteed to be set. All other values may |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1684 |
be None, depending on how the PackageInfo instance was created.""" |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1685 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1686 |
# Possible package installation states |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1687 |
INSTALLED = 1 |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1688 |
NOT_INSTALLED = 2 |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1689 |
OBSOLETE = 3 |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1690 |
RENAMED = 4 |
917
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
1691 |
|
1389
1827f487a235
8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents:
1370
diff
changeset
|
1692 |
__NUM_PROPS = 13 |
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
926
diff
changeset
|
1693 |
IDENTITY, SUMMARY, CATEGORIES, STATE, PREF_PUBLISHER, SIZE, LICENSES, \ |
1389
1827f487a235
8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents:
1370
diff
changeset
|
1694 |
LINKS, HARDLINKS, FILES, DIRS, DEPENDENCIES, DESCRIPTION = \ |
1827f487a235
8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents:
1370
diff
changeset
|
1695 |
range(__NUM_PROPS) |
917
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
1696 |
ALL_OPTIONS = frozenset(range(__NUM_PROPS)) |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
1697 |
ACTION_OPTIONS = frozenset([LINKS, HARDLINKS, FILES, DIRS, |
eed22f430a9f
6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents:
884
diff
changeset
|
1698 |
DEPENDENCIES]) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1699 |
|
688
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
1700 |
def __init__(self, pfmri, pkg_stem=None, summary=None, |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1701 |
category_info_list=None, states=None, publisher=None, |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1702 |
preferred_publisher=None, version=None, build_release=None, |
688
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
1703 |
branch=None, packaging_date=None, size=None, licenses=None, |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
1704 |
links=None, hardlinks=None, files=None, dirs=None, |
1389
1827f487a235
8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents:
1370
diff
changeset
|
1705 |
dependencies=None, description=None): |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1706 |
self.pkg_stem = pkg_stem |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1707 |
self.summary = summary |
688
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
1708 |
if category_info_list is None: |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
1709 |
category_info_list = [] |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
1710 |
self.category_info_list = category_info_list |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1711 |
self.publisher = publisher |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1712 |
self.preferred_publisher = preferred_publisher |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1713 |
self.version = version |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1714 |
self.build_release = build_release |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1715 |
self.branch = branch |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1716 |
self.packaging_date = packaging_date |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1717 |
self.size = size |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1718 |
self.fmri = pfmri |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1719 |
self.licenses = licenses |
615
aeeeb9f31173
4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents:
610
diff
changeset
|
1720 |
self.links = links |
aeeeb9f31173
4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents:
610
diff
changeset
|
1721 |
self.hardlinks = hardlinks |
aeeeb9f31173
4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents:
610
diff
changeset
|
1722 |
self.files = files |
aeeeb9f31173
4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents:
610
diff
changeset
|
1723 |
self.dirs = dirs |
aeeeb9f31173
4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents:
610
diff
changeset
|
1724 |
self.dependencies = dependencies |
1389
1827f487a235
8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents:
1370
diff
changeset
|
1725 |
self.description = description |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1726 |
self.states = self.__map_states(states) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1727 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1728 |
def __str__(self): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1729 |
return self.fmri |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1730 |
|
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1731 |
@classmethod |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1732 |
def __map_states(cls, states): |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1733 |
d = { |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1734 |
0: cls.NOT_INSTALLED, |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1735 |
2: cls.INSTALLED, |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1736 |
8: cls.OBSOLETE, |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1737 |
9: cls.RENAMED |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1738 |
} |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1739 |
|
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1740 |
if not states: |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1741 |
return [] |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1742 |
|
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1743 |
return [ |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1744 |
t |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1745 |
for t in ( |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1746 |
d.get(s, -1) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1747 |
for s in states |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1748 |
) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1749 |
if t != -1 |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1750 |
] |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
1751 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1752 |
@staticmethod |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1753 |
def build_from_fmri(f): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1754 |
if not f: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1755 |
return f |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1756 |
pub, name, version = f.tuple() |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1757 |
pub = fmri.strip_pub_pfx(pub) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1758 |
return PackageInfo(pkg_stem=name, publisher=pub, |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1759 |
version=version.release, |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff
changeset
|
1760 |
build_release=version.build_release, branch=version.branch, |
1150
2b8aaf0b0b4e
4346 use of ctime() creates non-localized time strings
Rich Burridge <rich.burridge@sun.com>
parents:
1141
diff
changeset
|
1761 |
packaging_date=version.get_timestamp().strftime("%c"), |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
1762 |
pfmri=str(f)) |