Skip to content

Instantly share code, notes, and snippets.

@schakrava
Created July 13, 2016 21:01
Show Gist options
  • Save schakrava/1647d50405da6e5ee6c92bfe36d8629f to your computer and use it in GitHub Desktop.
Save schakrava/1647d50405da6e5ee6c92bfe36d8629f to your computer and use it in GitHub Desktop.
#!/usr/bin/python
"""
Copyright (c) 2012-2015 RockStor, Inc. <http://rockstor.com>
This file is part of RockStor.
RockStor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
RockStor is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import sys
sys.path[0:0] = [
'/opt/rock-dep/src/rockstor',
'/opt/rock-dep/eggs/supervisor-3.0b1-py2.7.egg',
'/opt/rock-dep/eggs/meld3-1.0.2-py2.7.egg',
'/opt/rock-dep/eggs/setuptools-24.0.2-py2.7.egg',
'/opt/rock-dep/eggs/chardet-2.3.0-py2.7.egg',
'/opt/rock-dep/eggs/psutil-3.3.0-py2.7-linux-x86_64.egg',
'/opt/rock-dep/eggs/psycogreen-1.0-py2.7.egg',
'/opt/rock-dep/eggs/gevent_socketio-0.3.6-py2.7.egg',
'/opt/rock-dep/eggs/gevent_websocket-0.9.5-py2.7.egg',
'/opt/rock-dep/eggs/gevent-1.0.2-py2.7-linux-x86_64.egg',
'/opt/rock-dep/eggs/coverage-4.1-py2.7-linux-x86_64.egg',
'/opt/rock-dep/eggs/mock-1.0.1-py2.7.egg',
'/opt/rock-dep/eggs/django_ztask-0.1.5-py2.7.egg',
'/opt/rock-dep/eggs/six-1.7.3-py2.7.egg',
'/opt/rock-dep/eggs/django_oauth_toolkit-0.9.0-py2.7.egg',
'/opt/rock-dep/eggs/psycopg2-2.6-py2.7-linux-x86_64.egg',
'/opt/rock-dep/eggs/South-1.0.2-py2.7.egg',
'/opt/rock-dep/eggs/pyzmq-15.0.0-py2.7-linux-x86_64.egg',
'/opt/rock-dep/eggs/requests-1.1.0-py2.7.egg',
'/opt/rock-dep/eggs/django_pipeline-1.2.23-py2.7.egg',
'/opt/rock-dep/eggs/pytz-2014.3-py2.7.egg',
'/opt/rock-dep/eggs/djangorestframework-3.1.1-py2.7.egg',
'/opt/rock-dep/eggs/URLObject-2.1.1-py2.7.egg',
'/opt/rock-dep/eggs/distribute-0.7.3-py2.7.egg',
'/opt/rock-dep/eggs/Django-1.6.11-py2.7.egg',
'/opt/rock-dep/eggs/greenlet-0.4.10-py2.7-linux-x86_64.egg',
'/opt/rock-dep/eggs/oauthlib-1.0.1-py2.7.egg',
'/opt/rock-dep/eggs/django_braces-1.9.0-py2.7.egg',
]
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from storageadmin.models import RockOn
def delete_rockon():
try:
name = sys.argv[1]
except IndexError:
sys.exit('Usage: %s <rockon name>' % sys.argv[0])
try:
ro = RockOn.objects.get(name=name)
except RockOn.DoesNotExist:
sys.exit('Rock-On(%s) does not exist' % name)
ro.delete()
print('Rock-On(%s) metadata in the db is deleted' % name)
if __name__ == '__main__':
delete_rockon()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment