def validateService(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']
        
        #引数のチェック
        result = CommonUtils.checkArguments(method, paramDict)
        if result != True:
            return {'result':'1','message':result}
        
        #変数設定
        imageNo = paramDict['imageNo']
        serviceList = paramDict['serviceList']
        
        #イメージ存在チェック
        try:
            imageData = CommonUtils.getImageDataByNo(imageNo)
        except Exception as e:
            return {'reslut':'1','message':"イメージ情報の呼び出しに失敗したためサービス情報の追加を中止します。管理者に連絡を行って下さい。"}
        if imageData == None:
            return {'result':'1','message':"imageNo:" + imageNo + "が存在しません。サービス情報の追加を中止します。"}
        
        #serviceList存在チェック
        serviceNameList = serviceList.split(",")
        serviceNoList = []
        for serviceName in serviceNameList:
            try:
                result =  CommonUtils.getComponentTypeNoByName(serviceName)
                if result == None:
                    return {'result':'1','message':"サービス名称:" + serviceName + "が存在しません。サービス名称を確認して下さい。"}
                else:
                    serviceNoList.append(result)
            except Exception as e:
                return {'result':'1','message':"サービス情報の取得に失敗したためサービス情報の追加を中止します。管理者に連絡を行って下さい。"}

        #登録用データ作成
        compTypeNoList = imageData['COMPONENT_TYPE_NOS'].split(",")
        serviceNoList.extend(compTypeNoList)
        serviceNoList = list(set(serviceNoList))
        if "0" in serviceNoList:
            serviceNoList.remove("0")
        serviceNoList.sort()
        serviceNoList = ",".join(serviceNoList)

        #サービス情報追加
        try:
            image = self.conn.getTable("IMAGE")
            imageData = self.conn.selectOne(image.select(image.c.IMAGE_NO == imageNo))
            imageData['COMPONENT_TYPE_NOS'] = serviceNoList
            sql = image.update(image.c.IMAGE_NO == imageNo, values = imageData)
            self.conn.execute(sql)
            self.conn.commit()
            return {'result':'0','message':"イメージNo:" + imageNo + "上で利用可能なサービス情報:" + serviceList + "の追加に成功しました。"}
        except Exception as e:
            self.conn.rollback()
            return {'result':'1','message':"利用可能サービス情報:" + serviceList + "の追加に失敗しました。処理を終了します。"}
Exemplo n.º 2
0
    def disableService(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']

        #引数のチェック
        result = CommonUtils.checkArguments(method, paramDict)
        if result != True:
            return {'result': '1', 'message': result}

        #変数設定
        serviceName = paramDict['serviceName']

        #getComponentTypeDataByName呼び出し
        try:
            serviceData = CommonUtils.getComponentTypeDataByName(serviceName)
        except Exception as e:
            return {
                'result': '1',
                'message': "サービス情報の取得に失敗したため無効化処理を中止します。管理者に連絡を行って下さい。"
            }
        if serviceData == None:
            return {
                'result': '1',
                'message': "指定されたサービス名称が存在しません。無効化対象を確認して下さい。"
            }
        if serviceData['SELECTABLE'] == 0:
            return {'result': '1', 'message': "指定されたサービスは既に無効状態です。処理を中止します。"}

        #サービスの無効化
        try:
            componentType = self.conn.getTable("COMPONENT_TYPE")
            compTypeData = self.conn.selectOne(
                componentType.select(
                    componentType.c.COMPONENT_TYPE_NAME == serviceName))
            compTypeData['SELECTABLE'] = 0
            sql = componentType.update(
                componentType.c.COMPONENT_TYPE_NAME == serviceName,
                values=compTypeData)
            self.conn.execute(sql)
            self.conn.commit()
            return {
                'result': '0',
                'message': "サービス名:" + serviceName + "を無効化しました。"
            }
        except Exception as e:
            self.conn.rollback()
            return {
                'result':
                '1',
                'message':
                "COMPONENT_TYPEテーブルの無効化に失敗したため処理を中止します。サービス名:" + serviceName
            }
Exemplo n.º 3
0
    def showService(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']

        #引数のチェック
        result = CommonUtils.checkArguments(method, paramDict)
        if result != True:
            return {'result': '1', 'message': result}

        #変数設定
        serviceName = paramDict['serviceName']

        #サービス名称存在チェック
        try:
            compTypeNo = CommonUtils.getComponentTypeNoByName(serviceName)
        except Exception as e:
            return {
                'result': '1',
                'message': "サービス名称の取得に失敗したためサービス情報表示を中止します。管理者に連絡を行って下さい。"
            }
        if compTypeNo == None:
            return {
                'result': '1',
                'message': "指定されたサービス名称は存在しません。サービス情報表示対象を確認して下さい。"
            }

        #サービスデータ取得
        try:
            componentType = self.conn.getTable("COMPONENT_TYPE")
            compTypeData = self.conn.selectOne(
                componentType.select(
                    componentType.c.COMPONENT_TYPE_NAME == serviceName))
        except Exception as e:
            return {
                'result': '1',
                'message': "サービスデータの取得に失敗したためサービス情報表示を中止します。管理者に連絡を行って下さい。"
            }
        #getSeteclatbeStatus呼び出し
        try:
            result = CommonUtils.getSelectableStatus(
                compTypeData['SELECTABLE'])
        except Exception as e:
            return {
                'result': '1',
                'message': "ステータス名称の取得に失敗したためサービス情報表示を中止します。管理者に連絡を行って下さい。"
            }
        compTypeData['SELECTABLE'] = result

        #返却用データの編集
        retData = json.dumps(compTypeData, ensure_ascii=False)

        return {'result': '0', 'message': "success", 'data': retData}
Exemplo n.º 4
0
    def listImage(self):
        #データの取得
        try:
            table = self.conn.getTable("IMAGE")
        except Exception as e:
            return {'result':'1','message':"IMAGEテーブルが存在しません。管理者に連絡を行って下さい。"}
        imageDataList = self.conn.select(table.select())
        strImageDataList = []
        status = None
        
        if len(imageDataList) == 0:
            return  {'result':'1','message':"OSイメージが登録されていません。"}
        
        for imageData in imageDataList:
            #ステータスの取得
            try:
                status = CommonUtils.getSelectableStatus(imageData["SELECTABLE"])
            except Exception as e:
                return {'result':'1','message':"ステータス名称の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"}
            
            #SELECTABLEの値をenable/disableに変換
            imageData["SELECTABLE"] = status
            #JSON形式に変換し、リストに追加
            strImageDataList.append(json.dumps(imageData, ensure_ascii=False))

        #リストを"&&"で結合
        retData = "&&".join(strImageDataList)
        
        return {'result':'0', 'message':"suucess", 'data':retData}
Exemplo n.º 5
0
    def listService(self):
        try:
            #サービスリストの一覧取得
            table = self.conn.getTable("COMPONENT_TYPE")
            compTypeDataList = self.conn.select(table.select())
        except Exception as e:
            return {'result': '1', 'message': "サービスリストの登録に失敗したため処理を中止します。"}
        strCompTypeDataList = []
        status = None

        if len(compTypeDataList) == 0:
            return {'result': '1', 'message': "サービスデータが登録されていません。"}

        for compTypeData in compTypeDataList:
            try:
                status = CommonUtils.getSelectableStatus(
                    compTypeData['SELECTABLE'])
            except Exception as e:
                return {
                    'result': '1',
                    'message': "ステータス名称の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"
                }
            #SELECTABLEの値をenable/disableに変換
            compTypeData['SELECTABLE'] = status
            #JSON形式に変換し、リストに追加
            strCompTypeData = json.dumps(compTypeData, ensure_ascii=False)
            strCompTypeDataList.append(strCompTypeData)

        #リストを"&&"で結合
        retData = "&&".join(strCompTypeDataList)

        return {'result': '0', 'message': "success", 'data': retData}
 def listService(self):
     try:
         #サービスリストの一覧取得
         table = self.conn.getTable("COMPONENT_TYPE")
         compTypeDataList = self.conn.select(table.select())
     except Exception as e:
         return {'result':'1','message':"サービスリストの登録に失敗したため処理を中止します。"}
     strCompTypeDataList = []
     status = None
     
     if len(compTypeDataList) == 0:
         return {'result':'1','message':"サービスデータが登録されていません。"}
     
     for compTypeData in compTypeDataList:
         try:
             status = CommonUtils.getSelectableStatus(compTypeData['SELECTABLE'])
         except Exception as e:
             return {'result':'1','message':"ステータス名称の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"}
         #SELECTABLEの値をenable/disableに変換
         compTypeData['SELECTABLE'] = status
         #JSON形式に変換し、リストに追加
         strCompTypeData = json.dumps(compTypeData, ensure_ascii=False)
         strCompTypeDataList.append(strCompTypeData)
     
     #リストを"&&"で結合
     retData = "&&".join(strCompTypeDataList)
     
     return {'result':'0', 'message':"success", 'data':retData}
Exemplo n.º 7
0
def baosteel_certificate_pdf_sample_vl_a():
    test_file_vl_a = 'J0E0061697_BGSAJ2009120012700.pdf'
    abs_path = os.path.abspath(test_file_vl_a)
    if os.path.exists(test_file_vl_a):
        os.remove(test_file_vl_a)
    file_source = os.path.abspath(r"../test_data")
    shutil.copy(os.path.join(file_source, test_file_vl_a), test_file_vl_a)
    with CommonUtils.open_file(abs_path) as pdf_file:
        yield pdf_file
Exemplo n.º 8
0
def baosteel_certificate_pdf_sample_vl_d36():
    test_file_vl_d36 = 'J9H0001126_BGSAJ2001130008400.pdf'
    abs_path = os.path.abspath(test_file_vl_d36)
    if os.path.exists(test_file_vl_d36):
        os.remove(test_file_vl_d36)
    file_source = os.path.abspath(r"../test_data")
    shutil.copy(os.path.join(file_source, test_file_vl_d36), test_file_vl_d36)
    with CommonUtils.open_file(abs_path) as pdf_file:
        yield pdf_file
Exemplo n.º 9
0
    def disableImage(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']
        
        #引数チェック
        result = CommonUtils.checkArguments(method, paramDict)
        if result != True:
            return {'result':'1','message':result}
        
        #変数定義
        imageNo = paramDict['imageNo']

        #イメージデータ存在チェック
        try:
            imageData = CommonUtils.getImageDataByNo(imageNo)
            if imageData is None:
                return {'result':'1','message':"イメージNo:"+ imageNo + "が存在しません。無効化対象を確認して下さい。"}
        except Exception as e:
            return {'result':'1','message':"イメージ情報の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"}
        
        if "0" == str(imageData["SELECTABLE"]):
            return {'result':'1','message':"OSイメージNo:" + imageNo + "/" + str(imageData["IMAGE_NAME"]) + "は既に無効になっています。"}
        
        #更新データ作成
        imageData["SELECTABLE"] = 0
        
        try:
            #IMAGEテーブルのデータ更新
            image = self.conn.getTable("IMAGE")
            sql = image.update(image.c.IMAGE_NO == imageData["IMAGE_NO"], values = imageData)
            self.conn.execute(sql)
            self.conn.commit()
        except Exception as e:
            self.conn.rollback()
            return {'result':'1','message':"IMAGEテーブルの更新に失敗したため処理を中止します。"}
        
        return {'result':'0','message':"OSイメージNo:" + imageNo + "/" + str(imageData["IMAGE_NAME"]) + "の無効化が完了しました。"}
    def showService(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']
        
        #引数のチェック
        result = CommonUtils.checkArguments(method, paramDict)
        if result != True:
            return {'result':'1','message':result}

        #変数設定
        serviceName = paramDict['serviceName']
        
        #サービス名称存在チェック
        try:
            compTypeNo = CommonUtils.getComponentTypeNoByName(serviceName)
        except Exception as e:
            return {'result':'1','message':"サービス名称の取得に失敗したためサービス情報表示を中止します。管理者に連絡を行って下さい。"}
        if compTypeNo == None:
            return {'result':'1','message':"指定されたサービス名称は存在しません。サービス情報表示対象を確認して下さい。"}

        #サービスデータ取得
        try:
            componentType = self.conn.getTable("COMPONENT_TYPE")
            compTypeData = self.conn.selectOne(componentType.select(componentType.c.COMPONENT_TYPE_NAME == serviceName))
        except Exception as e:
            return {'result':'1','message':"サービスデータの取得に失敗したためサービス情報表示を中止します。管理者に連絡を行って下さい。"}
        #getSeteclatbeStatus呼び出し
        try:
            result = CommonUtils.getSelectableStatus(compTypeData['SELECTABLE'])
        except Exception as e:
            return {'result':'1','message':"ステータス名称の取得に失敗したためサービス情報表示を中止します。管理者に連絡を行って下さい。"}
        compTypeData['SELECTABLE'] = result
        
        #返却用データの編集
        retData = json.dumps(compTypeData, ensure_ascii=False)
        
        return {'result':'0','message':"success",'data':retData}
    def disableService(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']
        
        #引数のチェック
        result = CommonUtils.checkArguments(method, paramDict)
        if result != True:
            return {'result':'1','message':result}

        #変数設定
        serviceName = paramDict['serviceName']
        
        #getComponentTypeDataByName呼び出し
        try:
            serviceData = CommonUtils.getComponentTypeDataByName(serviceName)
        except Exception as e:
            return {'result':'1','message':"サービス情報の取得に失敗したため無効化処理を中止します。管理者に連絡を行って下さい。"}
        if serviceData == None:
            return {'result':'1','message':"指定されたサービス名称が存在しません。無効化対象を確認して下さい。"}
        if serviceData['SELECTABLE'] == 0:
            return {'result':'1','message':"指定されたサービスは既に無効状態です。処理を中止します。"}

        #サービスの無効化
        try:
            componentType = self.conn.getTable("COMPONENT_TYPE")
            compTypeData = self.conn.selectOne(componentType.select(componentType.c.COMPONENT_TYPE_NAME == serviceName))
            compTypeData['SELECTABLE'] = 0
            sql = componentType.update(componentType.c.COMPONENT_TYPE_NAME == serviceName, values = compTypeData)
            self.conn.execute(sql)
            self.conn.commit()
            return {'result':'0','message':"サービス名:" + serviceName + "を無効化しました。"}
        except Exception as e:
            self.conn.rollback()
            return {'result':'1','message':"COMPONENT_TYPEテーブルの無効化に失敗したため処理を中止します。サービス名:" + serviceName}
Exemplo n.º 12
0
    def deleteService(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']

        #引数のチェック
        result = CommonUtils.checkArguments(method, paramDict)
        if result != True:
            return {'result': '1', 'message': result}

        #変数設定
        imageNoList = []
        imageNoListAll = []
        serviceDelFlg = False
        serviceName = paramDict['serviceName']
        if "imageNoList" in paramDict:
            imageNoList = paramDict['imageNoList'].split(",")
        componentTypeNo = None
        componentNoList = []
        instanceNoList = []
        instanceImageNoList = []

        #getComponentTypeNoByNameの呼び出し
        try:
            componentTypeNo = CommonUtils.getComponentTypeNoByName(serviceName)
        except Exception as e:
            return {
                'result': '1',
                'message': "サービス情報の取得に失敗したため削除処理を中止します。管理者に連絡を行って下さい。"
            }
        if componentTypeNo == None:
            return {
                'result': '1',
                'message': "指定されたサービス名称が存在しません。削除対象を確認して下さい。"
            }

        #imageNoList存在チェック
        if len(imageNoList) != 0:
            for imageNo in imageNoList[:]:
                try:
                    imageData = CommonUtils.getImageDataByNo(imageNo)
                except Exception as e:
                    return {
                        'result': '1',
                        'message': "イメージ情報の取得に失敗したため削除処理を中止します。管理者に連絡を行って下さい。"
                    }
                if imageData is None:
                    return {
                        'result': '1',
                        'message':
                        "イメージNo:" + imageNo + "は存在しません。削除対象を確認して下さい。"
                    }
                instanceTypeNos = imageData["COMPONENT_TYPE_NOS"].split(",")
                if componentTypeNo not in instanceTypeNos:
                    imageNoList.remove(imageNo)

        #サービス登録済みのイメージ一覧所得
        try:
            tableImage = self.conn.getTable("IMAGE")
        except Exception as e:
            return {
                'result': '1',
                'message': "IMAGEテーブルが存在しません。管理者に連絡を行って下さい。"
            }
        #IMAGEテーブル一覧取得
        imageData = self.conn.select(tableImage.select())
        #指定したサービスが登録されているimageNo一覧を取得
        for image in imageData:
            serviceNos = image['COMPONENT_TYPE_NOS'].split(",")
            for service in serviceNos:
                if service == componentTypeNo:
                    imageNoListAll.append(image['IMAGE_NO'])
        if len(imageNoList) == 0 or len(imageNoList) == len(imageNoListAll):
            imageNoList = imageNoListAll
            serviceDelFlg = True

        #削除対象のサービス定義を使用しているインスタンスチェック
        #COMPONENTテーブル情報取得
        try:
            tableComponent = self.conn.getTable("COMPONENT")
            componentData = self.conn.select(
                tableComponent.select(
                    tableComponent.c.COMPONENT_TYPE_NO == componentTypeNo))
        except Exception as e:
            return {
                'result': '1',
                'message': "COMPONENTテーブル情報取得に失敗しました。処理を中止します。"
            }
        #現在作成中のサービスが存在する場合
        if len(componentData) > 0:
            return {
                'result': '1',
                'message': "サービスモジュール:" + serviceName + "は現在使用されているため処理を中止します。"
            }

        if serviceDelFlg:
            #削除対象のサービスを使用しているmyCloud用サービステンプレートチェック
            try:
                templateComponent = self.conn.getTable("TEMPLATE_COMPONENT")
            except Exception as e:
                return {
                    'result': '1',
                    'message': "TEMPLATE_COMPONENTテーブルが存在しません。管理者に連絡を行って下さい。"
                }
            tempCompData = self.conn.selectOne(
                templateComponent.select(
                    templateComponent.c.COMPONENT_TYPE_NO == componentTypeNo))
            if tempCompData != None:
                return {
                    'result':
                    '1',
                    'message':
                    "サービスモジュール:" + serviceName +
                    "は現在サービステンプレートで使用されているため削除できません。"
                }

        #各イメージからサービス情報を削除
        for imageNo in imageNoList:
            json_data = '{"method":"revokeService","imageNo":"' + str(
                imageNo) + '","serviceList":"' + serviceName + '"}'
            jsondic = json.loads(json_data)
            try:
                ret = self.revokeService(jsondic)
            except Exception as e:
                return {
                    'result': '1',
                    'message':
                    "イメージへのサービス情報削除処理呼び出しに失敗したため処理を中止します。管理者に連絡を行って下さい。"
                }
            if "1" == ret['result']:
                return ret

        if serviceDelFlg:
            #サービスを削除
            try:
                componentType = self.conn.getTable("COMPONENT_TYPE")
                sql = componentType.delete(
                    componentType.c.COMPONENT_TYPE_NAME == serviceName)
                self.conn.execute(sql)
                self.conn.commit()
                return {
                    'result': '0',
                    'message': "サービスモジュール:" + serviceName + "の削除が完了しました。"
                }
            except Exception as e:
                self.conn.rollback()
                return {
                    'result': '1',
                    'message': "COMPONENT_TYPEテーブルデータの削除に失敗したため処理を中止します。"
                }
        imageNoList = ",".join(imageNoList)

        return {
            'result':
            '0',
            'message':
            "イメージNo:" + imageNoList + "からサービス" + serviceName + "の削除が完了しました。"
        }
Exemplo n.º 13
0
    def addService(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']

        #引数のチェック
        result = CommonUtils.checkArguments(method, paramDict)
        if result != True:
            return {'result': '1', 'message': result}

        #変数設定
        serviceName = paramDict['serviceName']
        serviceNameDisp = paramDict['serviceNameDisp']
        layer = paramDict['layer']
        layerNameDisp = paramDict['layerNameDisp']
        runOrder = paramDict['runOrder']
        zabbixTemplate = paramDict['zabbixTemplate']
        addressUrl = None
        imageNoList = None
        if "addressUrl" in paramDict:
            addressUrl = paramDict['addressUrl']
        if "imageNoList" in paramDict:
            imageNoList = paramDict['imageNoList']

        #getComponentTypeNoByName呼び出し
        try:
            compNo = CommonUtils.getComponentTypeNoByName(serviceName)
        except Exception as e:
            return {
                'result': '1',
                'message': "サービス情報の取得に失敗したため登録処理を中止します。管理者に連絡を行って下さい。"
            }
        if compNo != None:
            return {
                'result': '1',
                'message': "指定されたサービス名称は既に使用されています。他の名称を設定して下さい。"
            }

        #imageNoListが指定された場合imageNoListの存在チェック
        if imageNoList is not None:
            imageNoList = imageNoList.split(",")
            for imageNo in imageNoList:
                try:
                    imageData = CommonUtils.getImageDataByNo(imageNo)
                except Exception as e:
                    return {
                        'result': '1',
                        'message': "イメージ情報の取得に失敗したため登録処理を中止します。管理者に連絡を行って下さい。"
                    }

                if imageData is None:
                    return {
                        'result':
                        '1',
                        'message':
                        "指定されたイメージNo:" + imageNo + "は存在しません。イメージ情報を確認して下さい。"
                    }

        #zabbixTemplateの存在チェックと、存在しない場合の追加処理
        #zabbixAPI認証コード発行
        try:
            #getConnectZabbixApi呼び出し
            auth = CommonUtils.getConnectZabbixApi()
        except Exception as e:
            return {
                'result': '1',
                'message': "zabbixAPI認証コード取得に失敗したため処理を終了します。管理者に連絡を行って下さい。"
            }
        if auth == None:
            return {
                'result': '1',
                'message': "zabbixAPI認証コードが発行されなかったため処理を終了します。"
            }

        #zabbixテンプレート存在チェック
        try:
            #getZabbixTemplate呼び出し
            zabbixTemplateData = CommonUtils.getZabbixTemplate(
                auth, zabbixTemplate)
        except Exception as e:
            return {
                'result': '1',
                'message': "zabbixテンプレート情報の取得に失敗したため処理を終了します。管理者に連絡を行って下さい。"
            }

        #テンプレート情報が未登録の場合登録処理実行
        createTemp = True
        if zabbixTemplateData == False:
            #createZabbixTemplate呼び出し
            try:
                createTemp = CommonUtils.createZabbixTemplate(
                    auth, zabbixTemplate)
            except Exception as e:
                return {
                    'result': '1',
                    'message': "zabbixテンプレートの追加に失敗したため処理を終了します。管理者に連絡を行って下さい。"
                }
        if createTemp != True:
            return {'result': '1', 'message': createTemp}

        # サービスを登録
        try:
            componetType = self.conn.getTable("COMPONENT_TYPE")
            sql = componetType.insert({
                "COMPONENT_TYPE_NO": None,
                "COMPONENT_TYPE_NAME": serviceName,
                "COMPONENT_TYPE_NAME_DISP": serviceNameDisp,
                "LAYER": layer,
                "LAYER_DISP": layerNameDisp,
                "RUN_ORDER": runOrder,
                "SELECTABLE": 1,
                "ZABBIX_TEMPLATE": zabbixTemplate,
                "ADDRESS_URL": addressUrl
            })
            self.conn.execute(sql)
            self.conn.commit()
        except Exception as e:
            self.conn.rollback()
            return {
                'result': '1',
                'message': "COMPONENT_TYPEテーブルへの登録に失敗したため処理を中止します。"
            }

        #imageNoListが指定されなかった場合有効状態の全てのイメージをリストに追加
        if imageNoList is None:
            try:
                imageNoList = CommonUtils.getSelectableImageNoList()
            except Exception as e:
                return {'result': '1', 'message': "イメージ情報の取得に失敗したため処理を中止します。"}

        #imageNoListで指定されたイメージに対してサービス情報を追加
        for imageNo in imageNoList:
            #引数用JSONデータ作成
            json_data = '{"method":"validateService","imageNo":"' + imageNo + '","serviceList":"' + serviceName + '"}'
            jsondic = json.loads(json_data)
            #validateService呼び出し
            try:
                result = self.validateService(jsondic)
                if "1" == result['result']:
                    return result
            except Exception as e:
                return {
                    'result': '1',
                    'message':
                    "イメージへのサービス情報追加処理呼び出しに失敗したため処理を中止します。管理者に連絡を行って下さい。"
                }

        imageNoList = ",".join(imageNoList)
        return {
            'result':
            '0',
            'message':
            "サービスモジュール:" + serviceName + "の登録が完了しました。イメージNo:" + imageNoList +
            "上で利用可能になりました。"
        }
Exemplo n.º 14
0
    def updateService(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']

        #引数のチェック
        result = CommonUtils.checkArguments(method, paramDict)
        if result != True:
            return {'result': '1', 'message': result}

        #変数設定
        serviceName = paramDict['serviceName']
        serviceNameDisp = None
        layer = None
        layerNameDisp = None
        runOrder = None
        zabbixTemplate = None
        addressUrl = None
        if "serviceNameDisp" in paramDict:
            serviceNameDisp = paramDict['serviceNameDisp']
        if "layer" in paramDict:
            layer = paramDict['layer']
        if "layerNameDisp" in paramDict:
            layerNameDisp = paramDict['layerNameDisp']
        if "runOrder" in paramDict:
            runOrder = paramDict['runOrder']
        if "zabbixTemplate" in paramDict:
            zabbixTemplate = paramDict['zabbixTemplate']
        if "addressUrl" in paramDict:
            addressUrl = paramDict['addressUrl']

        #getComponentTypeNoByName呼び出し
        try:
            compNo = CommonUtils.getComponentTypeNoByName(serviceName)
        except Exception as e:
            return {
                'result': '1',
                'message': "サービス情報の取得に失敗したため更新処理を中止します。管理者に連絡を行って下さい。"
            }
        if compNo == None:
            return {
                'result': '1',
                'message': "指定されたサービス名称が存在しません。更新対象を確認して下さい。"
            }

        # サービスを更新
        try:
            componentType = self.conn.getTable("COMPONENT_TYPE")
            compTypeData = self.conn.selectOne(
                componentType.select(
                    componentType.c.COMPONENT_TYPE_NAME == serviceName))
            if serviceNameDisp is not None:
                compTypeData['COMPONENT_TYPE_NAME_DISP'] = serviceNameDisp
            if layer is not None:
                compTypeData['LAYER'] = layer
            if layerNameDisp is not None:
                compTypeData['LAYER_DISP'] = layerNameDisp
            if runOrder is not None:
                compTypeData['RUN_ORDER'] = runOrder
            if zabbixTemplate is not None:
                compTypeData['ZABBIX_TEMPLATE'] = zabbixTemplate
            if addressUrl is not None:
                compTypeData['ADDRESS_URL'] = addressUrl
            sql = componentType.update(
                componentType.c.COMPONENT_TYPE_NAME == serviceName,
                values=compTypeData)
            self.conn.execute(sql)
            self.conn.commit()
            return {
                'result': '0',
                'message': "サービスモジュール:" + serviceName + "の更新が完了しました。"
            }
        except Exception as e:
            self.conn.rollback()
            return {
                'result': '1',
                'message': "COMPONENT_TYPEテーブルへの更新に失敗したため処理を中止します。"
            }
Exemplo n.º 15
0
    def showImage(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']
        strServiceName = None
        #引数チェック
        result = CommonUtils.checkArguments(method, paramDict)
        if result != True:
            return {'result':'1','message':result}
        
        #変数定義
        imageNo = paramDict['imageNo']
        imageIaasData = None
        
        #イメージデータ存在チェック
        try:
            imageData = CommonUtils.getImageDataByNo(imageNo)
            if imageData is None:
                return {'result':'1','message':"イメージNo:"+ imageNo + "が存在しません。対象を確認して下さい。"}
        except Exception as e:
            return {'result':'1','message':"イメージ情報の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"}
        
        strServiceNo = imageData["COMPONENT_TYPE_NOS"]
        #serviceListの値が存在する場合、Noを名称に変換
        if strServiceNo != None:
            serviceList = strServiceNo.split(',')
            serviceNameList = []
            for serviceNo in serviceList:
                try:
                    result =  CommonUtils.getComponentTypeNameByNo(serviceNo)
                    if result is None:
                        return {'result':'1','message':"サービス名称の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"}
                    else:
                        serviceNameList.append(result)
                except AttributeError as e:
                    return {'result':'1','message':"サービス名称の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"}
            #リストをカンマで結合
            strServiceName = ",".join(serviceNameList)
            
        imageData.update({"SERVICE_NAME_LIST":strServiceName})

        #ステータスの取得
        try:
            status = CommonUtils.getSelectableStatus(imageData["SELECTABLE"])
        except Exception as e:
            return {'result':'1','message':"ステータス名称の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"}
            
        #SELECTABLEの値をenable/disableに変換
        imageData["SELECTABLE"] = status
        
        #プラットフォーム存在チェック
        try:
            plData = CommonUtils.getPlatformDataByNo(imageData["PLATFORM_NO"])
            #指定されたプラットフォームが存在しない場合
            if plData is None:
                return {'result':'1','message':"プラットフォーム名:" + platformName + "が存在しません。管理者に連絡を行って下さい。"}
        except Exception as e:
            return {'result':'1','message':"プラットフォーム情報の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"}
        
        platformName = plData["PLATFORM_NAME"]
        iaasName = plData["PLATFORM_TYPE"]
        
        if "aws" == iaasName:
            try:
                tableImageAws = self.conn.getTable("IMAGE_AWS")
            except Exception as e:
                return {'result':'1','message':"IMAGE_AWSテーブルが存在しません。管理者に連絡を行って下さい。"}
            imageIaasData = self.conn.selectOne(tableImageAws.select(tableImageAws.c.IMAGE_NO==imageNo))
        elif "vmware" == iaasName:
            try:
                tableImageVm = self.conn.getTable("IMAGE_VMWARE")
            except Exception as e:
                return {'result':'1','message':"IMAGE_VMWAREテーブルが存在しません。管理者に連絡を行って下さい。"}
            imageIaasData = self.conn.selectOne(tableImageVm.select(tableImageVm.c.IMAGE_NO==imageNo))
            imageIaasData.update({"IMAGE_ID":imageIaasData["TEMPLATE_NAME"]})
        elif "cloudstack" == iaasName:
            try:
                tableImageCs = self.conn.getTable("IMAGE_CLOUDSTACK")
            except Exception as e:  
                return {'result':'1','message':"IMAGE_CLOUDSTACKテーブルが存在しません。管理者に連絡を行って下さい。"}
            imageIaasData = self.conn.selectOne(tableImageCs.select(tableImageCs.c.IMAGE_NO==imageNo))
            imageIaasData.update({"IMAGE_ID":imageIaasData["TEMPLATE_ID"]})
        elif "vcloud" == iaasName:
            try:
                tableImageVc = self.conn.getTable("IMAGE_VCLOUD")
            except Exception as e:
                return {'result':'1','message':"IMAGE_VCLOUDテーブルが存在しません。管理者に連絡を行って下さい。"}
            imageIaasData = self.conn.selectOne(tableImageVc.select(tableImageVc.c.IMAGE_NO==imageNo))
            imageIaasData.update({"IMAGE_ID":imageIaasData["TEMPLATE_NAME"]})
        elif "openstack" == iaasName:
            try:
                tableImageOs = self.conn.getTable("IMAGE_OPENSTACK")
            except Exception as e:  
                return {'result':'1','message':"IMAGE_OPENSTACKテーブルが存在しません。管理者に連絡を行って下さい。"}
            imageIaasData = self.conn.selectOne(tableImageOs.select(tableImageOs.c.IMAGE_NO==imageNo))
        elif "azure" == iaasName:
            try:
                tableImageAz = self.conn.getTable("IMAGE_AZURE")
            except Exception as e:
                return {'result':'1','message':"IMAGE_AZUREテーブルが存在しません。管理者に連絡を行って下さい。"}
            imageIaasData = self.conn.selectOne(tableImageAz.select(tableImageAz.c.IMAGE_NO==imageNo))
            imageIaasData.update({"IMAGE_ID":imageIaasData["IMAGE_NAME"]})
        elif "nifty" == iaasName:
            try:
                tableImageNif = self.conn.getTable("IMAGE_NIFTY")
            except Exception as e:
                return {'result':'1','message':"IMAGE_NIFTYテーブルが存在しません。管理者に連絡を行って下さい。"}
            imageIaasData = self.conn.selectOne(tableImageNif.select(tableImageNif.c.IMAGE_NO==imageNo))
            
        imageData.update(imageIaasData)
        imageData.update({u"PLATFORM_NAME":platformName})
        retData = json.dumps(imageData, ensure_ascii=False)
        
        return {'result':'0', 'message':"suucess", 'data':retData}
        
import json
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))) )
import common.CommonUtils as CommonUtils
from app.PlatformManager import PlatformManager
from app.ImageManager import ImageManager
from app.ServiceManager import ServiceManager
from app.RepositoryManager import RepositoryManager

if __name__ == '__main__':
    command = sys.argv[1]
    jsonData = sys.argv[2]
    paramDict = json.loads(jsonData)
    #DB接続チェック
    checkResult = CommonUtils.checkDbConnection()
    #DB接続エラーの場合、処理終了
    if checkResult == True:
        if "addPlatform" == command:
            pm = PlatformManager()
            retDict = pm.addPlatform(paramDict)
        elif "updatePlatform" == command:
            pm = PlatformManager()
            retDict = pm.updatePlatform(paramDict)
        elif "deletePlatform" == command:
            pm = PlatformManager()
            retDict = pm.deletePlatform(paramDict)
        elif "enablePlatform" == command:
            pm = PlatformManager()
            retDict = pm.enablePlatform(paramDict)
        elif "disablePlatform" == command:
    def updateService(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']
        
        #引数のチェック
        result = CommonUtils.checkArguments(method, paramDict)
        if result != True:
            return {'result':'1','message':result}
        
        #変数設定
        serviceName = paramDict['serviceName']
        serviceNameDisp = None
        layer = None
        layerNameDisp = None
        runOrder = None
        zabbixTemplate = None
        addressUrl = None
        if "serviceNameDisp" in paramDict:
            serviceNameDisp = paramDict['serviceNameDisp']
        if "layer" in paramDict:
            layer = paramDict['layer']
        if "layerNameDisp" in paramDict:
            layerNameDisp = paramDict['layerNameDisp']
        if "runOrder" in paramDict:
            runOrder = paramDict['runOrder']
        if "zabbixTemplate" in paramDict:
            zabbixTemplate = paramDict['zabbixTemplate']
        if "addressUrl" in paramDict:
            addressUrl = paramDict['addressUrl']
        
        #getComponentTypeNoByName呼び出し
        try:
            compNo = CommonUtils.getComponentTypeNoByName(serviceName)
        except Exception as e:
            return {'result':'1','message':"サービス情報の取得に失敗したため更新処理を中止します。管理者に連絡を行って下さい。"}
        if compNo == None:
            return {'result':'1','message':"指定されたサービス名称が存在しません。更新対象を確認して下さい。"}

        # サービスを更新
        try:
            componentType = self.conn.getTable("COMPONENT_TYPE")
            compTypeData = self.conn.selectOne(componentType.select(componentType.c.COMPONENT_TYPE_NAME == serviceName))
            if serviceNameDisp is not None:
                compTypeData['COMPONENT_TYPE_NAME_DISP'] = serviceNameDisp
            if layer is not None:
                compTypeData['LAYER'] = layer
            if layerNameDisp is not None:
                compTypeData['LAYER_DISP'] = layerNameDisp
            if runOrder is not None:
                compTypeData['RUN_ORDER'] = runOrder
            if zabbixTemplate is not None:
                compTypeData['ZABBIX_TEMPLATE'] = zabbixTemplate
            if addressUrl is not None:
                compTypeData['ADDRESS_URL'] = addressUrl
            sql = componentType.update(componentType.c.COMPONENT_TYPE_NAME == serviceName, values = compTypeData)
            self.conn.execute(sql)
            self.conn.commit()
            return {'result':'0','message':"サービスモジュール:" + serviceName + "の更新が完了しました。"}
        except Exception as e:
            self.conn.rollback()
            return {'result':'1','message':"COMPONENT_TYPEテーブルへの更新に失敗したため処理を中止します。"}
Exemplo n.º 18
0
    def addImage(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']
        iaasNameList = []
        retDict = None
        platformList = None
        platformNoList = []
        imageNoList = []
        
        try:
            #platformListが指定された場合
            if "platformList" in paramDict:
                #platformListをカンマ区切りで分ける
                platformList = paramDict['platformList'].split(',')
            #platformListが指定されなかった場合PLATFORMテーブルからSELECTABLEが1のPLATFORM_NAME一覧取得
            else:
                platformList = CommonUtils.getSelectablePlatformNameList()
            #AWSプラットフォームが指定された場合、専用のチェックメソッドを指定
            for platformName in platformList:
                iaasName = CommonUtils.getPlatformTypeByName(platformName)
                if iaasName is None:
                    return {'result':'1','message':"指定されたプラットフォーム名:" + platformName + "は存在しません。登録対象を確認して下さい。"}
                if "aws" == iaasName:
                    method = "addAwsImage"
        except Exception as e:
            return {'result':'1','message':"プラットフォーム情報の取得に失敗したためOSイメージの登録を中止します。管理者に連絡を行って下さい。"}

        #引数のチェック
        result = CommonUtils.checkArguments(method, paramDict)
        if result != True:
            return {'result':'1','message':result}
        #引数から変数へセット
        imageName = paramDict['imageName']
        imageNameDisp = paramDict['imageNameDisp']
        osName = paramDict['osName']
        osNameDisp = paramDict['osNameDisp']
        instanceTypeList = paramDict['instanceTypeList']
        imageId = paramDict['imageId']
        zabbixTemplate = paramDict['zabbixTemplate']
        serviceList = None
        serviceNoList = 0
        kernelId = None
        ramdiskId = None
        ebsImageFlg = 0
        icon = None
        if "serviceList" in paramDict:
            serviceList = paramDict['serviceList']
        if "kernelId" in paramDict:
            kernelId = paramDict['kernelId']
        if "ramdiskId" in paramDict:
            ramdiskId = paramDict['ramdiskId']
        if "ebsImageFlg" in paramDict:
            ebsImageFlg = paramDict['ebsImageFlg']
        if "icon" in paramDict:
            icon = paramDict['icon']

        #serviceListの値が存在する場合、名称をNoに変換
        if serviceList != None:
            serviceList = serviceList.split(',')
            serviceNoList = []
            for serviceName in serviceList:
                try:
                    result =  CommonUtils.getComponentTypeNoByName(serviceName)
                    if result is None:
                        return {'result':'1','message':"指定されたサービス名称:" + serviceName + "が存在しません。登録対象を確認して下さい。"}
                    else:
                        serviceNoList.append(result)
                except AttributeError as e:
                    return {'result':'1','message':"サービス名称の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"}
            #リストをカンマで結合
            serviceNoList = ",".join(serviceNoList)

        #プラットフォーム存在チェック
        for platformName in platformList:
            try:
                plData = CommonUtils.getPlatformDataByName(platformName)
            except Exception as e:
                return {'result':'1','message':"プラットフォーム情報の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"}
            
            platformNoList.append(str(plData["PLATFORM_NO"]))
            iaasNameList.append(plData["PLATFORM_TYPE"])

        #同一プラットフォーム・同一名のイメージデータ存在チェック
        for platformNo in platformNoList:
            try:
                checkImageData = CommonUtils.getImageDataByNameAndPlatformNo(imageName, platformNo)
                #指定されたプラットフォームに既に同名のイメージが存在する場合
                if checkImageData != None:
                    return {'result':'1','message':"指定されたプラットフォーム:" + str(platformNo) +"には既に同じ名称のイメージ:" + imageName + "が存在します。名称を指定し直して下さい。"}
            except Exception as e:
                return {'result':'1','message':"イメージ情報の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"}
        
        #アイコンファイル存在チェック
        if icon != None:
            if os.path.isfile(icon) == False:
                return {'result':'1','message':"指定されたアイコンファイルが見つからないため処理を中止します。登録対象を確認して下さい。"}
        
        #zabbixTemplateの存在チェックと、存在しない場合の追加処理
        #zabbixAPI認証コード発行
        try:
            #getConnectZabbixApi呼び出し
            auth = CommonUtils.getConnectZabbixApi()
        except Exception as e:
            return {'result':'1','message':"zabbixAPI認証コード取得に失敗したため処理を終了します。管理者に連絡を行って下さい。"}
        if auth == None:
            return {'result':'1','message':"zabbixAPI認証コードが発行されなかったため処理を終了します。"}
        
        #zabbixテンプレート存在チェック
        try:
            #getZabbixTemplate呼び出し
            zabbixTemplateData = CommonUtils.getZabbixTemplate(auth, zabbixTemplate)
        except Exception as e:
            return {'result':'1','message':"zabbixテンプレート情報の取得に失敗したため処理を終了します。管理者に連絡を行って下さい。"}

        #テンプレート情報が未登録の場合登録処理実行
        createTemp = True
        if zabbixTemplateData == False:
            #createZabbixTemplate呼び出し
            try:
                createTemp = CommonUtils.createZabbixTemplate(auth, zabbixTemplate)
            except Exception as e:
                return {'result':'1','message':"zabbixテンプレートの追加に失敗したため処理を終了します。管理者に連絡を行って下さい。"}
        if createTemp != True:
            return {'result':'1','message':createTemp}
        
        cnt = 0

        #IMAGEテーブルと各種PLATFORM_TYPE毎のIMAGE系テーブルへのデータ登録
        for platformNo in platformNoList:
            try:
                #IMAGEテーブル登録処理実行
                tableImage = self.conn.getTable("IMAGE")
                sql = tableImage.insert({"PLATFORM_NO":platformNo,
                        "IMAGE_NAME":imageName,
                        "IMAGE_NAME_DISP":imageNameDisp,
                        "OS":osName,
                        "OS_DISP":osNameDisp,
                        "SELECTABLE":"1",
                        "COMPONENT_TYPE_NOS":serviceNoList,
                        "ZABBIX_TEMPLATE":zabbixTemplate
                        })
                #return {'result':'1','message':str(sql)}
                self.conn.execute(sql)
                #ここでコミットしないと子テーブルのPLATFROM_NOが取得出来ない
                self.conn.commit()
            except Exception as e:
                self.conn.rollback()
                return {'result':'1','message':"IMAGEテーブルへの登録に失敗したため処理を中止します。イメージ名:" + imageName}

            imageData = CommonUtils.getImageDataByNameAndPlatformNo(imageName, platformNo)
            imageNo = imageData["IMAGE_NO"]
            imageNoList.append(str(imageNo))

            #IaaS毎のテーブル登録
            if "aws" == iaasNameList[cnt]:
                try:
                    #IMAGE_AWSテーブル登録処理実行
                    tableImageAws = self.conn.getTable("IMAGE_AWS")
                    sql = tableImageAws.insert({"IMAGE_NO":imageNo,
                            "IMAGE_ID":imageId,
                            "KERNEL_ID":kernelId,
                            "RAMDISK_ID":ramdiskId,
                            "INSTANCE_TYPES":instanceTypeList,
                            "EBS_IMAGE":ebsImageFlg
                            })
                    self.conn.execute(sql)
                    self.conn.commit()
                except Exception as e:
                    self.conn.rollback()
                    retDict = {'result':'1','message':"IMAGE_AWSテーブルへのデータ登録に失敗したため処理を中止します。"}
            
            elif "vmware" == iaasNameList[cnt]:
                try:
                    #IMAGE_VMWAREテーブル登録処理実行
                    tableImageVmware = self.conn.getTable("IMAGE_VMWARE")
                    sql = tableImageVmware.insert({"IMAGE_NO":imageNo,
                            "TEMPLATE_NAME":imageId,
                            "INSTANCE_TYPES":instanceTypeList
                            })
                    self.conn.execute(sql)
                    self.conn.commit()
                except Exception as e:
                    self.conn.rollback()
                    retDict = {'result':'1','message':"IMAGE_VMWAREテーブルへのデータ登録に失敗したため処理を中止します。"}
            
            elif "cloudstack" == iaasNameList[cnt]:
                try:
                    #IMAGE_CLOUDSTACKテーブル登録処理実行
                    tableImageCloudstack = self.conn.getTable("IMAGE_CLOUDSTACK")
                    sql = tableImageCloudstack.insert({"IMAGE_NO":imageNo,
                            "TEMPLATE_ID":imageId,
                            "INSTANCE_TYPES":instanceTypeList
                            })
                    self.conn.execute(sql)
                    self.conn.commit()
                except Exception as e:
                    self.conn.rollback()
                    retDict = {'result':'1','message':"IMAGE_CLOUDSTACKテーブルへのデータ登録に失敗したため処理を中止します。"}
            
            elif "vcloud" == iaasNameList[cnt]:
                try:
                    #IMAGE_VCLOUDテーブル登録処理実行
                    tableImageVcloud = self.conn.getTable("IMAGE_VCLOUD")
                    sql = tableImageVcloud.insert({"IMAGE_NO":imageNo,
                            "TEMPLATE_NAME":imageId,
                            "INSTANCE_TYPES":instanceTypeList
                            })
                    self.conn.execute(sql)
                    self.conn.commit()
                except Exception as e:
                    self.conn.rollback()
                    retDict = {'result':'1','message':"IMAGE_VCLOUDテーブルへのデータ登録に失敗したため処理を中止します。"}

            elif "openstack" == iaasNameList[cnt]:
                try:
                    #IMAGE_OPENSTACKテーブル登録処理実行
                    tableImageOpenstack = self.conn.getTable("IMAGE_OPENSTACK")
                    sql = tableImageOpenstack.insert({"IMAGE_NO":imageNo,
                            "IMAGE_ID":imageId,
                            "INSTANCE_TYPES":instanceTypeList
                            })
                    self.conn.execute(sql)
                    self.conn.commit()
                except Exception as e:
                    self.conn.rollback()
                    retDict = {'result':'1','message':"IMAGE_OPENSTACKテーブルへのデータ登録に失敗したため処理を中止します。"}
            
            elif "azure" == iaasNameList[cnt]:
                try:
                    #IMAGE_AZUREテーブル登録処理実行
                    tableImageAzure = self.conn.getTable("IMAGE_AZURE")
                    sql = tableImageAzure.insert({"IMAGE_NO":imageNo,
                            "IMAGE_NAME":imageId,
                            "INSTANCE_TYPES":instanceTypeList
                            })
                    self.conn.execute(sql)
                    self.conn.commit()
                except Exception as e:
                    self.conn.rollback()
                    retDict = {'result':'1','message':"IMAGE_AZUREテーブルへのデータ登録に失敗したため処理を中止します。"}
            
            elif "nifty" == iaasNameList[cnt]:
                try:
                    #IMAGE_NIFTYテーブル登録処理実行
                    tableImageNifty = self.conn.getTable("IMAGE_NIFTY")
                    sql = tableImageNifty.insert({"IMAGE_NO":imageNo,
                            "IMAGE_ID":imageId,
                            "INSTANCE_TYPES":instanceTypeList
                            })
                    self.conn.execute(sql)
                    self.conn.commit()
                except Exception as e:
                    self.conn.rollback()
                    retDict = {'result':'1','message':"IMAGE_NIFTYテーブルへのデータ登録に失敗したため処理を中止します。"}

            if retDict != None and retDict['result'] == "1":
                image = self.conn.getTable("IMAGE")
                #エラー終了時、登録したイメージデータを削除
                image.delete(image.c.IMAGE_NO == imageNo).execute()
            
            cnt = cnt + 1
            
        if icon != None:
            path, ext = os.path.splitext(icon)
            #iconの指定がある場合iconのパスに存在する画像を/opt/adc/app/auto-web/VAADIN/themes/classy/iconsに(引数.imageName)pngの形式にリネームしてコピーする。
            copyName = "/opt/adc/app/auto-web/VAADIN/themes/classy/icons/" + imageName + ext
            shutil.copyfile(icon, copyName)
            
        imageNoList = ",".join(imageNoList)
        retDict = {'result':'0','message':"OSイメージNo:" + imageNoList + "/" + imageName + "の登録が完了しました。"}

        return retDict
    def revokeService(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']
        
        #引数のチェック
        result = CommonUtils.checkArguments(method, paramDict)
        if result != True:
            return {'result':'1','message':result}
        
        #変数設定
        imageNo = paramDict['imageNo']
        serviceList = paramDict['serviceList']
        componentNoList = []
        instanceNoList = []
        
        #イメージ存在チェック
        try:
            imageData = CommonUtils.getImageDataByNo(imageNo)
        except Exception as e:
            return {'result':'1','message':"イメージ情報の取得に失敗したためサービス情報の削除を中止します。管理者に連絡を行って下さい。"}
        if imageData == None:
            return {'result':'1','message':"imageNo:" + imageNo + "が存在しません。サービス情報の削除を中止します。"}

        #serviceList存在チェック
        serviceNameList = serviceList.split(",")
        serviceNoList = []
        for serviceName in serviceNameList:
            try:
                result =  CommonUtils.getComponentTypeNoByName(serviceName)
                if result == None:
                    return {'result':'1','message':"サービス名称:" + serviceName + "が存在しません。サービス名称を確認して下さい。"}
                else:
                    serviceNoList.append(result)
            except Exception as e:
                return {'result':'1','message':"サービス情報の取得に失敗したためサービス情報の削除を中止します。管理者に連絡を行って下さい。"}

        #インスタンス作成中のサービスチェック
        for componentTypeNo in serviceNoList:
            #COMPONENTテーブル情報取得
            try:
                tableComponent = self.conn.getTable("COMPONENT")
                componentData = self.conn.select(tableComponent.select(tableComponent.c.COMPONENT_TYPE_NO == componentTypeNo))
            except Exception as e:
                return {'result':'1','message':"COMPONENTテーブル情報取得に失敗しました。処理を中止します。"}
            if len(componentData) > 0:
                return {'result':'1','message':"指定されたサービスは現在使用されているため処理を中止します。"}

        #登録用データ作成
        imageServiceDataList = imageData['COMPONENT_TYPE_NOS'].split(",")
        for service in serviceNoList:
            errFlg = False
            for image in imageServiceDataList[:]:
                if image == service:
                    imageServiceDataList.remove(image)
                    errFlg = True
            if errFlg == False:
                try:
                    serviceName = CommonUtils.getComponentTypeNameByNo(service)
                except Exception as e:
                    return {'result':'1','message':"サービス情報の取得に失敗したためサービス削除処理を中止します。管理者に連絡を行って下さい。"}
                return {'result':'1','message':"サービス名称:" + serviceName + "はイメージNo:" + imageNo + "で利用可能なサービス情報に存在しません。削除対象を確認して下さい。"}
        #サービス情報の作成
        imageServiceDataList.sort()
        imageService = ",".join(imageServiceDataList)
        if "" == imageService:
            imageService = 0

        #サービス情報削除
        try:
            image = self.conn.getTable("IMAGE")
            imageData = self.conn.selectOne(image.select(image.c.IMAGE_NO == imageNo))
            imageData['COMPONENT_TYPE_NOS'] = imageService
            sql = image.update(image.c.IMAGE_NO == imageNo, values = imageData)
            self.conn.execute(sql)
            self.conn.commit()
            return {'result':'0','message':"イメージNo:" + imageNo + "上で利用可能なサービス情報:" + serviceList + "の削除に成功しました。"}
        except Exception as e:
            self.conn.rollback()
            return {'result':'1','message':"利用可能サービス情報:" + serviceList + "の削除に失敗しました。処理を終了します。"}
    def removeModule(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']
        #辞書からmifDictを受け取えい削除
        mifDict = paramDict['mifDict']
        del paramDict['mifDict']

        #引数のチェック
        result = CommonUtils.checkArguments(method, paramDict)

        if result != True:
            return {'result': '1', 'message': result}

        #引数から変数へセット
        moduleName = paramDict['moduleName']

        #削除対象がイメージの場合
        if mifDict['moduleInformation'].has_key('TemplateModule'):
            imageName = mifDict['moduleInformation']['TemplateModule'][
                'templateModuleInformation']['moduleName']
            #DB上にイメージが登録されているか確認
            try:
                ret = CommonUtils.getImageDataByName(imageName)
            except Exception as e:
                return {
                    'result': '1',
                    'message': "イメージ情報の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"
                }
            if ret is not None:
                return {
                    'result':
                    '1',
                    'message':
                    "モジュール:" + moduleName +
                    "は現在PCCに登録されています。pccadmin del imageコマンドを使用してPCCから削除した後、pccrepo removeコマンドを実行して下さい。"
                }

        #削除対象がサービスの場合
        elif mifDict['moduleInformation'].has_key('ServiceModule'):
            serviceName = mifDict['moduleInformation']['ServiceModule'][
                'ServiceModuleInformation']['moduleName']
            #DB上にサービスが登録されているか確認
            try:
                ret = CommonUtils.getComponentTypeNoByName(serviceName)
            except Exception as e:
                return {
                    'result': '1',
                    'message': "サービス情報の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"
                }
            if ret is not None:
                return {
                    'result':
                    '1',
                    'message':
                    "モジュール:" + moduleName +
                    "は現在PCCに登録されています。pccadmin del serviceコマンドを使用してPCCから削除した後、pccrepo removeコマンドを実行して下さい。"
                }
        else:
            return {'result': '1', 'message': "JSONファイルが壊れているため処理を中止します。"}
        #正常終了
        return {'result': '0', 'message': "success"}
Exemplo n.º 21
0
Author       :  Ken-Kei
Create Date  :  2016/07/01
"""


from attribute import *  # @UnusedWildImport
from common import CommonUtils
import unittest
import logging
import multiprocessing
from Lib.HTMLTestRunner import HTMLTestRunner
# from TestCase.test_LaunchOperation import LaunchOperationCase
# from TestCase.test_LaunchLogin import LaunchLoginCase


com = CommonUtils()
# 创建log文件并初始化logging模块
com.create_log_file(launch_log_path)
com.init_logging()

logging.info("浏览器版本: %s" % com.get_browser_version())


# 初始化测试套件并添加测试用例
# suite = unittest.TestSuite()
# suite.addTest(LaunchOperationCase("test_CreateQRCode"))
# suite.addTest(LaunchLoginCase("test_LoginFailedWithWrongUser"))

case = []
# 初始化测试套件并添加测试用例
suite = unittest.TestSuite()
Exemplo n.º 22
0
    def revokeService(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']

        #引数のチェック
        result = CommonUtils.checkArguments(method, paramDict)
        if result != True:
            return {'result': '1', 'message': result}

        #変数設定
        imageNo = paramDict['imageNo']
        serviceList = paramDict['serviceList']
        componentNoList = []
        instanceNoList = []

        #イメージ存在チェック
        try:
            imageData = CommonUtils.getImageDataByNo(imageNo)
        except Exception as e:
            return {
                'result': '1',
                'message': "イメージ情報の取得に失敗したためサービス情報の削除を中止します。管理者に連絡を行って下さい。"
            }
        if imageData == None:
            return {
                'result': '1',
                'message': "imageNo:" + imageNo + "が存在しません。サービス情報の削除を中止します。"
            }

        #serviceList存在チェック
        serviceNameList = serviceList.split(",")
        serviceNoList = []
        for serviceName in serviceNameList:
            try:
                result = CommonUtils.getComponentTypeNoByName(serviceName)
                if result == None:
                    return {
                        'result':
                        '1',
                        'message':
                        "サービス名称:" + serviceName + "が存在しません。サービス名称を確認して下さい。"
                    }
                else:
                    serviceNoList.append(result)
            except Exception as e:
                return {
                    'result': '1',
                    'message': "サービス情報の取得に失敗したためサービス情報の削除を中止します。管理者に連絡を行って下さい。"
                }

        #インスタンス作成中のサービスチェック
        for componentTypeNo in serviceNoList:
            #COMPONENTテーブル情報取得
            try:
                tableComponent = self.conn.getTable("COMPONENT")
                componentData = self.conn.select(
                    tableComponent.select(
                        tableComponent.c.COMPONENT_TYPE_NO == componentTypeNo))
            except Exception as e:
                return {
                    'result': '1',
                    'message': "COMPONENTテーブル情報取得に失敗しました。処理を中止します。"
                }
            if len(componentData) > 0:
                return {
                    'result': '1',
                    'message': "指定されたサービスは現在使用されているため処理を中止します。"
                }

        #登録用データ作成
        imageServiceDataList = imageData['COMPONENT_TYPE_NOS'].split(",")
        for service in serviceNoList:
            errFlg = False
            for image in imageServiceDataList[:]:
                if image == service:
                    imageServiceDataList.remove(image)
                    errFlg = True
            if errFlg == False:
                try:
                    serviceName = CommonUtils.getComponentTypeNameByNo(service)
                except Exception as e:
                    return {
                        'result': '1',
                        'message':
                        "サービス情報の取得に失敗したためサービス削除処理を中止します。管理者に連絡を行って下さい。"
                    }
                return {
                    'result':
                    '1',
                    'message':
                    "サービス名称:" + serviceName + "はイメージNo:" + imageNo +
                    "で利用可能なサービス情報に存在しません。削除対象を確認して下さい。"
                }
        #サービス情報の作成
        imageServiceDataList.sort()
        imageService = ",".join(imageServiceDataList)
        if "" == imageService:
            imageService = 0

        #サービス情報削除
        try:
            image = self.conn.getTable("IMAGE")
            imageData = self.conn.selectOne(
                image.select(image.c.IMAGE_NO == imageNo))
            imageData['COMPONENT_TYPE_NOS'] = imageService
            sql = image.update(image.c.IMAGE_NO == imageNo, values=imageData)
            self.conn.execute(sql)
            self.conn.commit()
            return {
                'result':
                '0',
                'message':
                "イメージNo:" + imageNo + "上で利用可能なサービス情報:" + serviceList +
                "の削除に成功しました。"
            }
        except Exception as e:
            self.conn.rollback()
            return {
                'result': '1',
                'message': "利用可能サービス情報:" + serviceList + "の削除に失敗しました。処理を終了します。"
            }
    def deleteService(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']
        
        #引数のチェック
        result = CommonUtils.checkArguments(method, paramDict)
        if result != True:
            return {'result':'1','message':result}
        
        #変数設定
        imageNoList = []
        imageNoListAll = []
        serviceDelFlg = False
        serviceName = paramDict['serviceName']
        if "imageNoList" in paramDict:
            imageNoList = paramDict['imageNoList'].split(",")
        componentTypeNo = None
        componentNoList = []
        instanceNoList = []
        instanceImageNoList = []

        #getComponentTypeNoByNameの呼び出し
        try:
            componentTypeNo = CommonUtils.getComponentTypeNoByName(serviceName)
        except Exception as e:
            return {'result':'1','message':"サービス情報の取得に失敗したため削除処理を中止します。管理者に連絡を行って下さい。"}
        if componentTypeNo == None:
            return {'result':'1','message':"指定されたサービス名称が存在しません。削除対象を確認して下さい。"}

        #imageNoList存在チェック
        if len(imageNoList) != 0:
            for imageNo in imageNoList[:]:
                try:
                    imageData = CommonUtils.getImageDataByNo(imageNo)
                except Exception as e:
                    return {'result':'1','message':"イメージ情報の取得に失敗したため削除処理を中止します。管理者に連絡を行って下さい。"}
                if imageData is None:
                    return {'result':'1','message':"イメージNo:" + imageNo + "は存在しません。削除対象を確認して下さい。"}
                instanceTypeNos = imageData["COMPONENT_TYPE_NOS"].split(",")
                if componentTypeNo not in instanceTypeNos:
                    imageNoList.remove(imageNo)

        #サービス登録済みのイメージ一覧所得
        try:
            tableImage = self.conn.getTable("IMAGE")
        except Exception as e:
            return {'result':'1','message':"IMAGEテーブルが存在しません。管理者に連絡を行って下さい。"}
        #IMAGEテーブル一覧取得
        imageData = self.conn.select(tableImage.select())
        #指定したサービスが登録されているimageNo一覧を取得
        for image in imageData:
            serviceNos = image['COMPONENT_TYPE_NOS'].split(",")
            for service in serviceNos:
                if service == componentTypeNo:
                    imageNoListAll.append(image['IMAGE_NO'])
        if len(imageNoList) == 0 or len(imageNoList) == len(imageNoListAll):
            imageNoList = imageNoListAll
            serviceDelFlg = True

        #削除対象のサービス定義を使用しているインスタンスチェック
        #COMPONENTテーブル情報取得
        try:
            tableComponent = self.conn.getTable("COMPONENT")
            componentData = self.conn.select(tableComponent.select(tableComponent.c.COMPONENT_TYPE_NO == componentTypeNo))
        except Exception as e:
            return {'result':'1','message':"COMPONENTテーブル情報取得に失敗しました。処理を中止します。"}
        #現在作成中のサービスが存在する場合
        if len(componentData) > 0:
            return {'result':'1','message':"サービスモジュール:" + serviceName + "は現在使用されているため処理を中止します。"}
        
        if serviceDelFlg:
            #削除対象のサービスを使用しているmyCloud用サービステンプレートチェック
            try:
                templateComponent = self.conn.getTable("TEMPLATE_COMPONENT")
            except Exception as e:
                return {'result':'1','message':"TEMPLATE_COMPONENTテーブルが存在しません。管理者に連絡を行って下さい。"}
            tempCompData = self.conn.selectOne(templateComponent.select(templateComponent.c.COMPONENT_TYPE_NO == componentTypeNo))
            if tempCompData != None:
                return {'result':'1','message':"サービスモジュール:" + serviceName + "は現在サービステンプレートで使用されているため削除できません。"}

        #各イメージからサービス情報を削除
        for imageNo in imageNoList:
            json_data = '{"method":"revokeService","imageNo":"' + str(imageNo) + '","serviceList":"' + serviceName + '"}'
            jsondic = json.loads(json_data)
            try:
                ret = self.revokeService(jsondic)
            except Exception as e:
                return {'result':'1','message':"イメージへのサービス情報削除処理呼び出しに失敗したため処理を中止します。管理者に連絡を行って下さい。"}
            if "1" == ret['result']:
                return ret

        if serviceDelFlg:
            #サービスを削除
            try:
                componentType = self.conn.getTable("COMPONENT_TYPE")
                sql = componentType.delete(componentType.c.COMPONENT_TYPE_NAME == serviceName)
                self.conn.execute(sql)
                self.conn.commit()
                return {'result':'0','message':"サービスモジュール:" + serviceName + "の削除が完了しました。"}
            except Exception as e:
                self.conn.rollback()
                return {'result':'1','message':"COMPONENT_TYPEテーブルデータの削除に失敗したため処理を中止します。"}
        imageNoList = ",".join(imageNoList)
        
        return {'result':'0','message':"イメージNo:" + imageNoList + "からサービス" + serviceName + "の削除が完了しました。"}
    def addService(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']

        #引数のチェック
        result = CommonUtils.checkArguments(method, paramDict)
        if result != True:
            return {'result':'1','message':result}

        #変数設定
        serviceName = paramDict['serviceName']
        serviceNameDisp = paramDict['serviceNameDisp']
        layer = paramDict['layer']
        layerNameDisp = paramDict['layerNameDisp']
        runOrder = paramDict['runOrder']
        zabbixTemplate = paramDict['zabbixTemplate']
        addressUrl = None
        imageNoList = None
        if "addressUrl" in paramDict:
            addressUrl = paramDict['addressUrl']
        if "imageNoList" in paramDict:
            imageNoList = paramDict['imageNoList']

        #getComponentTypeNoByName呼び出し
        try:
            compNo = CommonUtils.getComponentTypeNoByName(serviceName)
        except Exception as e:
            return {'result':'1','message':"サービス情報の取得に失敗したため登録処理を中止します。管理者に連絡を行って下さい。"}
        if compNo != None:
            return {'result':'1','message':"指定されたサービス名称は既に使用されています。他の名称を設定して下さい。"}

        #imageNoListが指定された場合imageNoListの存在チェック
        if imageNoList is not None:
            imageNoList = imageNoList.split(",")
            for imageNo in imageNoList:
                try:
                    imageData = CommonUtils.getImageDataByNo(imageNo)
                except Exception as e:
                    return {'result':'1','message':"イメージ情報の取得に失敗したため登録処理を中止します。管理者に連絡を行って下さい。"}
                
                if imageData is None:
                    return {'result':'1','message':"指定されたイメージNo:" + imageNo + "は存在しません。イメージ情報を確認して下さい。"}
        
        #zabbixTemplateの存在チェックと、存在しない場合の追加処理
        #zabbixAPI認証コード発行
        try:
            #getConnectZabbixApi呼び出し
            auth = CommonUtils.getConnectZabbixApi()
        except Exception as e:
            return {'result':'1','message':"zabbixAPI認証コード取得に失敗したため処理を終了します。管理者に連絡を行って下さい。"}
        if auth == None:
            return {'result':'1','message':"zabbixAPI認証コードが発行されなかったため処理を終了します。"}
        
        #zabbixテンプレート存在チェック
        try:
            #getZabbixTemplate呼び出し
            zabbixTemplateData = CommonUtils.getZabbixTemplate(auth, zabbixTemplate)
        except Exception as e:
            return {'result':'1','message':"zabbixテンプレート情報の取得に失敗したため処理を終了します。管理者に連絡を行って下さい。"}

        #テンプレート情報が未登録の場合登録処理実行
        createTemp = True
        if zabbixTemplateData == False:
            #createZabbixTemplate呼び出し
            try:
                createTemp = CommonUtils.createZabbixTemplate(auth, zabbixTemplate)
            except Exception as e:
                return {'result':'1','message':"zabbixテンプレートの追加に失敗したため処理を終了します。管理者に連絡を行って下さい。"}
        if createTemp != True:
            return {'result':'1','message':createTemp}
        
        # サービスを登録
        try:
            componetType = self.conn.getTable("COMPONENT_TYPE")
            sql = componetType.insert({"COMPONENT_TYPE_NO":None,
                    "COMPONENT_TYPE_NAME":serviceName,
                    "COMPONENT_TYPE_NAME_DISP":serviceNameDisp,
                    "LAYER":layer,
                    "LAYER_DISP":layerNameDisp,
                    "RUN_ORDER":runOrder,
                    "SELECTABLE":1,
                    "ZABBIX_TEMPLATE":zabbixTemplate,
                    "ADDRESS_URL":addressUrl})
            self.conn.execute(sql)
            self.conn.commit()
        except Exception as e:
            self.conn.rollback()
            return {'result':'1','message':"COMPONENT_TYPEテーブルへの登録に失敗したため処理を中止します。"}
        
        #imageNoListが指定されなかった場合有効状態の全てのイメージをリストに追加
        if imageNoList is None:
            try:
                imageNoList = CommonUtils.getSelectableImageNoList()
            except Exception as e:
                return {'result':'1','message':"イメージ情報の取得に失敗したため処理を中止します。"}
        
        #imageNoListで指定されたイメージに対してサービス情報を追加
        for imageNo in imageNoList:
            #引数用JSONデータ作成
            json_data = '{"method":"validateService","imageNo":"' + imageNo + '","serviceList":"' + serviceName + '"}'
            jsondic = json.loads(json_data)
            #validateService呼び出し
            try:
                result = self.validateService(jsondic)
                if "1" == result['result']:
                    return result
            except Exception as e:
                return {'result':'1','message':"イメージへのサービス情報追加処理呼び出しに失敗したため処理を中止します。管理者に連絡を行って下さい。"}
            
        imageNoList = ",".join(imageNoList)
        return {'result':'0','message':"サービスモジュール:" + serviceName + "の登録が完了しました。イメージNo:" + imageNoList + "上で利用可能になりました。"}
Exemplo n.º 25
0
    def deleteImage(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']
        
        #引数チェック
        result = CommonUtils.checkArguments(method, paramDict)
        if result != True:
            return {'result':'1','message':result}
        
        #変数定義
        platformList = None
        imageName = paramDict['imageName']
        if "platformList" in paramDict:
            platformList = paramDict['platformList']
        iconDeleteFlg = False
        imageNoList = []
        imageDataList = []
        
        #イメージデータ存在チェック
        try:
            imageData = CommonUtils.getImageDataByName(imageName)
            if imageData is None:
                return {'result':'1','message':"イメージ:"+ imageName + "が存在しません。削除対象を確認して下さい。"}
        except Exception as e:
            return {'result':'1','message':"イメージ情報の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"}
        
        #削除対象imageNo一覧取得
        #platformListが指定されなかった場合
        if platformList is None:
            for image in imageData:
                imageNoList.append(image["IMAGE_NO"])
        else:
            platformList = platformList.split(",")
            for platformName in platformList:
                try:
                    platformNo = CommonUtils.getPlatformDataByName(platformName)["PLATFORM_NO"]
                except Exception as e:
                    return {'result':'1','message':"プラットフォーム情報の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"}
                try:
                    imageData = CommonUtils.getImageDataByNameAndPlatformNo(imageName, platformNo)
                    if imageData != None:
                        imageNoList.append(imageData["IMAGE_NO"])
                except Exception as e:
                    return {'result':'1','message':"イメージ情報の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"}

        for imageNo in imageNoList:
            #削除対象のOSイメージを使用しているインスタンス存在チェック
            try:
                table = self.conn.getTable("INSTANCE")
            except Exception as e:
                return {'result':'1','message':"INSTANCEテーブルが存在しません。管理者に連絡を行って下さい。"}
            instanceDatas = self.conn.select(table.select(table.c.IMAGE_NO==imageNo))
            if len(instanceDatas) > 0:
                return {'result':'1','message':"OSイメージNo:" + str(imageNo) + "は現在作成済みのインスタンスで使用されているため削除できません。処理を中止します。"}

            #削除対象のOSイメージを使用しているmyCloud用インスタンステンプレートチェック
            try:
                table = self.conn.getTable("TEMPLATE_INSTANCE")
            except Exception as e:
                return {'result':'1','message':"TEMPLATE_INSTANCEテーブルが存在しません。管理者に連絡を行って下さい。"}
            tmpInstDatas = self.conn.select(table.select(table.c.IMAGE_NO==imageNo))
            if len(tmpInstDatas) > 0:
                return {'result':'1','message':"OSイメージNo:" + str(imageNo) + "は現在インスタンステンプレートで使用されているため削除できません。処理を中止します。"}

        #imageNameの同名存在チェック
        try:
            table = self.conn.getTable("IMAGE")
        except Exception as e:
            return {'result':'1','message':"IMAGEテーブルが存在しません。管理者に連絡を行って下さい。"}
        checkImageData = self.conn.select(table.select(table.c.IMAGE_NAME==imageName))

        if len(checkImageData) == len(imageNoList):
            iconDeleteFlg = True
        
        for imageNo in imageNoList:
            #プラットフォームデータ取得
            try:
                platformNo = CommonUtils.getImageDataByNo(imageNo)["PLATFORM_NO"]
            except Exception as e:
                return {'result':'1','message':"イメージ情報の取得に失敗したため処理を終了します。"}
            try:
                plData = CommonUtils.getPlatformDataByNo(platformNo)
            except Exception as e:
                return {'result':'1','message':"プラットフォーム情報の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"}
            
            iaasName = plData["PLATFORM_TYPE"]
            #IaaS毎のイメージテーブルのデータ削除
            if "aws" == iaasName:
                try:
                    tableImageAws = self.conn.getTable("IMAGE_AWS")
                    sql = tableImageAws.delete(tableImageAws.c.IMAGE_NO == imageNo)
                    self.conn.execute(sql)
                except Exception as e:
                    self.conn.rollback()
                    return {'result':'1','message':"IMAGE_AWSテーブルのデータ削除に失敗したため処理を中止します。"}

            elif "vmware" == iaasName:
                try:
                    tableImageVm = self.conn.getTable("IMAGE_VMWARE")
                    sql = tableImageVm.delete(tableImageVm.c.IMAGE_NO == imageNo)
                    self.conn.execute(sql)
                except Exception as e:
                    self.conn.rollback()
                    return {'result':'1','message':"IMAGE_VMWAREテーブルのデータ削除に失敗したため処理を中止します。"}
                    
            elif "cloudstack" == iaasName:
                try:
                    tableImageCs = self.conn.getTable("IMAGE_CLOUDSTACK")
                    sql = tableImageCs.delete(tableImageCs.c.IMAGE_NO == imageNo)
                    self.conn.execute(sql)
                except Exception as e:
                    self.conn.rollback()
                    return {'result':'1','message':"IMAGE_CLOUDSTACKテーブルのデータ削除に失敗したため処理を中止します。"}
                    
            elif "vcloud" == iaasName:
                try:
                    tableImageVc = self.conn.getTable("IMAGE_VCLOUD")
                    sql = tableImageVc.delete(tableImageVc.c.IMAGE_NO == imageNo)
                    self.conn.execute(sql)
                except Exception as e:
                    self.conn.rollback()
                    return {'result':'1','message':"IMAGE_VCLOUDテーブルのデータ削除に失敗したため処理を中止します。"}

            elif "openstack" == iaasName:
                try:
                    tableImageOs = self.conn.getTable("IMAGE_OPENSTACK")
                    sql = tableImageOs.delete(tableImageOs.c.IMAGE_NO == imageNo)
                    self.conn.execute(sql)
                except Exception as e:
                    self.conn.rollback()
                    return {'result':'1','message':"IMAGE_OPENSTACKテーブルのデータ削除に失敗したため処理を中止します。"}

            elif "azure" == iaasName:
                try:
                    tableImageAz = self.conn.getTable("IMAGE_AZURE")
                    sql = tableImageAz.delete(tableImageAz.c.IMAGE_NO == imageNo)
                    self.conn.execute(sql)
                except Exception as e:
                    self.conn.rollback()
                    return {'result':'1','message':"IMAGE_AZUREテーブルのデータ削除に失敗したため処理を中止します。"}

            elif "nifty" == iaasName:
                try:
                    tableImageNif = self.conn.getTable("IMAGE_NIFTY")
                    sql = tableImageNif.delete(tableImageNif.c.IMAGE_NO == imageNo)
                    self.conn.execute(sql)
                except Exception as e:
                    self.conn.rollback()
                    return {'result':'1','message':"IMAGE_NIFTYテーブルのデータ削除に失敗したため処理を中止します。"}

            #IMAGEテーブルのデータ削除
            try:
                tableImage = self.conn.getTable("IMAGE")
                sql = tableImage.delete(tableImage.c.IMAGE_NO == imageNo)
                self.conn.execute(sql)
            except Exception as e:
                self.conn.rollback()
                return {'result':'1','message':"IMAGEテーブルのデータ削除に失敗したため処理を中止します。"}
        
        self.conn.commit()
        
        imageNos = ",".join(str(imageNo) for imageNo in imageNoList)
        
        if iconDeleteFlg:
            #アイコン画像削除処理
            filePath = glob.glob('/opt/adc/app/auto-web/VAADIN/themes/classy/icons/' + imageName + '.*')
            if len(filePath) > 0:
                if os.path.isfile(filePath[0]):
                    os.remove(filePath[0])

        return {'result':'0','message':"OSイメージNo:" + imageNos + "の削除が完了しました。"}
Exemplo n.º 26
0
Arquivo: __init__.py Projeto: ag-sd/py
from PyQt5.QtGui import QImageReader

from Settings import SettingsKeys
from common import CommonUtils

__VERSION__ = "0.0.4"
__NAME__ = "ImagePlay"
__APP_NAME__ = str.format(f"{__NAME__} {__VERSION__}")

logger = CommonUtils.get_logger(__APP_NAME__)

settings = CommonUtils.AppSettings(
    __APP_NAME__,
    {
        SettingsKeys.image_delay: 3000,
        SettingsKeys.gif_delay: 1000,
        SettingsKeys.gif_by_frame: False,
        SettingsKeys.recurse_subdirs: False,
        SettingsKeys.shuffle: False,
        SettingsKeys.loop: True,
        SettingsKeys.image_scaled: True,
        SettingsKeys.dupe_image_view_zoom: 5
    }
)

supported_formats = []
for _format in QImageReader.supportedImageFormats():
    supported_formats.append(f".{str(_format, encoding='ascii').upper()}")
Exemplo n.º 27
0
    def updateImage(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']

        #イメージNo存在チェック
        try:
            if "imageNo" in paramDict:
                imageNo = paramDict['imageNo']
                imageData = CommonUtils.getImageDataByNo(imageNo)
                if imageData is None:
                    return {'result':'1','message':"イメージNo:"+ imageNo + "が存在しません。更新対象を確認して下さい。"}
                else:
                    platformNo = imageData["PLATFORM_NO"]
                    iaasName = CommonUtils.getPlatformTypeByNo(platformNo)
                    if iaasName is None:
                        return {'result':'1','message':"指定されたプラットフォーム名:" + paramDict['platformName'] + "は存在しません。登録対象を確認して下さい。"}
                    elif "aws" == iaasName:
                        method = "updateAwsImage"
        except Exception as e:
            return {'result':'1','message':"イメージ情報の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"}

        #引数のチェック
        result = CommonUtils.checkArguments(method, paramDict)
        if result != True:
            return {'result':'1','message':result}
        
        #引数から変数へセット
        imageNo = paramDict['imageNo']
        imageName = None
        imageNameDisp = None
        osName = None
        osNameDisp = None
        serviceList = None
        serviceNoList = 0
        instanceTypeList = None
        zabbixTemplate = None
        kernelId = None
        ramdiskId = None
        icon = None
        
        if "imageName" in paramDict:
            imageName = paramDict['imageName']
        if "imageNameDisp" in paramDict:
            imageNameDisp = paramDict['imageNameDisp']
        if "osName" in paramDict:
            osName = paramDict['osName']
        if "osNameDisp" in paramDict:
            osNameDisp = paramDict['osNameDisp']
        if "serviceList" in paramDict:
            serviceList = paramDict['serviceList']
        if "instanceTypeList" in paramDict:
            instanceTypeList = paramDict['instanceTypeList']
        if "zabbixTemplate" in paramDict:
            zabbixTemplate = paramDict['zabbixTemplate']
        if "kernelId" in paramDict:
            kernelId = paramDict['kernelId']
        if "ramdiskId" in paramDict:
            ramdiskId = paramDict['ramdiskId']
        if "icon" in paramDict:
            icon = paramDict['icon']
       
        #serviceListの値が存在する場合、名称をNoに変換
        if serviceList != None:
            serviceList = serviceList.split(',')
            serviceNoList = []
            for serviceName in serviceList:
                try:
                    result =  CommonUtils.getComponentTypeNoByName(serviceName)
                    if result is None:
                        return {'result':'1','message':"サービス名称:" + serviceName + "が存在しません。更新対象を確認して下さい。"}
                    else:
                        serviceNoList.append(result)
                except AttributeError as e:
                    return {'result':'1','message':"サービス名称の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"}
            #リストをカンマで結合
            serviceNoList = ",".join(serviceNoList)
        
        #同一プラットフォーム・同一名のイメージデータ存在チェック
        try:
            platformNo = imageData["PLATFORM_NO"]
            plData = CommonUtils.getPlatformDataByNo(platformNo)
            checkImageData = CommonUtils.getImageDataByNameAndPlatformNo(imageName, platformNo)
             #指定されたイメージ名が既に存在する場合
            if checkImageData != None and imageNo != checkImageData["IMAGE_NO"]:
                return {'result':'1','message':"更新対象のOSイメージが使用するプラットフォーム:" + plData["PLATFORM_NAME"] +"には既に同じ名称のイメージ:" + imageName + "が存在します。名称を指定し直して下さい。"}
        except Exception as e:
            return {'result':'1','message':"イメージ情報の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"}
        
        #アイコンファイル存在チェック
        if icon != None:
            if os.path.isfile(icon) == False:
                return {'result':'1','message':"指定されたアイコンファイルが見つからないため処理を中止します。対象を確認して下さい。"}
        
        iaasName = plData["PLATFORM_TYPE"]
        
        #更新データ作成
        if imageName != None:
            imageData["IMAGE_NAME"] = imageName
        if imageNameDisp != None:
            imageData["IMAGE_NAME_DISP"] = imageNameDisp
        if osName != None:
            imageData["OS"] = osName
        if osNameDisp != None:
            imageData["OS_DISP"] = osName
        if serviceNoList != 0:
            imageData["COMPONENT_TYPE_NOS"] = serviceNoList
        if zabbixTemplate != None:
            imageData["ZABBIX_TEMPLATE"] = zabbixTemplate
        
        try:
            #IMAGEテーブルのデータ更新
            try:
                image = self.conn.getTable("IMAGE")
            except Exception as e:
                return {'result':'1','message':"IMAGEテーブルが存在しません。管理者に連絡を行って下さい。"}
            sql = image.update(image.c.IMAGE_NO == imageData["IMAGE_NO"], values = imageData)
            self.conn.execute(sql)
        except Exception as e:
            self.conn.rollback()
            return {'result':'1','message':"IMAGEテーブルの更新に失敗したため処理を中止します。イメージNo:" + imageNo}
        
        #IaaS毎のテーブル更新
        if "aws" == iaasName:
            #更新データ作成
            try:
                tableImageAws = self.conn.getTable("IMAGE_AWS")
            except Exception as e:
                return {'result':'1','message':"IMAGE_AWSテーブルが存在しません。管理者に連絡を行って下さい。"}
            imageAwsData = self.conn.selectOne(tableImageAws.select(tableImageAws.c.IMAGE_NO==imageNo))
            if kernelId != None:
                imageAwsData["KERNEL_ID"] = kernelId
            if ramdiskId != None:
                imageAwsData["RAMDISK_ID"] = ramdiskId
            if instanceTypeList != None:
                imageAwsData["INSTANCE_TYPES"] = instanceTypeList
            try:
                #IMAGE_AWSテーブルのデータ更新
                sql = tableImageAws.update(tableImageAws.c.IMAGE_NO == imageAwsData["IMAGE_NO"], values = imageAwsData)
                self.conn.execute(sql)
            except Exception as e:
                self.conn.rollback()
                return {'result':'1','message':"IMAGE_AWSテーブルの更新に失敗したため処理を中止します。イメージNo:" + imageNo}
        
        elif "vmware" == iaasName:
            #更新データ作成
            try:
                tableImageVm = self.conn.getTable("IMAGE_VMWARE")
            except Exception as e:
                return {'result':'1','message':"IMAGE_VMWAREテーブルが存在しません。管理者に連絡を行って下さい。"}
            imageVmData = self.conn.selectOne(tableImageVm.select(tableImageVm.c.IMAGE_NO==imageNo))
            if instanceTypeList != None:
                imageVmData["INSTANCE_TYPES"] = instanceTypeList
            try:
                #IMAGE_VMWAREテーブルのデータ更新
                sql = tableImageVm.update(tableImageVm.c.IMAGE_NO == imageVmData["IMAGE_NO"], values = imageVmData)
                self.conn.execute(sql)
            except Exception as e:
                self.conn.rollback()
                return {'result':'1','message':"IMAGE_VMWAREテーブルの更新に失敗したため処理を中止します。イメージNo:" + imageNo}
        
        elif "cloudstack" == iaasName:
            #更新データ作成
            try:
                tableImageCs = self.conn.getTable("IMAGE_CLOUDSTACK")
            except Exception as e:
                return {'result':'1','message':"IMAGE_CLOUDSTACKテーブルが存在しません。管理者に連絡を行って下さい。"}
            imageCsData = self.conn.selectOne(tableImageCs.select(tableImageCs.c.IMAGE_NO==imageNo))
            if instanceTypeList != None:
                imageCsData["INSTANCE_TYPES"] = instanceTypeList
            try:
                #IMAGE_CLOUDSTACKテーブルのデータ更新
                sql = tableImageCs.update(tableImageCs.c.IMAGE_NO == imageCsData["IMAGE_NO"], values = imageCsData)
                self.conn.execute(sql)
            except Exception as e:
                self.conn.rollback()
                return {'result':'1','message':"IMAGE_CLOUDSTACKテーブルの更新に失敗したため処理を中止します。イメージNo:" + imageNo}
        
        elif "vcloud" == iaasName:
            #更新データ作成
            try:
                tableImageVc = self.conn.getTable("IMAGE_VCLOUD")
            except Exception as e:
                return {'result':'1','message':"IMAGE_VCLOUDテーブルが存在しません。管理者に連絡を行って下さい。"}
            imageVcData = self.conn.selectOne(tableImageVc.select(tableImageVc.c.IMAGE_NO==imageNo))
            if instanceTypeList != None:
                imageVcData["INSTANCE_TYPES"] = instanceTypeList
            try:
                #IMAGE_VCLOUDテーブルのデータ更新
                sql = tableImageVc.update(tableImageVc.c.IMAGE_NO == imageVcData["IMAGE_NO"], values = imageVcData)
                self.conn.execute(sql)
            except Exception as e:
                self.conn.rollback()
                return {'result':'1','message':"IMAGE_VCLOUDテーブルの更新に失敗したため処理を中止します。イメージNo:" + imageNo}
        
        elif "openstack" == iaasName:
            #更新データ作成
            try:
                tableImageOs = self.conn.getTable("IMAGE_OPENSTACK")
            except Exception as e:
                return {'result':'1','message':"IMAGE_OPENSTACKテーブルが存在しません。管理者に連絡を行って下さい。"}
            imageOsData = self.conn.selectOne(tableImageOs.select(tableImageOs.c.IMAGE_NO==imageNo))
            if instanceTypeList != None:
                imageOsData["INSTANCE_TYPES"] = instanceTypeList
            try:
                #IMAGE_OPENSTACKテーブルのデータ更新
                sql = tableImageOs.update(tableImageOs.c.IMAGE_NO == imageOsData["IMAGE_NO"], values = imageOsData)
                self.conn.execute(sql)
            except Exception as e:
                self.conn.rollback()
                return {'result':'1','message':"IMAGE_OPENSTACKテーブルの更新に失敗したため処理を中止します。イメージNo:" + imageNo}
        
        elif "azure" == iaasName:
            #更新データ作成
            try:
                tableImageAzure = self.conn.getTable("IMAGE_AZURE")
            except Exception as e:
                return {'result':'1','message':"IMAGE_AZUREテーブルが存在しません。管理者に連絡を行って下さい。"}
            imageAzureData = self.conn.selectOne(tableImageAzure.select(tableImageAzure.c.IMAGE_NO==imageNo))
            if instanceTypeList != None:
                imageAzureData["INSTANCE_TYPES"] = instanceTypeList
            try:
                #IMAGE_AZUREテーブルのデータ更新
                sql = tableImageAzure.update(tableImageAzure.c.IMAGE_NO == imageAzureData["IMAGE_NO"], values = imageAzureData)
                self.conn.execute(sql)
            except Exception as e:
                self.conn.rollback()
                return {'result':'1','message':"IMAGE_AZUREテーブルの更新に失敗したため処理を中止します。イメージNo:" + imageNo}
        
        elif "nifty" == iaasName:
            #更新データ作成
            try:
                tableImageNifty = self.conn.getTable("IMAGE_NIFTY")
            except Exception as e:
                return {'result':'1','message':"IMAGE_NIFTYテーブルが存在しません。管理者に連絡を行って下さい。"}
            imageNiftyData = self.conn.selectOne(tableImageNifty.select(tableImageNifty.c.IMAGE_NO==imageNo))
            if instanceTypeList != None:
                imageNiftyData["INSTANCE_TYPES"] = instanceTypeList
            try:
                #IMAGE_NIFTYテーブルのデータ更新
                sql = tableImageNifty.update(tableImageNifty.c.IMAGE_NO == imageNiftyData["IMAGE_NO"], values = imageNiftyData)
                self.conn.execute(sql)
            except Exception as e:
                self.conn.rollback()
                return {'result':'1','message':"IMAGE_NIFTYテーブルの更新に失敗したため処理を中止します。イメージNo:" + imageNo}

        if icon != None:
            path, ext = os.path.splitext(icon)
            #iconの指定がある場合iconのパスに存在する画像を/opt/adc/app/auto-web/VAADIN/themes/classy/iconsに(引数.imageName)pngの形式にリネームしてコピーする。
            copyName = "/opt/adc/app/auto-web/VAADIN/themes/classy/icons/" + imageName + ext
            shutil.copyfile(icon, copyName)

        self.conn.commit()
        return {'result':'0','message':"OSイメージNo:" + imageNo + "/" + imageName + "の更新が完了しました。"}
Exemplo n.º 28
0
            # check if the tensile strength value of each steel plate matches the expected value. (抗拉)
            assert plate.tensile_strength.value == expected_tensile_strength_vl_d36[
                cert_index][plate_index]
            # check if the elongation value of each steel plate matches the expected value. (伸长)
            assert plate.elongation.value == expected_elongation_vl_d36[
                cert_index][plate_index]
            # check if the direction value of each steel plate matches the expected value.
            assert plate.position_direction_impact.value == expected_position_direction_impact_vl_36[
                cert_index][plate_index]
            # check if the temperature value of each steel plate matches the expected value.
            assert plate.temperature.value == expected_temperature_vl_d36[
                cert_index][plate_index]
            # check if the impact energy values of eact steel plate match the expected values.
            current_imapct_energy_list = expected_impact_energy_list_vl_d36[
                cert_index][plate_index]
            assert len(
                plate.impact_energy_list) == len(current_imapct_energy_list)
            if len(current_imapct_energy_list) > 0:
                for impact_energy_index, impact_energy_value in enumerate(
                        current_imapct_energy_list):
                    assert plate.impact_energy_list[
                        impact_energy_index].value == impact_energy_value


if __name__ == '__main__':
    test_file_vl_a = 'J0E0061697_BGSAJ2009120012700.pdf'
    abs_path = os.path.abspath(test_file_vl_a)
    with CommonUtils.open_file(abs_path) as pdf_file:
        cert_file: PdfFile = pdf_file
        print(cert_file.tables[1])
Exemplo n.º 29
0
    def validateService(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']

        #引数のチェック
        result = CommonUtils.checkArguments(method, paramDict)
        if result != True:
            return {'result': '1', 'message': result}

        #変数設定
        imageNo = paramDict['imageNo']
        serviceList = paramDict['serviceList']

        #イメージ存在チェック
        try:
            imageData = CommonUtils.getImageDataByNo(imageNo)
        except Exception as e:
            return {
                'reslut': '1',
                'message': "イメージ情報の呼び出しに失敗したためサービス情報の追加を中止します。管理者に連絡を行って下さい。"
            }
        if imageData == None:
            return {
                'result': '1',
                'message': "imageNo:" + imageNo + "が存在しません。サービス情報の追加を中止します。"
            }

        #serviceList存在チェック
        serviceNameList = serviceList.split(",")
        serviceNoList = []
        for serviceName in serviceNameList:
            try:
                result = CommonUtils.getComponentTypeNoByName(serviceName)
                if result == None:
                    return {
                        'result':
                        '1',
                        'message':
                        "サービス名称:" + serviceName + "が存在しません。サービス名称を確認して下さい。"
                    }
                else:
                    serviceNoList.append(result)
            except Exception as e:
                return {
                    'result': '1',
                    'message': "サービス情報の取得に失敗したためサービス情報の追加を中止します。管理者に連絡を行って下さい。"
                }

        #登録用データ作成
        compTypeNoList = imageData['COMPONENT_TYPE_NOS'].split(",")
        serviceNoList.extend(compTypeNoList)
        serviceNoList = list(set(serviceNoList))
        if "0" in serviceNoList:
            serviceNoList.remove("0")
        serviceNoList.sort()
        serviceNoList = ",".join(serviceNoList)

        #サービス情報追加
        try:
            image = self.conn.getTable("IMAGE")
            imageData = self.conn.selectOne(
                image.select(image.c.IMAGE_NO == imageNo))
            imageData['COMPONENT_TYPE_NOS'] = serviceNoList
            sql = image.update(image.c.IMAGE_NO == imageNo, values=imageData)
            self.conn.execute(sql)
            self.conn.commit()
            return {
                'result':
                '0',
                'message':
                "イメージNo:" + imageNo + "上で利用可能なサービス情報:" + serviceList +
                "の追加に成功しました。"
            }
        except Exception as e:
            self.conn.rollback()
            return {
                'result': '1',
                'message': "利用可能サービス情報:" + serviceList + "の追加に失敗しました。処理を終了します。"
            }
    def updateModule(self, paramDict):
        #処理メソッド取得
        method = paramDict['method']
        #辞書からメソッドキーと値を削除
        del paramDict['method']
        #辞書からmifDictを受け取り削除
        mifDict = paramDict['mifDict']
        del paramDict['mifDict']

        #引数のチェック
        result = CommonUtils.checkArguments(method, paramDict)
        if result != True:
            return {'result': '1', 'message': result}

        #引数から変数へセット
        moduleName = paramDict['moduleName']
        componentNos = []
        instanceNos = []
        status = []

        #更新対象がイメージの場合
        if mifDict['moduleInformation'].has_key('TemplateModule'):
            #MIF中にテンプレートIDが存在するか確認
            #if jsonMif['moduleInformation']['TemplateModude']['templateModuleInformation'].has_key('uploadedTemplateID'):
            a = "hoge"
            #############################################################
            #IaaSへの登録機能実装時に実装する
            #############################################################

        #更新対象がサービスの場合
        elif mifDict['moduleInformation'].has_key('ServiceModule'):
            serviceName = mifDict['moduleInformation']['ServiceModule'][
                'ServiceModuleInformation']['moduleName']
            #COMPONENT_TYPEテーブルからモジュールのCOMPONENT_TYPE_NO取得
            try:
                componentTypeNo = CommonUtils.getComponentTypeNoByName(
                    serviceName)
            except Exception as e:
                return {
                    'result': '1',
                    'message': "サービス情報の取得に失敗したため処理を中止します。管理者に連絡を行って下さい。"
                }
            #PCCテーブルに登録されている場合使用中確認を行う
            if componentTypeNo is not None:
                conn = MysqlConnector()
                #COMPONENTテーブル情報取得
                try:
                    tableComponent = conn.getTable("COMPONENT")
                    componentData = conn.select(
                        tableComponent.select(
                            tableComponent.c.COMPONENT_TYPE_NO ==
                            componentTypeNo))
                except Exception as e:
                    return {
                        'result': '1',
                        'message': "COMPONENTテーブル情報取得に失敗しました。処理を中止します。"
                    }
                if len(componentData) > 0:
                    for conponent in componentData:
                        componentNos.append(conponent['COMPONENT_NO'])
                #COMPONENT_INSTANCEテーブル情報取得
                try:
                    tableComponentInstance = conn.getTable(
                        "COMPONENT_INSTANCE")
                except Exception as e:
                    return {
                        'result': '1',
                        'message':
                        "COMPONENT_INSTANCEテーブル情報取得に失敗しました。処理を中止します。"
                    }
                for conponentNo in componentNos:
                    instanceNos.append(
                        conn.selectOne(
                            tableComponentInstance.select(
                                tableComponentInstance.c.COMPONENT_NO ==
                                conponentNo))['INSTANCE_NO'])
                #INSTANCEテーブル情報取得
                try:
                    tableInstance = conn.getTable("INSTANCE")
                except Exception as e:
                    return {
                        'result': '1',
                        'message': "INSTANCEテーブル情報取得に失敗しました。処理を中止します。"
                    }
                for instanceNo in instanceNos:
                    status.append(
                        conn.selectOne(
                            tableInstance.select(tableInstance.c.INSTANCE_NO ==
                                                 instanceNo))['STATUS'])
                #起動中のサービスが存在する場合処理終了
                if "RUNNING" in status:
                    return {
                        'result': '1',
                        'message': "起動中のサービスが存在するため処理を中止します。"
                    }
        else:
            return {'result': '1', 'message': "JSONファイルが壊れているため処理を中止します。"}

        #正常終了
        return {'result': '0', 'message': "success"}
Exemplo n.º 31
0
from common import CommonUtils

__VERSION__ = "0.0.0"
__NAME__ = "RedditBrowser"
__APP_NAME__ = str.format(f"{__NAME__} {__VERSION__}")

logger = CommonUtils.get_logger(__APP_NAME__)
Exemplo n.º 32
0
import json
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import common.CommonUtils as CommonUtils
from app.PlatformManager import PlatformManager
from app.ImageManager import ImageManager
from app.ServiceManager import ServiceManager
from app.RepositoryManager import RepositoryManager

if __name__ == '__main__':
    command = sys.argv[1]
    jsonData = sys.argv[2]
    paramDict = json.loads(jsonData)
    #DB接続チェック
    checkResult = CommonUtils.checkDbConnection()
    #DB接続エラーの場合、処理終了
    if checkResult == True:
        if "addPlatform" == command:
            pm = PlatformManager()
            retDict = pm.addPlatform(paramDict)
        elif "updatePlatform" == command:
            pm = PlatformManager()
            retDict = pm.updatePlatform(paramDict)
        elif "deletePlatform" == command:
            pm = PlatformManager()
            retDict = pm.deletePlatform(paramDict)
        elif "enablePlatform" == command:
            pm = PlatformManager()
            retDict = pm.enablePlatform(paramDict)
        elif "disablePlatform" == command: