Esempio n. 1
0
def add_vm_to_group_while_creating(username, groupname, vmname):
    '''
    add a vm to a group while the vm is being created, if the group doesn't exist, 
    this will create one
    '''
    GroupManage = GroupManagement(username)
    groups_list = GroupManage.get_groups_names_list()
    if groupname not in groups_list:
        GroupManage.create_group(groupname)
    GroupManage.add_item_to_group(groupname, "VM", vmname)
Esempio n. 2
0
            if GroupName in groups_list:
                vms_in_group_list = GroupManage.list_items_of_group(GroupName, _type="VM")["VM"]

            if not arguments['--force'] and len(vms_in_group_list) != 0:
                if yn_choice("The group you provide exists and it has VMs in it, " + \
                             "do you want to proceed? (if you choose yes, these exist " +\
                             "VMs will be included in the cluster, this could also " +\
                             "rewrite the key on the exist VMs)",
                             default='n',
                             tries=3):
                    pass
                else:
                    return
            
            if GroupName not in groups_list:
                GroupManage.create_group(GroupName)
            GroupManage.add_tag_to_group(GroupName, "cluster")

            # start VMs 
            print ("starting VMs...")
            arguments_temp = arguments
            arguments_temp['start'] = True
            arguments_temp['--name'] = None
            arguments_temp['--group'] = GroupName

            
            vmclass = VMcommand(arguments_temp)
            res = vmclass.execute()
            if res == False: 
                return
        
Esempio n. 3
0
                vms_in_group_list = GroupManage.list_items_of_group(
                    GroupName, _type="VM")["VM"]

            if not arguments['--force'] and len(vms_in_group_list) != 0:
                if yn_choice("The group you provide exists and it has VMs in it, " + \
                             "do you want to proceed? (if you choose yes, these exist " +\
                             "VMs will be included in the cluster, this could also " +\
                             "rewrite the key on the exist VMs)",
                             default='n',
                             tries=3):
                    pass
                else:
                    return

            if GroupName not in groups_list:
                GroupManage.create_group(GroupName)
            GroupManage.add_tag_to_group(GroupName, "cluster")

            # start VMs
            print("starting VMs...")
            arguments_temp = arguments
            arguments_temp['start'] = True
            arguments_temp['--name'] = None
            arguments_temp['--group'] = GroupName

            vmclass = VMcommand(arguments_temp)
            res = vmclass.execute()
            if res == False:
                return

            def string_to_dict(s):