Beispiel #1
0
def sg_delete(sg_name):
    try:
        system = ibox_login("ibox1499")
        sg = system.cons_groups.find(
            system.cons_groups.fields.name == sg_name).to_list()
        if sg:
            for sgn in sg:
                if sgn.get_type() != 'SNAPSHOT':
                    print "{} is not an Snap Group".format(sg_name)
                    return False, "Not SnapGroup provided"

                #members=sgn.get_members().to_list()
                #for member in members:
                #        print "member is {} has_children is {}".format(member,member.has_children())
                #        if member.has_children():
                #                print "{} - has snapshot(s)!!! cannot delete".format(member.get_name())
                #                return False,"Volume has snapshots, cannot be deleted"
                print "Deleting {}".format(sg_name)
                sgn.delete(delete_members=True)
                return True, "Deleted"
        else:
            print "{} - Cannot be found".format(sg_name)
            return False, "Cannot be found"
    except Exception as E:
        print "caught exception {}".format(E)
        return False, E
def snap_delete(snap_name):
        try:
                system=ibox_login("ibox1499")
                snap=system.volumes.find(system.volumes.fields.name == snap_name,type='SNAPSHOT').to_list()
                if snap:
			snapn=snap[0]
			if snapn.get_family_master().get_cons_group():
				print "Snapshot master volume is in a CG ";
				return False,"Master is in CG";
			return snapn.delete()
                else:
                        print "{} - Cannot be found".format(snap_name)
			return False, "Cannot be found"
        except Exception as E:
                print "caught exception {}".format(E)
                return False,E
Beispiel #3
0
from __future__ import print_function
from infinini import ibox_login
from infinisdk import Q
system = ibox_login("infinibox01-vip.dc01")
vol_snaps = system.volumes.find(Q.type == 'snapshot').to_list()
fs_snaps = system.filesystems.find(Q.type == 'snapshot').to_list()
header = """ --------------------+--------------------+----------+------+-------+------------
Volume               Snapshot             Size       Online Status  New Data
Name                 Name                 (MB)                      (MB)
--------------------+--------------------+----------+------+-------+------------"""


def get_master_id(vol):
    if vol.get_type() == 'MASTER':
        return vol
    else:
        return get_master_id(vol.get_parent())


print(header)
for snap in vol_snaps:
    #parent=snap.get_family_master()
    ## to handle INFINIBOX-33269
    parent = get_master_id(snap)
    if (parent.get_id()):
        parent_name = parent.get_name()
        name = snap.get_name()
        size = parent.get_size().bits / 8 / 1024 / 1024
        new_data = snap.get_size().bits / 8 / 1024 / 1024
        online_status = "Okay"
        print(parent_name, name, size, online_status, new_data)
Beispiel #4
0
if __name__ == '__main__':
    args = get_args()
    if args.vol is not None:
	vol=args.vol[0]
        callwipe(args.vol[0])
        exit
    else:
        cfgargs = args_from_cfgfile()
        source_box_name_or_fqdn=cfgargs['source_system']
        target_box_name_or_fqdn=cfgargs['target_system']
        map_host=cfgargs['map_to']
        volume=args.volume[0]
        size=(args.size[0])*GiB
        setup_logger(map_host)
        try:
            source_box, source_box_auth=ibox_login(source_box_name_or_fqdn)
            target_box, target_box_auth=ibox_login(target_box_name_or_fqdn)
            print "Getting CG Object"
            logging.info("Getting CG Object")
            cg_object=get_vol_cg(source_box,volume)
            if (not cg_object):
                logging.error("unable to get volume CG")
                raise Exception("unable to get volume CG")
	    print "CG is {}".format(cg_object.get_name())
	    logging.info("CG is {}".format(cg_object.get_name()))
	    print "Getting CG ID"
	    logging.info("Getting CG ID")
	    cg_id=cg_object.get_id()
	    print "Getting Replica"
	    logging.info("Getting Replica")
	    replica_object, replica_json=get_cg_replica(source_box,source_box_name_or_fqdn, source_box_auth, cg_id)
Beispiel #5
0
from infinini import ibox_login
from sg_delete import sg_delete
ibox_login('ibox1499')
p = sg_delete('XL_CG')
print p