Ejemplo n.º 1
0
 def __init__(self, hostname=None, ssh_port=22, username=Node.DEFAULT_USER, password=None, isRemote=False, helper=None, use_keys=False, address=None):
     self.hostname = hostname
     self.ssh_port = ssh_port
     self.username = username
     self.id = getHexID(hostname, [MANAGED_NODE])
     self.password = password
     self.isRemote = isRemote
     self.helper = helper
     self.use_keys = use_keys
     self.credential = Credential(self.id, u'', ssh_port=ssh_port, username=username, password=password, use_keys=use_keys)
     if not address:
         self.address = hostname
     else:
         self.address = address
     self.setup_config = None
     self._node_proxy_lock = threading.RLock()
     self._node_proxy = None
     self._lvm_proxy = None
     self._isLVMEnabled = None
     self._config = None
     self._environ = None
     self._exec_path = None
     self.metrics = None
     self.current_state = AvailState(self.id, EntityType.MANAGED_NODE, self.UP, AvailState.MONITORING, description=u'Newly created node.')
     self.push_bash_timeout_script()
     return None
Ejemplo n.º 2
0
Archivo: Entity.py Proyecto: smarkm/ovm
    def __init__(self, context):
        self.id = getHexID()
        if not isinstance(context, dict):
            LOGGER.debug('Entity context should be a dictionary')
            raise Exception('Entity context should be a dictionary')

        for k,v in context.items():
            setattr(self, k, v)
Ejemplo n.º 3
0
 def __init__(self, mail_server, desc, port, use_secure, site_id, useremail, password):
     self.id = getHexID()
     self.mail_server = to_unicode(mail_server)
     self.description = desc
     self.port = port
     self.use_secure = use_secure
     self.site_id = site_id
     self.credential = Credential(self.id, u'', user_email=useremail, password=password)
Ejemplo n.º 4
0
 def __init__(self, entity_id, state, monit_state, timestamp, description, endtime=None, period=None):
     self.id = getHexID()
     self.entity_id = entity_id
     self.state = state
     self.timestamp = timestamp
     self.description = description
     self.monit_state = monit_state
     self.endtime = endtime
     self.period = period
Ejemplo n.º 5
0
 def __init__(self, node_id, vm_id, avail_state, monit_state, transient_state, transient_state_time, owner):
     self.id = getHexID()
     self.node_id = node_id
     self.vm_id = vm_id
     self.avail_state = avail_state
     self.monit_state = monit_state
     self.transient_state = transient_state
     self.transient_state_time = transient_state_time
     self.owner = owner
     self.timestamp = datetime.now()
Ejemplo n.º 6
0
 def create_network(self, nw_name, nw_desc, nw_type, nw_bridge, nw_address_space, nw_dhcp_range, nat_radio, nw_nat_fwding, site_id, group_id, node_id, op_level, nw_gateway, nw_ip_address, nw_use_vlan, nw_vlan_id, nw_isbonded, nw_slaves, interface, vlan_id_pool_id, sp_id, csep_context_id, csep_id, cp_id):
     nw_id = getHexID()
     t = self.add_nw_defn(nw_name, nw_desc, nw_type, nw_bridge, nw_address_space, nw_dhcp_range, nat_radio, nw_nat_fwding, site_id, group_id, node_id, op_level, nw_gateway, nw_ip_address, nw_use_vlan, nw_vlan_id, nw_isbonded, nw_slaves, interface, vlan_id_pool_id, sp_id, csep_context_id, csep_id, nw_id, cp_id)
     t = eval(t)
     finish,status = wait_for_task_completion(t.get('task_id'), 5000)
     if finish == True and status == Task.SUCCEEDED:
         nw_def = DBSession.query(NwDef).filter(NwDef.id == nw_id).first()
         vlan_info = nw_def.vlan_info
         result = {'nw_id': nw_id, 'nw_vlan_id': vlan_info.get('vlan_id')}
         return result
Ejemplo n.º 7
0
Archivo: Groups.py Proyecto: smarkm/ovm
 def __init__(self, name, node_list=None, group_vars=None):
     self.name = name
     self.id = getHexID(name, [constants.SERVER_POOL])
     self.n_list = {}
     self.groupVars = {}
     self.alloc_policy = SimpleAllocationPolicy(self)
     if node_list is not None:
         self.n_list = node_list
     if group_vars is not None:
         self.groupVars = group_vars
     self.current_state = AvailState(self.id, EntityType.SERVER_POOL, None, AvailState.MONITORING, description=u'New ServerPool')
Ejemplo n.º 8
0
Archivo: IP.py Proyecto: smarkm/ovm
 def __init__(self, name, cidr=None, iplist=None, description=None):
     self.id = getHexID()
     self.name = name
     self.cidr = cidr
     self.iplist = iplist
     self.ip_networks = []
     self.description = description
     self._validate_network()
     self._validate_range_with_network()
     self._populate_ips_table()
     self.total = len(self.ips)
     self.used = 0
     LOGGER.debug('name:%s, cidr:%s, iplist:%s, total:%s' % (self.name, self.cidr, self.iplist, self.total))
Ejemplo n.º 9
0
 def add_vm_restore_result(self, backup_id, vm_id, start_time, end_time, status, result, bkp_result_id=None):
     bkp_result = VMRestoreResult()
     bkp_result.id = getHexID()
     bkp_result.backup_id = backup_id
     bkp_result.vm_id = vm_id
     bkp_result.start_time = start_time
     bkp_result.end_time = end_time
     bkp_result.status = status
     bkp_result.result = result
     bkp_result.backup_result_id = bkp_result_id
     DBSession.add(bkp_result)
     transaction.commit()
     return bkp_result.id
Ejemplo n.º 10
0
 def add_vlan_id_pool(self, auth, site_id, name, desc, range, interface, sp_ids, cidr, num_hosts):
     LOGGER.info("Adding VLAN ID Pool..")
     vlan_id_pool = VLANIDPool()
     vlan_id_pool_id = getHexID()
     vlan_id_pool.id = vlan_id_pool_id
     vlan_id_pool.name = name
     vlan_id_pool.description = desc
     vlan_id_pool.range = range
     vlan_id_pool.interface = interface
     vlan_id_pool.cidr = cidr
     vlan_id_pool.num_hosts = num_hosts
     rnge = range.split("-")
     diff = int(rnge[1]) - int(rnge[0])
     vlan_id_pool.total = diff
     network_size = num_hosts
     num_networks = diff + 1
     vlan_start = rnge[0]
     vlan_nw_infos = self.get_vlan_network_info(cidr, num_networks, network_size, vlan_start, interface)
     for info_dict in vlan_nw_infos:
         vlan_nw_info_db = self.create_vlan_network_info_db(info_dict)
         vlan_id_pool.vlan_nws_infos.append(vlan_nw_info_db)
     LOGGER.info("VLAN Network info added.")
     self.attach_vlan_id_pool(sp_ids, vlan_id_pool)
     nums = range.split("-")
     first_num = nums[0]
     last_num = nums[1]
     i = first_num
     while int(i) <= int(last_num):
         vlan_id = VLANID()
         vlan_id.id = getHexID()
         vlan_id.vlan_id = int(i)
         vlan_id.used_by = None
         vlan_id_pool.vlan_ids.append(vlan_id)
         i = int(i) + 1
     LOGGER.info("VLAN IDs are added")
     DBSession.add(vlan_id_pool)
     transaction.commit()
     LOGGER.info("VLAN ID Pool is added.")
Ejemplo n.º 11
0
 def attach_vlan_id_pool(self, sp_ids, vlan_id_pool):
     if sp_ids:
         id_list = sp_ids.split(",")
         for each_id in id_list:
             vlan_id_pool_sp_rel = None
             vlan_id_pool_sp_rel = (
                 DBSession.query(VLANIDPoolSPRelation)
                 .filter_by(vlan_id_pool_id=vlan_id_pool.id, sp_id=each_id)
                 .first()
             )
             if not vlan_id_pool_sp_rel:
                 vlan_id_pool_sp_rel = VLANIDPoolSPRelation()
                 vlan_id_pool_sp_rel.id = getHexID()
                 vlan_id_pool_sp_rel.sp_id = each_id
                 vlan_id_pool.vlan_id_pool_sp_relation.append(vlan_id_pool_sp_rel)
                 LOGGER.info("SP relation is added to VLAN ID Pool")
Ejemplo n.º 12
0
 def add_restore_detail_result(self, result_id, phase, status, details, cms_start=False, seq=0, restore_service=None):
     s_seq = seq
     if details:
         seq,s_seq = self.get_comment_prefix(seq)
         bkp_result = VMRestoreDetailResult()
         bkp_result.id = getHexID()
         bkp_result.result_id = result_id
         bkp_result.phase = phase
         bkp_result.status = status
         bkp_result.details = s_seq + '-' + details
         bkp_result.dt_time = datetime.now()
         DBSession.add(bkp_result)
         if not cms_start:
             transaction.commit()
         if restore_service:
             restore_service.seq = seq
     return bkp_result.id
Ejemplo n.º 13
0
 def __init__(
     self,
     cidr=None,
     dhcp_start=None,
     dhcp_end=None,
     gateway=None,
     netmask=None,
     vlan_id=None,
     vpn_private_address=None,
     broadcast=None,
     bridge=None,
 ):
     self.id = getHexID()
     self.cidr = cidr
     self.dhcp_start = dhcp_start
     self.dhcp_end = dhcp_end
     self.gateway = gateway
     self.netmask = netmask
     self.vlan_id = vlan_id
     self.vpn_private_address = vpn_private_address
     self.broadcast = broadcast
     self.bridge = bridge
Ejemplo n.º 14
0
    def create_disk(self, context, managed_node=None):
        storage_disk_id = ''
        storage_id = ''
        hex_id = getHexID()

        try:
            if not managed_node:
                managed_node,storage_id,create_flag, delete_flag= StorageManager().get_storage_and_node()
            context['hex_id'] = hex_id
            task_id = self.tc.create_disk_task(session['auth'], context, managed_node.id)
            finish,status = wait_for_task_completion(task_id, 5000)
            if (finish == True) and (status == Task.SUCCEEDED):
                disk = StorageManager().get_reserve_disk(hex_id)
                if disk:
                    storage_id = disk.storage_id
                    storage_disk_id = disk.id
                    StorageManager().unreserve_disk(storage_disk_id)
            return (storage_disk_id, storage_id)

        except Exception as ex:
            print_traceback()
            StorageManager().unreserve_disk(hex_id)
            raise Exception('Storage disk creation is failed')
Ejemplo n.º 15
0
 def __init__(self, type):
     self.type = type
     self.id = getHexID(type, [constants.NODEINFO_COMPONENT])
Ejemplo n.º 16
0
 def get_platform_image(self):
     from stackone.model.ImageStore import VcenterImage
     platform = self.get_platform()
     return VcenterImage(getHexID(), platform, 'VMWTempImg', location=None)
Ejemplo n.º 17
0
 def __init__(self, platform_type, display, desc=None):
     self.id = getHexID()
     self.name = platform_type
     self.display = display
     self.desc = desc
Ejemplo n.º 18
0
 def __init__(self, name):
     self.name = name
     self.id = getHexID()
Ejemplo n.º 19
0
 def __init__(self, host, port, ssl, username, password):
     self.id = getHexID()
     self.port = port
     self.host = host
     self.ssl = ssl
     self.credential = Credential(self.id, u'', username=username, password=password)
Ejemplo n.º 20
0
Archivo: IP.py Proyecto: smarkm/ovm
 def __init__(self):
     self.id = getHexID()
Ejemplo n.º 21
0
Archivo: Sites.py Proyecto: smarkm/ovm
 def __init__(self, name):
     self.name = name
     self.id = getHexID(name, [constants.DATA_CENTER])
Ejemplo n.º 22
0
 def __init__(self, name):
     self.name = name
     self.id = getHexID(name, [constants.APPLIANCE_CATALOG])
