From 7e3332432774f8cf4d91b2956eb01bcfe3917f80 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sun, 22 May 2011 18:37:16 -0700 Subject: server.py/version.py shouldn't be executable while cli tools should --- keystone/server.py | 0 keystone/version.py | 0 management/delgroup.py | 85 +++++++++++++++++++------------------- management/getgroup.py | 81 +++++++++++++++++++------------------ management/getgroups.py | 75 +++++++++++++++++----------------- management/getgroupusers.py | 79 ++++++++++++++++++------------------ management/getuser.py | 75 +++++++++++++++++----------------- management/getusergroups.py | 77 ++++++++++++++++++----------------- management/getusers.py | 77 ++++++++++++++++++----------------- management/groupadd.py | 81 +++++++++++++++++++------------------ management/setuserlock.py | 99 +++++++++++++++++++++++---------------------- management/setuserpswd.py | 83 ++++++++++++++++++------------------- management/updategroup.py | 85 +++++++++++++++++++------------------- management/useradd.py | 85 +++++++++++++++++++------------------- management/userdel.py | 79 ++++++++++++++++++------------------ management/userupdate.py | 83 ++++++++++++++++++------------------- 16 files changed, 579 insertions(+), 565 deletions(-) mode change 100755 => 100644 keystone/server.py mode change 100755 => 100644 keystone/version.py mode change 100644 => 100755 management/delgroup.py mode change 100644 => 100755 management/getgroup.py mode change 100644 => 100755 management/getgroups.py mode change 100644 => 100755 management/getgroupusers.py mode change 100644 => 100755 management/getuser.py mode change 100644 => 100755 management/getusergroups.py mode change 100644 => 100755 management/getusers.py mode change 100644 => 100755 management/groupadd.py mode change 100644 => 100755 management/setuserlock.py mode change 100644 => 100755 management/setuserpswd.py mode change 100644 => 100755 management/updategroup.py mode change 100644 => 100755 management/useradd.py mode change 100644 => 100755 management/userdel.py mode change 100644 => 100755 management/userupdate.py diff --git a/keystone/server.py b/keystone/server.py old mode 100755 new mode 100644 diff --git a/keystone/version.py b/keystone/version.py old mode 100755 new mode 100644 diff --git a/management/delgroup.py b/management/delgroup.py old mode 100644 new mode 100755 index 9ef2d733..f1593635 --- a/management/delgroup.py +++ b/management/delgroup.py @@ -1,42 +1,43 @@ -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import optparse -import keystone.db.sqlalchemy.api as db_api - - -def main(): - usage = "usage: %prog group_id" - parser = optparse.OptionParser(usage) - options, args = parser.parse_args() - if len(args) != 1: - parser.error("Incorrect number of arguments") - else: - index = args[0] - - try: - o = db_api.group_get(index) - if o == None: - raise IndexError("Group %s not found", index) - else: - db_api.group_delete(index) - print 'Group', index, 'deleted.' - - except Exception, e: - print 'Error deleting group', index, str(e) - - -if __name__ == '__main__': - main() +#!/usr/bin/env python +# Copyright (c) 2010-2011 OpenStack, LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import optparse +import keystone.db.sqlalchemy.api as db_api + + +def main(): + usage = "usage: %prog group_id" + parser = optparse.OptionParser(usage) + options, args = parser.parse_args() + if len(args) != 1: + parser.error("Incorrect number of arguments") + else: + index = args[0] + + try: + o = db_api.group_get(index) + if o == None: + raise IndexError("Group %s not found", index) + else: + db_api.group_delete(index) + print 'Group', index, 'deleted.' + + except Exception, e: + print 'Error deleting group', index, str(e) + + +if __name__ == '__main__': + main() diff --git a/management/getgroup.py b/management/getgroup.py old mode 100644 new mode 100755 index 38a6b8f2..62c6d824 --- a/management/getgroup.py +++ b/management/getgroup.py @@ -1,40 +1,41 @@ -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import optparse -import keystone.db.sqlalchemy.api as db_api - - -def main(): - usage = "usage: %prog group_id" - parser = optparse.OptionParser(usage) - options, args = parser.parse_args() - if len(args) != 1: - parser.error("Incorrect number of arguments") - else: - index = args[0] - - try: - o = db_api.group_get(index) - if o == None: - raise IndexError("Group %s not found", index) - - print o.id, o.desc - except Exception, e: - print 'Error getting group', index, str(e) - - -if __name__ == '__main__': - main() +#!/usr/bin/env python +# Copyright (c) 2010-2011 OpenStack, LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import optparse +import keystone.db.sqlalchemy.api as db_api + + +def main(): + usage = "usage: %prog group_id" + parser = optparse.OptionParser(usage) + options, args = parser.parse_args() + if len(args) != 1: + parser.error("Incorrect number of arguments") + else: + index = args[0] + + try: + o = db_api.group_get(index) + if o == None: + raise IndexError("Group %s not found", index) + + print o.id, o.desc + except Exception, e: + print 'Error getting group', index, str(e) + + +if __name__ == '__main__': + main() diff --git a/management/getgroups.py b/management/getgroups.py old mode 100644 new mode 100755 index 501d948f..14f6069d --- a/management/getgroups.py +++ b/management/getgroups.py @@ -1,37 +1,38 @@ -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import optparse -import keystone.db.sqlalchemy.api as db_api - - -def main(): - usage = "usage: %prog " - parser = optparse.OptionParser(usage) - options, args = parser.parse_args() - if len(args) != 0: - parser.error("Incorrect number of arguments") - else: - try: - u = db_api.group_get_all() - if u == None: - raise IndexError("Groups not found") - for row in u: - print row.id - except Exception, e: - print 'Error getting groups:', str(e) - -if __name__ == '__main__': - main() +#!/usr/bin/env python +# Copyright (c) 2010-2011 OpenStack, LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import optparse +import keystone.db.sqlalchemy.api as db_api + + +def main(): + usage = "usage: %prog " + parser = optparse.OptionParser(usage) + options, args = parser.parse_args() + if len(args) != 0: + parser.error("Incorrect number of arguments") + else: + try: + u = db_api.group_get_all() + if u == None: + raise IndexError("Groups not found") + for row in u: + print row.id + except Exception, e: + print 'Error getting groups:', str(e) + +if __name__ == '__main__': + main() diff --git a/management/getgroupusers.py b/management/getgroupusers.py old mode 100644 new mode 100755 index 0fc7d231..0f8022be --- a/management/getgroupusers.py +++ b/management/getgroupusers.py @@ -1,39 +1,40 @@ -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import optparse -import keystone.db.sqlalchemy.api as db_api - - -def main(): - usage = "usage: %prog group_id" - parser = optparse.OptionParser(usage) - options, args = parser.parse_args() - if len(args) != 1: - parser.error("Incorrect number of arguments") - else: - group_id = args[0] - - try: - g = db_api.group_users(group_id) - if g == None: - raise IndexError("Group users not found") - for row in g: - print row - except Exception, e: - print 'Error getting group users for group', group_id, ':', str(e) - -if __name__ == '__main__': - main() +#!/usr/bin/env python +# Copyright (c) 2010-2011 OpenStack, LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import optparse +import keystone.db.sqlalchemy.api as db_api + + +def main(): + usage = "usage: %prog group_id" + parser = optparse.OptionParser(usage) + options, args = parser.parse_args() + if len(args) != 1: + parser.error("Incorrect number of arguments") + else: + group_id = args[0] + + try: + g = db_api.group_users(group_id) + if g == None: + raise IndexError("Group users not found") + for row in g: + print row + except Exception, e: + print 'Error getting group users for group', group_id, ':', str(e) + +if __name__ == '__main__': + main() diff --git a/management/getuser.py b/management/getuser.py old mode 100644 new mode 100755 index 036f10f4..e248f3a6 --- a/management/getuser.py +++ b/management/getuser.py @@ -1,37 +1,38 @@ -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import optparse -import keystone.db.sqlalchemy.api as db_api - - -def main(): - usage = "usage: %prog username" - parser = optparse.OptionParser(usage) - options, args = parser.parse_args() - if len(args) != 1: - parser.error("Incorrect number of arguments") - else: - username = args[0] - try: - u = db_api.user_get(username) - if u == None: - raise IndexError("User not found") - print u.id, u.email, u.enabled - except Exception, e: - print 'Error finding user', username, ':', str(e) - -if __name__ == '__main__': - main() +#!/usr/bin/env python +# Copyright (c) 2010-2011 OpenStack, LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import optparse +import keystone.db.sqlalchemy.api as db_api + + +def main(): + usage = "usage: %prog username" + parser = optparse.OptionParser(usage) + options, args = parser.parse_args() + if len(args) != 1: + parser.error("Incorrect number of arguments") + else: + username = args[0] + try: + u = db_api.user_get(username) + if u == None: + raise IndexError("User not found") + print u.id, u.email, u.enabled + except Exception, e: + print 'Error finding user', username, ':', str(e) + +if __name__ == '__main__': + main() diff --git a/management/getusergroups.py b/management/getusergroups.py old mode 100644 new mode 100755 index 3fd7d3f9..0e477db0 --- a/management/getusergroups.py +++ b/management/getusergroups.py @@ -1,38 +1,39 @@ -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import optparse -import keystone.db.sqlalchemy.api as db_api - - -def main(): - usage = "usage: %prog user_id" - parser = optparse.OptionParser(usage) - options, args = parser.parse_args() - if len(args) != 1: - parser.error("Incorrect number of arguments") - else: - username = args[0] - try: - g = db_api.user_groups(username) - if g == None: - raise IndexError("User groups not found") - for row in g: - print row - except Exception, e: - print 'Error getting user groups for user', user_id, ':', str(e) - -if __name__ == '__main__': - main() +#!/usr/bin/env python +# Copyright (c) 2010-2011 OpenStack, LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import optparse +import keystone.db.sqlalchemy.api as db_api + + +def main(): + usage = "usage: %prog user_id" + parser = optparse.OptionParser(usage) + options, args = parser.parse_args() + if len(args) != 1: + parser.error("Incorrect number of arguments") + else: + username = args[0] + try: + g = db_api.user_groups(username) + if g == None: + raise IndexError("User groups not found") + for row in g: + print row + except Exception, e: + print 'Error getting user groups for user', user_id, ':', str(e) + +if __name__ == '__main__': + main() diff --git a/management/getusers.py b/management/getusers.py old mode 100644 new mode 100755 index 18a5de56..a33fcc5a --- a/management/getusers.py +++ b/management/getusers.py @@ -1,38 +1,39 @@ -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import optparse -import keystone.db.sqlalchemy.api as db_api - - -def main(): - usage = "usage: %prog tenant_id" - parser = optparse.OptionParser(usage) - options, args = parser.parse_args() - if len(args) != 1: - parser.error("Incorrect number of arguments") - else: - tenant_id = args[0] - try: - u = db_api.user_get_by_tenant(tenant_id) - if u == None: - raise IndexError("Users not found") - for row in u: - print row - except Exception, e: - print 'Error getting users for tenant', tenant_id, ':', str(e) - -if __name__ == '__main__': - main() +#!/usr/bin/env python +# Copyright (c) 2010-2011 OpenStack, LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import optparse +import keystone.db.sqlalchemy.api as db_api + + +def main(): + usage = "usage: %prog tenant_id" + parser = optparse.OptionParser(usage) + options, args = parser.parse_args() + if len(args) != 1: + parser.error("Incorrect number of arguments") + else: + tenant_id = args[0] + try: + u = db_api.user_get_by_tenant(tenant_id) + if u == None: + raise IndexError("Users not found") + for row in u: + print row + except Exception, e: + print 'Error getting users for tenant', tenant_id, ':', str(e) + +if __name__ == '__main__': + main() diff --git a/management/groupadd.py b/management/groupadd.py old mode 100644 new mode 100755 index adec58dc..1a02801a --- a/management/groupadd.py +++ b/management/groupadd.py @@ -1,40 +1,41 @@ -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import optparse -import keystone.db.sqlalchemy.api as db_api -from keystone.db.sqlalchemy import models - - -def main(): - usage = "usage: %prog group_id group_desc" - parser = optparse.OptionParser(usage) - options, args = parser.parse_args() - if len(args) != 2: - parser.error("Incorrect number of arguments") - else: - group_id = args[0] - group_desc = args[1] - try: - g = models.Group() - g.id = group_id - g.desc = group_desc - db_api.group_create(g) - print 'Group', g.id, 'created.' - except Exception, e: - print 'Error creating group', group_id, ':', str(e) - -if __name__ == '__main__': - main() +#!/usr/bin/env python +# Copyright (c) 2010-2011 OpenStack, LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import optparse +import keystone.db.sqlalchemy.api as db_api +from keystone.db.sqlalchemy import models + + +def main(): + usage = "usage: %prog group_id group_desc" + parser = optparse.OptionParser(usage) + options, args = parser.parse_args() + if len(args) != 2: + parser.error("Incorrect number of arguments") + else: + group_id = args[0] + group_desc = args[1] + try: + g = models.Group() + g.id = group_id + g.desc = group_desc + db_api.group_create(g) + print 'Group', g.id, 'created.' + except Exception, e: + print 'Error creating group', group_id, ':', str(e) + +if __name__ == '__main__': + main() diff --git a/management/setuserlock.py b/management/setuserlock.py old mode 100644 new mode 100755 index 622d876b..9effc451 --- a/management/setuserlock.py +++ b/management/setuserlock.py @@ -1,49 +1,50 @@ -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import optparse -import keystone.db.sqlalchemy.api as db_api - - -def main(): - usage = "usage: %prog username enabled" - parser = optparse.OptionParser(usage) - options, args = parser.parse_args() - if len(args) != 2: - parser.error("Incorrect number of arguments") - else: - username = args[0] - enabled = args[1].capitalize().strip() - - if enabled == 'True' or enabled == '1': - enabled = 1 - elif enabled == 'False' or enabled == '0': - enabled = 0 - else: - parser.error("Incorrect arguments value") - - try: - u = db_api.user_get(username) - if u == None: - raise IndexError("User not found") - else: - values = {'enabled': enabled} - db_api.user_update(username, values) - print 'User', u.id, 'updated. Enabled =', enabled - except Exception, e: - print 'Error updating user', username, ':', str(e) - -if __name__ == '__main__': - main() +#!/usr/bin/env python +# Copyright (c) 2010-2011 OpenStack, LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import optparse +import keystone.db.sqlalchemy.api as db_api + + +def main(): + usage = "usage: %prog username enabled" + parser = optparse.OptionParser(usage) + options, args = parser.parse_args() + if len(args) != 2: + parser.error("Incorrect number of arguments") + else: + username = args[0] + enabled = args[1].capitalize().strip() + + if enabled == 'True' or enabled == '1': + enabled = 1 + elif enabled == 'False' or enabled == '0': + enabled = 0 + else: + parser.error("Incorrect arguments value") + + try: + u = db_api.user_get(username) + if u == None: + raise IndexError("User not found") + else: + values = {'enabled': enabled} + db_api.user_update(username, values) + print 'User', u.id, 'updated. Enabled =', enabled + except Exception, e: + print 'Error updating user', username, ':', str(e) + +if __name__ == '__main__': + main() diff --git a/management/setuserpswd.py b/management/setuserpswd.py old mode 100644 new mode 100755 index 6283bf73..9f0abe77 --- a/management/setuserpswd.py +++ b/management/setuserpswd.py @@ -1,41 +1,42 @@ -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import optparse -import keystone.db.sqlalchemy.api as db_api - - -def main(): - usage = "usage: %prog username password" - parser = optparse.OptionParser(usage) - options, args = parser.parse_args() - if len(args) != 2: - parser.error("Incorrect number of arguments") - else: - username = args[0] - password = args[1] - try: - u = db_api.user_get(username) - if u == None: - raise IndexError("User not found") - else: - values = {'password': password} - db_api.user_update(username, values) - print 'User', u.id, 'updated.' - except Exception, e: - print 'Error updating user', username, ':', str(e) - -if __name__ == '__main__': - main() +#!/usr/bin/env python +# Copyright (c) 2010-2011 OpenStack, LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import optparse +import keystone.db.sqlalchemy.api as db_api + + +def main(): + usage = "usage: %prog username password" + parser = optparse.OptionParser(usage) + options, args = parser.parse_args() + if len(args) != 2: + parser.error("Incorrect number of arguments") + else: + username = args[0] + password = args[1] + try: + u = db_api.user_get(username) + if u == None: + raise IndexError("User not found") + else: + values = {'password': password} + db_api.user_update(username, values) + print 'User', u.id, 'updated.' + except Exception, e: + print 'Error updating user', username, ':', str(e) + +if __name__ == '__main__': + main() diff --git a/management/updategroup.py b/management/updategroup.py old mode 100644 new mode 100755 index 598d38ef..0ae64765 --- a/management/updategroup.py +++ b/management/updategroup.py @@ -1,42 +1,43 @@ -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import optparse -import keystone.db.sqlalchemy.api as db_api -from keystone.db.sqlalchemy import models - - -def main(): - usage = "usage: %prog group_id group_desc" - parser = optparse.OptionParser(usage) - options, args = parser.parse_args() - if len(args) != 2: - parser.error("Incorrect number of arguments") - else: - group = args[0] - desc = args[1] - try: - g = db_api.group_get(group) - if g == None: - raise IndexError("Group not found") - else: - values = {'desc': desc} - db_api.group_update(group, values) - print 'Group', g.id, 'updated.' - except Exception, e: - print 'Error updating user', group, ':', str(e) - -if __name__ == '__main__': - main() +#!/usr/bin/env python +# Copyright (c) 2010-2011 OpenStack, LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import optparse +import keystone.db.sqlalchemy.api as db_api +from keystone.db.sqlalchemy import models + + +def main(): + usage = "usage: %prog group_id group_desc" + parser = optparse.OptionParser(usage) + options, args = parser.parse_args() + if len(args) != 2: + parser.error("Incorrect number of arguments") + else: + group = args[0] + desc = args[1] + try: + g = db_api.group_get(group) + if g == None: + raise IndexError("Group not found") + else: + values = {'desc': desc} + db_api.group_update(group, values) + print 'Group', g.id, 'updated.' + except Exception, e: + print 'Error updating user', group, ':', str(e) + +if __name__ == '__main__': + main() diff --git a/management/useradd.py b/management/useradd.py old mode 100644 new mode 100755 index fc3fc8b6..4f04a05f --- a/management/useradd.py +++ b/management/useradd.py @@ -1,42 +1,43 @@ -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import optparse -import keystone.db.sqlalchemy.api as db_api -from keystone.db.sqlalchemy import models - - -def main(): - usage = "usage: %prog username password" - parser = optparse.OptionParser(usage) - options, args = parser.parse_args() - if len(args) != 2: - parser.error("Incorrect number of arguments") - else: - username = args[0] - password = args[1] - try: - u = models.User() - u.id = username - u.email = username - u.password = password - u.enabled = True - db_api.user_create(u) - print 'User', u.id, 'created.' - except Exception, e: - print 'Error creating user', username, ':', str(e) - -if __name__ == '__main__': - main() +#!/usr/bin/env python +# Copyright (c) 2010-2011 OpenStack, LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import optparse +import keystone.db.sqlalchemy.api as db_api +from keystone.db.sqlalchemy import models + + +def main(): + usage = "usage: %prog username password" + parser = optparse.OptionParser(usage) + options, args = parser.parse_args() + if len(args) != 2: + parser.error("Incorrect number of arguments") + else: + username = args[0] + password = args[1] + try: + u = models.User() + u.id = username + u.email = username + u.password = password + u.enabled = True + db_api.user_create(u) + print 'User', u.id, 'created.' + except Exception, e: + print 'Error creating user', username, ':', str(e) + +if __name__ == '__main__': + main() diff --git a/management/userdel.py b/management/userdel.py old mode 100644 new mode 100755 index 928dfc55..62dab47f --- a/management/userdel.py +++ b/management/userdel.py @@ -1,39 +1,40 @@ -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import optparse -import keystone.db.sqlalchemy.api as db_api - - -def main(): - usage = "usage: %prog username" - parser = optparse.OptionParser(usage) - options, args = parser.parse_args() - if len(args) != 1: - parser.error("Incorrect number of arguments") - else: - username = args[0] - try: - u = db_api.user_get(username) - if u == None: - raise IndexError("User not found") - else: - db_api.user_delete(username) - print 'User', username, 'deleted.' - except Exception, e: - print 'Error deleting user', username, ':', str(e) - -if __name__ == '__main__': - main() +#!/usr/bin/env python +# Copyright (c) 2010-2011 OpenStack, LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import optparse +import keystone.db.sqlalchemy.api as db_api + + +def main(): + usage = "usage: %prog username" + parser = optparse.OptionParser(usage) + options, args = parser.parse_args() + if len(args) != 1: + parser.error("Incorrect number of arguments") + else: + username = args[0] + try: + u = db_api.user_get(username) + if u == None: + raise IndexError("User not found") + else: + db_api.user_delete(username) + print 'User', username, 'deleted.' + except Exception, e: + print 'Error deleting user', username, ':', str(e) + +if __name__ == '__main__': + main() diff --git a/management/userupdate.py b/management/userupdate.py old mode 100644 new mode 100755 index 89174d04..a3ff21f2 --- a/management/userupdate.py +++ b/management/userupdate.py @@ -1,41 +1,42 @@ -# Copyright (c) 2010-2011 OpenStack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import optparse -import keystone.db.sqlalchemy.api as db_api - - -def main(): - usage = "usage: %prog username email" - parser = optparse.OptionParser(usage) - options, args = parser.parse_args() - if len(args) != 2: - parser.error("Incorrect number of arguments") - else: - username = args[0] - email = args[1] - try: - u = db_api.user_get(username) - if u == None: - raise IndexError("User not found") - else: - values = {'email': email} - db_api.user_update(username, values) - print 'User', u.id, 'updated.' - except Exception, e: - print 'Error updating user', username, ':', str(e) - -if __name__ == '__main__': - main() +#!/usr/bin/env python +# Copyright (c) 2010-2011 OpenStack, LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import optparse +import keystone.db.sqlalchemy.api as db_api + + +def main(): + usage = "usage: %prog username email" + parser = optparse.OptionParser(usage) + options, args = parser.parse_args() + if len(args) != 2: + parser.error("Incorrect number of arguments") + else: + username = args[0] + email = args[1] + try: + u = db_api.user_get(username) + if u == None: + raise IndexError("User not found") + else: + values = {'email': email} + db_api.user_update(username, values) + print 'User', u.id, 'updated.' + except Exception, e: + print 'Error updating user', username, ':', str(e) + +if __name__ == '__main__': + main() -- cgit