import subprocess
import os
from baseCheck import baseCheck

class orphanvm(baseCheck):

    def getHumanName(self):
        return "Check for VMs with no access"

    def runCheck(self,config, debug):
        # confirm no VM's exist that have blank private and blank customerIP
        returnCode=0
        
        for server in config["environment"]["servers"]:
            for vm in server['vms']:
                ipc = vm['customerIP']
                ipp = vm['privateIP']
                if ipc == "" and ipp == "":
                    # this is a problem.
                    addFailure("Vm "+vm["name"]+" on host node "+server["accessIP"]+" is orphaned. It is not on the private or public network. Please assign an IP address on the private network at least.")

        return returnCode
