def command_metrics(self):
        """
        Return metrics
        """
        # Create the XML document
        metrics = []

        resgrp = self.getEnv("RI_OPENSTACK_RG")
        controller = self.getEnv("RI_OPENSTACK_NOVACONTROLLER")
        user = self.getEnv("RI_OPENSTACK_USERNAME")
        passwd = self.getEnv("RI_OPENSTACK_PASSWORD")

        db = self.getEnv("RI_OPENSTACK_DB")
        dbuser = self.getEnv("RI_OPENSTACK_DBUSERNAME")
        dbpasswd = self.getEnv("RI_OPENSTACK_DBPASSWORD")

        objs = retrieve_openstack_instance.retrieve_instance(
            user, passwd, controller)
        #pdb.set_trace()
        for o in objs:
            metrics.append({
                'ResourceId':
                getattr(o, "name", '').lower().replace(' ', '-'),
                'Status':
                getattr(o, "status", ''),
                'CPUUtil':
                "95",
                'MemUsage':
                "100",
                'ExecHostId':
                getattr(o, "OS-EXT-SRV-ATTR:host", ""),
                'Nics': [{
                    'DeviceName': 'eth0',
                    'NicUsage': '100'
                }],
                'Disks':
                ""
            })

        cc = 0
        (novaComputes, hostStatus, ips, cpuUT, memUsed,
         memTotal) = self.getAllComputeNodes(dbuser, dbpasswd, db)
        #pdb.set_trace()
        for com in novaComputes:
            metrics.append({
                'ResourceId': com,
                'Status': '',
                'CPUUtil': str(cpuUT[cc]),
                'MemUsage': str(memUsed[cc]),
                'ExecHostId': 'xxx',
                'Nics': [],
                'Disks': ""
            })
            cc = cc + 1
        return metrics
    def command_connections(self):
        """
        Get the IP addresses of the nodes from OPENSTACK
        """

        # Set up single dummy connections for now, until we understand this more
        # At least in the Amazon environment

        # Create the XML document
        connections = []
        device = "eth0"
        mac = "00:00:00:00:00:00"

        resgrp = self.getEnv("RI_OPENSTACK_RG")
        controller = self.getEnv("RI_OPENSTACK_NOVACONTROLLER")
        user = self.getEnv("RI_OPENSTACK_USERNAME")
        passwd = self.getEnv("RI_OPENSTACK_PASSWORD")
        db = self.getEnv("RI_OPENSTACK_DB")
        dbuser = self.getEnv("RI_OPENSTACK_DBUSERNAME")
        dbpasswd = self.getEnv("RI_OPENSTACK_DBPASSWORD")
        objs = retrieve_openstack_instance.retrieve_instance(
            user, passwd, controller)
        for o in objs:
            connections.append({
                'ResourceId':
                getattr(o, "name", '').lower().replace(' ', '-'),
                'Nics': []
            })
            ip = getattr(o, "addresses", "").get('private')[0]['addr'] if (
                getattr(o, "addresses", "")) else 'None'
            connections[-1]['Nics'].append({
                'Fqdn': "Fqdn",
                'Ip': ip,
                'Mac': "00:00:00:00:00",
                'DeviceName': "eth0"
            })

        cc = 0
        (novaComputes, hostStatus, ips, cpuUT, memUsed,
         memTotal) = self.getAllComputeNodes(dbuser, dbpasswd, db)
        for com in novaComputes:
            # check host aggregate
            connections.append({'ResourceId': com, 'Nics': []})
            ip = ''
            if len(ips) > 0:
                ip = ips[cc]
            connections[-1]['Nics'].append({
                'Fqdn': "Fqdn",
                'Ip': ip,
                'Mac': "00:00:00:00:00",
                'DeviceName': "eth0"
            })
            cc = cc + 1
        return connections
    def command_inventory(self):
        """
        Return inventory
        """

        # Create the XML document
        inventories = []

        resgrp = self.getEnv("RI_OPENSTACK_RG")
        controller = self.getEnv("RI_OPENSTACK_NOVACONTROLLER")
        user = self.getEnv("RI_OPENSTACK_USERNAME")
        passwd = self.getEnv("RI_OPENSTACK_PASSWORD")

        db = self.getEnv("RI_OPENSTACK_DB")
        dbuser = self.getEnv("RI_OPENSTACK_DBUSERNAME")
        dbpasswd = self.getEnv("RI_OPENSTACK_DBPASSWORD")

        # TODO
        # First get flavors, then get flavor CPU and Memory
        objs = retrieve_openstack_instance.retrieve_instance(
            user, passwd, controller)
        for o in objs:
            inventories.append({
                'ResourceId':
                getattr(o, "name", '').lower().replace(' ', '-'),
                'CPUType':
                "OpenStack",
                'NumCPUs':
                "2",
                'MemSize':
                "1024",
                'NumDisks':
                '1',
                'Disks':
                ""
            })

        cc = 0
        (novaComputes, hostStatus, ips, cpuUT, memUsed,
         memTotal) = self.getAllComputeNodes(dbuser, dbpasswd, db)
        #pdb.set_trace()
        for com in novaComputes:
            inventories.append({
                'ResourceId': com,
                'CPUType': 'Intel',
                'NumCPUs': '2',
                'MemSize': str(memTotal[cc]),
                'NumDisks': '1',
                'Disks': ""
            })
            cc = cc + 1

        return inventories
Exemple #4
0
    def getvmIdByName(self,name):
        controller = self.getEnv("RI_OPENSTACK_NOVACONTROLLER")
        user = self.getEnv("RI_OPENSTACK_USERNAME")
        passwd = self.getEnv("RI_OPENSTACK_PASSWORD")
        objs = retrieve_openstack_instance.retrieve_instance(user, passwd, controller)
        returnId= ''
        for o in objs:
            if cmp(getattr(o, "name", ''), name)==0:
                returnId = getattr(o, "id", '')
                break

        return returnId
    def getvmIdByName(self, name):
        controller = self.getEnv("RI_OPENSTACK_NOVACONTROLLER")
        user = self.getEnv("RI_OPENSTACK_USERNAME")
        passwd = self.getEnv("RI_OPENSTACK_PASSWORD")
        objs = retrieve_openstack_instance.retrieve_instance(
            user, passwd, controller)
        returnId = ''
        for o in objs:
            if cmp(getattr(o, "name", ''), name) == 0:
                returnId = getattr(o, "id", '')
                break

        return returnId
Exemple #6
0
    def command_connections(self):
        """
        Get the IP addresses of the nodes from OPENSTACK
        """

        # Set up single dummy connections for now, until we understand this more
        # At least in the Amazon environment

        # Create the XML document
        connections = []
        device = "eth0"
        mac = "00:00:00:00:00:00"

        resgrp = self.getEnv("RI_OPENSTACK_RG")
        controller = self.getEnv("RI_OPENSTACK_NOVACONTROLLER")
        user = self.getEnv("RI_OPENSTACK_USERNAME")
        passwd = self.getEnv("RI_OPENSTACK_PASSWORD")
        db = self.getEnv("RI_OPENSTACK_DB")
        dbuser = self.getEnv("RI_OPENSTACK_DBUSERNAME")
        dbpasswd = self.getEnv("RI_OPENSTACK_DBPASSWORD")
        objs = retrieve_openstack_instance.retrieve_instance(user, passwd, controller)
        for o in objs:
            connections.append({'ResourceId':getattr(o, "name", '').lower().replace(' ', '-'),
                                'Nics':[]})
            ip = getattr(o, "addresses", "").get('private')[0]['addr'] if(getattr(o, "addresses", "")) else 'None'
            connections[-1]['Nics'].append({'Fqdn':"Fqdn",
                                            'Ip': ip,
                                            'Mac':"00:00:00:00:00",
                                            'DeviceName':"eth0"})
        
        
        cc = 0
        (novaComputes, hostStatus, ips, cpuUT, memUsed, memTotal) = self.getAllComputeNodes(dbuser, dbpasswd, db)
        for com in novaComputes:
            # check host aggregate
            connections.append({'ResourceId':com,
                                'Nics':[]})
            ip = ''
            if len(ips) > 0:
                ip = ips[cc]
            connections[-1]['Nics'].append({'Fqdn':"Fqdn",
                                'Ip':ip,
                                'Mac':"00:00:00:00:00",
                                'DeviceName':"eth0"})
            cc = cc + 1
        return connections
    def command_statuses(self):
        """
        Return status
        """
        cc = 0
        # Create the XML document
        statuses = []

        resgrp = self.getEnv("RI_OPENSTACK_RG")
        controller = self.getEnv("RI_OPENSTACK_NOVACONTROLLER")
        user = self.getEnv("RI_OPENSTACK_USERNAME")
        passwd = self.getEnv("RI_OPENSTACK_PASSWORD")
        db = self.getEnv("RI_OPENSTACK_DB")
        dbuser = self.getEnv("RI_OPENSTACK_DBUSERNAME")
        dbpasswd = self.getEnv("RI_OPENSTACK_DBPASSWORD")

        objs = retrieve_openstack_instance.retrieve_instance(
            user, passwd, controller)
        #pdb.set_trace()
        for o in objs:
            if cmp(getattr(o, "status", ''), "ACTIVE") == 0 or cmp(
                    getattr(o, "status", ''), "MIGRATING") == 0:
                status = "Up"
            else:
                status = "Down"
            statuses.append({
                'ResourceId':
                getattr(o, "name", '').lower().replace(' ', '-'),
                'Status':
                status
            })

        (novaComputes, hostStatus, ips, cpuUT, memUsed,
         memTotal) = self.getAllComputeNodes(dbuser, dbpasswd, db)
        for com in novaComputes:
            # get all PM name and status
            computeName = com
            if hostStatus[cc] == 0:
                status = "Up"
            else:
                status = "Down"

            statuses.append({'ResourceId': computeName, 'Status': status})
            cc = cc + 1
        return statuses
Exemple #8
0
    def command_inventory(self):
        """
        Return inventory
        """

        # Create the XML document
        inventories = []

        resgrp = self.getEnv("RI_OPENSTACK_RG")
        controller = self.getEnv("RI_OPENSTACK_NOVACONTROLLER")
        user = self.getEnv("RI_OPENSTACK_USERNAME")
        passwd = self.getEnv("RI_OPENSTACK_PASSWORD")

        db = self.getEnv("RI_OPENSTACK_DB")
        dbuser = self.getEnv("RI_OPENSTACK_DBUSERNAME")
        dbpasswd = self.getEnv("RI_OPENSTACK_DBPASSWORD")

        # TODO
        # First get flavors, then get flavor CPU and Memory
        objs = retrieve_openstack_instance.retrieve_instance(user, passwd, controller)
        for o in objs:
            inventories.append({'ResourceId':getattr(o, "name", '').lower().replace(' ', '-'),
                                'CPUType':"OpenStack",
                                'NumCPUs':"2",
                                'MemSize':"1024",
                                'NumDisks':'1',
                                'Disks':""})

        cc = 0
        (novaComputes, hostStatus, ips, cpuUT, memUsed, memTotal) = self.getAllComputeNodes(dbuser, dbpasswd, db)
        #pdb.set_trace()
        for com  in novaComputes:
            inventories.append({'ResourceId': com,
                            'CPUType': 'Intel',
                            'NumCPUs': '2',
                            'MemSize': str(memTotal[cc]),
                            'NumDisks':'1',
                            'Disks':""})
            cc = cc + 1

        return inventories
Exemple #9
0
    def command_metrics(self):
        """
        Return metrics
        """
        # Create the XML document
        metrics = []

        resgrp = self.getEnv("RI_OPENSTACK_RG")
        controller = self.getEnv("RI_OPENSTACK_NOVACONTROLLER")
        user = self.getEnv("RI_OPENSTACK_USERNAME")
        passwd = self.getEnv("RI_OPENSTACK_PASSWORD")
      
        db = self.getEnv("RI_OPENSTACK_DB")
        dbuser = self.getEnv("RI_OPENSTACK_DBUSERNAME")
        dbpasswd = self.getEnv("RI_OPENSTACK_DBPASSWORD")

        objs = retrieve_openstack_instance.retrieve_instance(user, passwd, controller)
        #pdb.set_trace() 
        for o in objs:
            metrics.append({'ResourceId':getattr(o, "name", '').lower().replace(' ', '-'),
                            'Status':getattr(o, "status", ''),
                            'CPUUtil':"95",
                            'MemUsage':"100",
                            'ExecHostId':getattr(o, "OS-EXT-SRV-ATTR:host", ""),
                            'Nics':[{'DeviceName':'eth0', 'NicUsage':'100'}],
                            'Disks':""})

        cc = 0
        (novaComputes, hostStatus, ips, cpuUT, memUsed, memTotal) = self.getAllComputeNodes(dbuser, dbpasswd, db)
        #pdb.set_trace()
        for com  in novaComputes:
            metrics.append({'ResourceId': com,
                            'Status': '',
                            'CPUUtil': str(cpuUT[cc]),
                            'MemUsage': str(memUsed[cc]),
                            'ExecHostId':'xxx',
                            'Nics': [],
                            'Disks':""}) 
            cc = cc + 1
        return metrics
Exemple #10
0
    def command_statuses(self):
        """
        Return status
        """
        cc = 0
        # Create the XML document
        statuses = []

        resgrp = self.getEnv("RI_OPENSTACK_RG")
        controller = self.getEnv("RI_OPENSTACK_NOVACONTROLLER")
        user = self.getEnv("RI_OPENSTACK_USERNAME")
        passwd = self.getEnv("RI_OPENSTACK_PASSWORD")
        db = self.getEnv("RI_OPENSTACK_DB")
        dbuser = self.getEnv("RI_OPENSTACK_DBUSERNAME")
        dbpasswd = self.getEnv("RI_OPENSTACK_DBPASSWORD")

        objs = retrieve_openstack_instance.retrieve_instance(user, passwd, controller)
        #pdb.set_trace() 
        for o in objs:
            if cmp(getattr(o, "status", ''), "ACTIVE")==0 or cmp(getattr(o, "status", ''), "MIGRATING")==0:
                status = "Up"
            else:
                status = "Down"
            statuses.append({'ResourceId':getattr(o, "name", '').lower().replace(' ', '-'),
                             'Status':status})
        
        (novaComputes, hostStatus, ips, cpuUT, memUsed, memTotal) = self.getAllComputeNodes(dbuser, dbpasswd, db)
        for com in novaComputes:
            # get all PM name and status
            computeName = com
            if hostStatus[cc] == 0:
                status = "Up"
            else:
                status = "Down"
        
            statuses.append({'ResourceId':computeName,
                         'Status':status})
            cc = cc + 1
        return statuses
    def command_resources(self):
        """
        Get the nodes managed by LS
        """
        self.logger.error("get resource >>>>>>>>>>>>>>>>>>>>.")
        #pdb.set_trace()
        resgrp = self.getEnv("RI_OPENSTACK_RG")
        controller = self.getEnv("RI_OPENSTACK_NOVACONTROLLER")
        user = self.getEnv("RI_OPENSTACK_USERNAME")
        passwd = self.getEnv("RI_OPENSTACK_PASSWORD")
        db = self.getEnv("RI_OPENSTACK_DB")
        dbuser = self.getEnv("RI_OPENSTACK_DBUSERNAME")
        dbpasswd = self.getEnv("RI_OPENSTACK_DBPASSWORD")

        # Create the XML document
        resources = []

        # get all openstack instance
        objs = retrieve_openstack_instance.retrieve_instance(
            user, passwd, controller)
        for o in objs:
            resources.append({
                'ResourceId':
                getattr(o, "name", '').lower().replace(' ', '-'),
                'Caption':
                getattr(o, "name", '').lower().replace(' ', '-'),
                'Description':
                "openstack instance",
                'SubType':
                'Virtual',
                'TemplateId':
                o.image.get('id'),
                'ResourceStatus':
                getattr(o, "status", ''),
                'GroupId':
                ""
            })
            #print field
            #print "dict %s\n" % (o.__dict__)
            #field_name = field.lower().replace(' ', '_')
            name = getattr(o, "name", '')
            id = getattr(o, "id", '')
            status = getattr(o, "status", '')
            networks = getattr(o, "networks", '')
            #print "name %s id %s status %s networks %s" % (name, id, status, networks)
            #print "field %s data %s\n" % (field, data)

        #pdb.set_trace()
        cc = 0
        (novaComputes, hostStatus, ips, cpuUT, memUsed,
         memTotal) = self.getAllComputeNodes(dbuser, dbpasswd, db)
        for com in novaComputes:
            # check host aggregate
            objs = retrieve_openstack_rgs.retrieve_rgs(user, passwd,
                                                       controller)
            for o in objs:
                hosts = getattr(o, "hosts", "")
                if com in hosts:
                    resgrp = getattr(o, "name", "")
                    break
            if hostStatus[cc] == 0:
                status = "Up"
            else:
                status = "Down"
            # get all openstack PM
            resources.append({
                'ResourceId': com,
                'Caption': com,
                'Description': "nova-compute",
                'SubType': 'Physical',
                'TemplateId': "",
                'ResourceStatus': status,
                'GroupId': [resgrp]
            })
            cc = cc + 1
        """
        mock data for storage repository 
        """
        self.getStorageRepository(resources)
        """
        get volumes info 
        """
        self.getVolumes(dbuser, dbpasswd, db, resources)
        """
        get networking info 
        """
        self.getNetworking(dbuser, dbpasswd, db, resources)

        return resources