Ejemplo n.º 23
0
 def edit_vlan_id_pool(self, auth, site_id, vlan_id_pool_id, desc, range, sp_ids, name):
     LOGGER.info("Editing VLAN ID Pool..")
     vlan_id_pool = DBSession.query(VLANIDPool).filter_by(id=vlan_id_pool_id).first()
     if vlan_id_pool:
         list_to_delete = []
         range_old = vlan_id_pool.range
         vlan_id_pool.name = name
         vlan_id_pool.description = desc
         vlan_id_pool.range = range
         DBSession.add(vlan_id_pool)
         interface = vlan_id_pool.interface
         self.attach_vlan_id_pool(sp_ids, vlan_id_pool)
         self.detach_vlan_id_pool(site_id, sp_ids, vlan_id_pool_id)
         nums_old = range_old.split("-")
         first_num_old = int(nums_old[0])
         last_num_old = int(nums_old[1])
         nums = range.split("-")
         first_num = int(nums[0])
         last_num = int(nums[1])
         if first_num < first_num_old:
             LOGGER.info("Range increased at start...")
             i = 0
             i = first_num
             while int(i) < int(first_num_old):
                 vlan_id = VLANID()
                 vlan_id.id = getHexID()
                 vlan_id.vlan_id = int(i)
                 vlan_id.vlan_id_pool_id = vlan_id_pool_id
                 vlan_id.used_by = None
                 DBSession.add(vlan_id)
                 i = int(i) + 1
             network_size = vlan_id_pool.num_hosts
             num_networks = int(first_num_old) - int(first_num)
             cidr = vlan_id_pool.cidr
             vlan_start = int(first_num)
             self.create_vlan_network_info(vlan_id_pool, cidr, num_networks, network_size, vlan_start, interface)
         else:
             if last_num > last_num_old:
                 LOGGER.info("Range increased at end...")
                 i = 0
                 i = int(last_num_old) + 1
                 while int(i) <= int(last_num):
                     vlan_id = VLANID()
                     vlan_id.id = getHexID()
                     vlan_id.vlan_id = int(i)
                     vlan_id.vlan_id_pool_id = vlan_id_pool_id
                     vlan_id.used_by = None
                     DBSession.add(vlan_id)
                     i = int(i) + 1
                 network_size = vlan_id_pool.num_hosts
                 num_networks = int(last_num) - int(last_num_old)
                 cidr = vlan_id_pool.cidr
                 vlan_start = int(last_num_old)
                 self.create_vlan_network_info(vlan_id_pool, cidr, num_networks, network_size, vlan_start, interface)
         if first_num > first_num_old:
             LOGGER.info("Range decreased at start...")
             i = 0
             i = first_num_old
             while int(i) < int(first_num):
                 list_to_delete.append(i)
                 i = int(i) + 1
         else:
             if last_num < last_num_old:
                 LOGGER.info("Range decreased at end...")
                 i = 0
                 i = int(last_num) + 1
                 while int(i) <= int(last_num_old):
                     list_to_delete.append(i)
                     i = int(i) + 1
         LOGGER.info("VLAN IDs to be deleted are " + to_str(list_to_delete))
         if list_to_delete:
             DBSession.query(VLANID).filter(VLANID.vlan_id.in_(list_to_delete)).filter(
                 VLANID.vlan_id_pool_id == vlan_id_pool_id
             ).delete()
             self.delete_vlan_network_info(vlan_id_pool, list_to_delete)
             LOGGER.info("Out of range VLAN IDs are deleted")
         LOGGER.info("VLAN IDs are updated")
         transaction.commit()
Ejemplo n.º 24
0
 def __init__(self, entity_id, type, **kwargs):
     self.id = getHexID()
     self.entity_id = entity_id
     self.cred_type = type
     self.cred_details = kwargs
Ejemplo n.º 25
0
 def __init__(self, provider_id):
     self.provider_id = provider_id
     self.id = getHexID(provider_id, [constants.APPLIANCE_FEED])
Ejemplo n.º 26
0
 def __init__(self, title):
     self.title = title
     self.id = getHexID()
Ejemplo n.º 27
0
 def __init__(self, name):
     self.name = name
     self.id = getHexID(name, [constants.VDC_FOLDER])
Ejemplo n.º 28
0
 def __init__(self, node):
     self.id = getHexID()
     self.node_id = node.id
     self.node = node
     self.config = {}
     self._NodeConfiguration__populateDefaultEntries()
Ejemplo n.º 29
0
 def __init__(self, name):
     self.name = name
     self.id = getHexID(name, [constants.NODEINFO_CATEGORY])