Exemple #12
0
    def command_resources(self):
        """
        Get the nodes managed by LS
        """
        self.logger.error("get resource >>>>>>>>>>>>>>>>>>>>.") 
        #pdb.set_trace() 
        resgrp = self.getEnv("RI_OPENSTACK_RG")
        controller = self.getEnv("RI_OPENSTACK_NOVACONTROLLER") 
        user = self.getEnv("RI_OPENSTACK_USERNAME") 
        passwd = self.getEnv("RI_OPENSTACK_PASSWORD")
        db = self.getEnv("RI_OPENSTACK_DB") 
        dbuser = self.getEnv("RI_OPENSTACK_DBUSERNAME") 
        dbpasswd = self.getEnv("RI_OPENSTACK_DBPASSWORD")
 
        # Create the XML document
        resources = [] 

        # get all openstack instance
        objs = retrieve_openstack_instance.retrieve_instance(user, passwd, controller)
        for o in objs:
            resources.append({'ResourceId':getattr(o, "name", '').lower().replace(' ', '-'),
                                  'Caption':getattr(o, "name", '').lower().replace(' ', '-'),
                                  'Description':"openstack instance",
                                  'SubType':'Virtual',
                                  'TemplateId':o.image.get('id'),
                                  'ResourceStatus':getattr(o, "status", ''),
                                  'GroupId':""})
            #print field
            #print "dict %s\n" % (o.__dict__)
            #field_name = field.lower().replace(' ', '_')
            name = getattr(o, "name", '')
            id = getattr(o, "id", '')
            status = getattr(o, "status", '')
            networks = getattr(o, "networks", '')
            #print "name %s id %s status %s networks %s" % (name, id, status, networks)
            #print "field %s data %s\n" % (field, data)

        #pdb.set_trace()
        cc = 0
        (novaComputes, hostStatus, ips, cpuUT, memUsed, memTotal) = self.getAllComputeNodes(dbuser, dbpasswd, db)
        for com in novaComputes:
            # check host aggregate
            objs = retrieve_openstack_rgs.retrieve_rgs(user, passwd, controller)
            for o in objs:
                hosts = getattr(o, "hosts", "")
                if com in hosts:
                    resgrp = getattr(o, "name", "")
                    break
            if hostStatus[cc] == 0:
                status = "Up"
            else:
                status = "Down"
            # get all openstack PM
            resources.append({'ResourceId':com,
                                      'Caption':com,
                                      'Description':"nova-compute",
                                      'SubType':'Physical',
                                      'TemplateId':"",
                                      'ResourceStatus':status,
                                      'GroupId':[resgrp]})
            cc = cc + 1
        """
        mock data for storage repository 
        """
        self.getStorageRepository(resources)
            
        """
        get volumes info 
        """
        self.getVolumes(dbuser, dbpasswd, db,resources)

        """
        get networking info 
        """
        self.getNetworking(dbuser, dbpasswd, db,resources)
     
        return resources