学华为思想

举报
lzyzgyaaabbbccc 发表于 2024/12/13 22:00:32 2024/12/13
【摘要】 hostnamectl  set-hostname kubeedge-node[root@master ~]# cat >> /etc/hosts <<EOF10.26.17.135 master10.26.7.126 kubeedge-nodeEOF[root@kubeedge-node ~]# cat >> /etc/hosts <<EOF10.26.17.135 master10.26...

hostnamectl  set-hostname kubeedge-node

[root@master ~]# cat >> /etc/hosts <<EOF
10.26.17.135 master
10.26.7.126 kubeedge-node
EOF
[root@kubeedge-node ~]# cat >> /etc/hosts <<EOF
10.26.17.135 master
10.26.7.126 kubeedge-node
EOF

[root@master ~]# curl -O http://mirrors.douxuedu.com/KubeEdge/kubernetes_kubeedge_allinone.tar.gz
[root@master ~]# tar -zxvf kubernetes_kubeedge_allinone.tar.gz  -C /opt/
[root@master ~]# ls 
docker-compose-Linux-x86_64  harbor-offline-installer-v2.5.0.tgz  kubeedge               kubernetes_kubeedge.tar.gz
ec-dashboard-sa.yaml         k8simage                             kubeedge-counter-demo  yum

[root@master ~]# mv /etc/yum.repos.d/* /media/
[root@master ~]# cat > /etc/yum.repos.d/local.repo <<EOF
[docker]
name=docker
baseurl=file:///opt/yum
gpgcheck=0
enabled=1
EOF
[root@master ~]# yum -y install vsftpd
[root@master ~]# echo anon_root=/opt >> /etc/vsftpd/vsftpd.conf

[root@kubeedge-node ~]# mv /etc/yum.repos.d/* /media/
[root@kubeedge-node ~]# cat >/etc/yum.repos.d/ftp.repo <<EOF
[docker]
name=docker
baseurl=ftp://master/yum
gpgcheck=0
enabled=1
EOF

[root@master ~]# vi /etc/docker/daemon.json
"insecure-registries": ["0.0.0.0/0"]
[root@master ~]# systemctl  daemon-reload 
[root@master ~]# systemctl  restart docker

[root@kubeedge-node ~]# yum -y install docker-ce
[root@kubeedge-node ~]# vi  /etc/docker/daemon.json
"insecure-registries": ["0.0.0.0/0"]
[root@master ~]# systemctl  daemon-reload 
[root@master ~]# systemctl  restart docker

[root@master ~]# cd /opt/
[root@master opt]# mv docker-compose-Linux-x86_64  /usr/bin/docker-compose
[root@master opt]# tar -zxvf harbor-offline-installer-v2.5.0.tgz  
[root@master opt]# cd harbor && cp harbor.yml.tmpl harbor.yml
[root@master harbor]# vi harbor.yml
hostname: 10.26.17.135            #将hostname修改为云端节点IP
[root@master harbor]# ./install.sh
……
✔ ----Harbor has been installed and started successfully.----
[root@master harbor]# docker login -u admin -p Harbor12345 master
….
Login Succeeded

master节点IP,访问Harbor页面,使用默认的用户名和密码进行登录(admin/Harbor12345),并创建一个名为“k8s”的命名空间

[root@master harbor]# cd /opt/k8simage/ && sh load.sh
[root@master k8simage]# sh push.sh 
请输入您的Harbor仓库地址(不需要带http):10.26.17.135  #地址为云端master节点地址

[root@master k8simage]# cd /opt/kubeedge/
[root@master kubeedge]# mv keadm /usr/bin/
[root@master kubeedge]# mkdir /etc/kubeedge
[root@master kubeedge]# tar -zxf kubeedge-1.11.1.tar.gz
[root@master kubeedge]# cp -rf kubeedge-1.11.1/build/tools/* /etc/kubeedge/
[root@master kubeedge]# cp -rf kubeedge-1.11.1/build/crds/ /etc/kubeedge/
[root@master kubeedge]# tar -zxf kubeedge-v1.11.1-linux-amd64.tar.gz
[root@master kubeedge]# cp -rf * /etc/kubeedge/

[root@master kubeedge]# cd /etc/kubeedge/
[root@master kubeedge]# keadm deprecated init --kubeedge-version=1.11.1 --advertise-address=10.26.17.135 
……
KubeEdge cloudcore is running, For logs visit: /var/log/kubeedge/cloudcore.log
CloudCore started

netstat  -ntpl |grep cloudcor

[root@kubeedge-node ~]# scp root@master:/usr/bin/keadm /usr/local/bin/
[root@kubeedge-node ~]# mkdir /etc/kubeedge
[root@kubeedge-node ~]# cd /etc/kubeedge/
[root@kubeedge-node kubeedge]# scp -r root@master:/etc/kubeedge/* /etc/kubeedge/

[root@master kubeedge]# keadm gettoken

[root@kubeedge-node ~]# keadm deprecated join --cloudcore-ipport=10.26.17.135:10000 --kubeedge-version=1.11.1 --token=1f0f213568007af1011199f65ca6405811573e44061c903d0f24c7c0379a5f65.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2OTEwNTc2ODN9.48eiBKuwwL8bFyQcfYyicnFSogra0Eh0IpyaRMg5NvY

[root@master kubeedge]# export CLOUDCOREIPS="master"

[root@master kubeedge]# cd /etc/kubeedge/
[root@master kubeedge]# ./certgen.sh stream

[root@master kubeedge]# vi /etc/kubeedge/config/cloudcore.yaml
 cloudStream:
    enable: true  #修改为true
    streamPort: 10003
router:
    address: 0.0.0.0
    enable: true  #修改为true
    port: 9443
    restTimeout: 60

[root@kubeedge-node kubeedge]# vi /etc/kubeedge/config/edgecore.yaml
 edgeStream:
    enable: true  #修改为true
    handshakeTimeout: 30
serviceBus:
    enable: true  #修改为true

[root@master kubeedge]# kill -9 $(netstat -lntup |grep cloudcore |awk 'NR==1 {print $7}' |cut -d '/' -f 1)
[root@master kubeedge]# cp -rfv cloudcore.service /usr/lib/systemd/system/
[root@master kubeedge]# systemctl start  cloudcore.service 
[root@master kubeedge]# netstat -lntup |grep 10003
tcp6   0   0  :::10003     :::*       LISTEN      15089/cloudcore

[root@kubeedge-node kubeedge]# systemctl restart edgecore.service

2.1.2 安装依赖包
首先安装gcc编译器,gcc有些系统版本已经默认安装,通过gcc -version查看,没安装的先安装gcc,不要缺少,否则有可能安装python出错,python3.7.0以下的版本可不装libffi-devel。

在云端节点,下载离线yum源,安装软件,命令如下:

[root@master ~]# curl -O http://mirrors.douxuedu.com/KubeEdge/python-kubeedge/gcc-repo.tar.gz
[root@master ~]# tar -zxvf  gcc-repo.tar.gz  
[root@master ~]# vi /etc/yum.repos.d/gcc.repo 
[gcc]
name=gcc
baseurl=file:///root/gcc-repo
gpgcheck=0
enabled=1
[root@master ~]# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel gcc

2.1.3 编译安装Python3.7
在云端节点下载python3.7等安装包,并进行解压编译,命令如下:

[root@master ~]# curl -O http://mirrors.douxuedu.com/KubeEdge/python-kubeedge/Python-3.7.3.tar.gz
[root@master ~]# curl -O http://mirrors.douxuedu.com/KubeEdge/python-kubeedge/volume_packages.tar.gz
[root@master ~]# mkdir /usr/local/python3 && tar -zxvf Python-3.7.3.tar.gz 
[root@master ~]# cd Python-3.7.3/
[root@master Python-3.7.3]# ./configure --prefix=/usr/local/python3
[root@master Python-3.7.3]#  make && make install
[root@master Python-3.7.3]# cd /root

2.1.4 建立Python软链接
解压volume_packages压缩包,然后将编译后的python3.7软连接至/usr/bin目录下,并查看版本信息,命令如下:

[root@master ~]# tar -zxvf volume_packages.tar.gz 
[root@master ~]# yes |mv volume_packages/site-packages/* /usr/local/python3/lib/python3.7/site-packages/
[root@master ~]# ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
[root@master ~]#  ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
[root@master ~]# python3 --version
Python 3.7.3
[root@master ~]# pip3 list
Package                  Version             
------------------------ --------------------
absl-py                  1.4.0               
aiohttp                  3.8.4               
aiosignal                1.3.1               
anyio                    3.7.0               
async-timeout            4.0.2               
asynctest                0.13.0  
......以下内容忽略......

2.2 搭建MongoDB
2.2.1 搭建MongoDB
将mongoRepo.tar.gz软件包放到边侧节点中,然后进行解压,命令如下:

[root@kubeedge-node ~]# curl -O http://mirrors.douxuedu.com/KubeEdge/python-kubeedge/mongoRepo.tar.gz
[root@kubeedge-node ~]# tar -zxvf mongoRepo.tar.gz -C /opt/
[root@kubeedge-node ~]# vi /etc/yum.repos.d/mongo.repo
[mongo]
name=mongo
enabled=1
gpgcheck=0
baseurl=file:///opt/mongoRepo

在边侧节点安装mongodb,命令如下:

[root@kubeedge-node ~]# yum -y install mongodb*
安装完成后配置mongo,命令如下:

[root@kubeedge-node ~]# vi /etc/mongod.conf 
#找到下面的字段然后进行修改
net:
  port: 27017
  bindIp: 0.0.0.0   #修改为0.0.0.0

修改完毕后,重启服务,命令如下:

[root@kubeedge-node ~]# systemctl restart mongod && systemctl enable mongod
验证服务,命令如下:

[root@kubeedge-node ~]# netstat -lntup |grep 27017
tcp        0      0 0.0.0.0:27017           0.0.0.0:*               LISTEN      10195/mongod 

若出现27017端口,则MongoDB服务启动成功。

2.2.2 创建数据库
边侧节点登录MongoDB,创建数据库与集合,命令如下:

[root@kubeedge-node ~]# mongo
> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
> use edgesql
switched to db edgesql
> show collections
> db.createCollection("users")
{ "ok" : 1 }
> db.createCollection("ai_data")
{ "ok" : 1 }
> db.createCollection("ai_model")
{ "ok" : 1 }
> show collections
ai_data
ai_model
users
>
#按键盘上的Ctrl+D可退出

2.3 搭建H5前端
ydy_cloudapp_front_dist是编译后的前端H5程序,通过Web Server运行即可。

2.3.1 Linux运行H5前端
在边侧节点下载gcc-repo和ydy_cloudapp_front_dist压缩包并进行解压,配置Yum源并将解压后的文件拷贝至Nginx站点目录,命令如下:

[root@kubeedge-node ~]# curl -O http://mirrors.douxuedu.com/KubeEdge/python-kubeedge/gcc-repo.tar.gz
[root@kubeedge-node ~]# curl  -O http://mirrors.douxuedu.com/KubeEdge/python-kubeedge/ydy_cloudapp_front_dist.tar.gz
[root@kubeedge-node ~]# tar -zxvf gcc-repo.tar.gz 
[root@kubeedge-node ~]# tar -zxvf ydy_cloudapp_front_dist.tar.gz  
[root@kubeedge-node ~]# vi  /etc/yum.repos.d/gcc.repo
[gcc]
name=gcc
baseurl=file:///root/gcc-repo
gpgcheck=0
enabled=1
[root@kubeedge-node ~]#  yum install -y nginx
[root@kubeedge-node ~]# rm -rf /usr/share/nginx/html/*
[root@kubeedge-node ~]# mv ydy_cloudapp_front_dist/index.html /usr/share/nginx/html/
[root@kubeedge-node ~]# mv ydy_cloudapp_front_dist/static/ /usr/share/nginx/html/
[root@kubeedge-node ~]# vi /etc/nginx/nginx.conf
#配置nginx反向代理,进入配置文件在文件下方找到相应的位置进行配置
server {
        listen       80;
        listen       [::]:80;
        server_name  localhost;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;
        error_page 404 /404.html;
        location = /404.html {
        }
        location  ~ ^/cloudedge/(.*) {
          proxy_pass http://10.26.17.135:30850/cloudedge/$1;  
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          
          add_header 'Access-Control-Allow-Origin' '*';
          add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
          add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type';
          add_header 'Access-Control-Allow-Credentials' 'true';
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
    }
[root@kubeedge-node ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@kubeedge-node ~]# systemctl restart nginx && systemctl enable nginx


数据库管理
配置本地yum源

[a]
baserurl=file:///root/rocket/yum
gpgcheck=0
1
2
3
安装MongoDB 数据库、

[root@mysql-1 ~]# yum install -y mongodb-org 
[root@mysql-2 ~]# yum install -y mongodb-org 

1
2
3
启动MongoDB数据库

[root@mysql-1 ~]# systemctl restart mongod
[root@mysql-2 ~]# systemctl restart mongod

[root@mysql-1 ~]# vi /etc/mongod.conf


net:
  port: 27017
  bindIp: 0.0.0.0   # 修改

#security:

#operationProfiling:

replication:
  replSetName: rs  #添加   过滤: mongod --help | grep repl
重启服务

[root@mysql-1 ~]# systemctl restart mongod
[root@mysql-2 ~]#  systemctl restart mongod

1
2
3
数据库配置( 在mysql-1配置就可以了 )

> use admin 
switched to db admin
> cfg={ _id:"rs", members:[ {_id:0,host:'172.16.1.88:27017',priority:2}, {_id:1,host:'172.16.1.89:27017',priority:1}] };
{
        "_id" : "rs",
        "members" : [
                {
                        "_id" : 0,
                        "host" : "172.16.1.88:27017",
                        "priority" : 2
                },
                {
                        "_id" : 1,
                        "host" : "172.16.1.89:27017",
                        "priority" : 1
                }
        ]
}
> rs.initiate(cfg)
{ "ok" : 1 }   要显示ok 1
rs:SECONDARY> rs.status()

[root@mysql-1 rocket]# tar xf node-v12.16.1-linux-x64.tar.gz 
[root@mysql-1 rocket]# mv node-v12.16.1-linux-x64 /usr/local/node
[root@mysql-1 rocket]# ln -s /usr/local/node/bin/* /usr/bin/
[root@mysql-1 rocket]# node -v
v12.16.1
[root@mysql-1 rocket]# 

RocketChat 上云

[root@mysql-1 rocket]# tar xf rocket.chat-3.2.2.tgz 
[root@mysql-1 rocket]# cd bundle/
[root@mysql-1 bundle]# ls
main.js  programs  README  server  star.json
[root@mysql-1 bundle]# cd programs/server/
[root@mysql-1 server]# npm install   如果出现报错可以切换nodejs版本来安装

选择chinaskill-sql-1 ip加入
[root@mysql-1 bundle]# export ROOT_URL='http://localhost:3000'
[root@mysql-1 bundle]# export PORT="3000"
[root@mysql-1 bundle]# export MONGO_URL='mongodb://172.16.1.88:27017/rocketchat?replicsSet=rs' 
[root@mysql-1 bundle]# export MONGO_OPLOG_URL=mongodb://172.16.1.88:27017/local?replicaSet=rs
[root@mysql-1 bundle]# node main.js 


ecsyunzhuji
# coding: utf-8
import argparse
import json


import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkecs.v2.region.ecs_region import EcsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkecs.v2 import *

def create_ecs(client, name):
    try:
        request = CreatePostPaidServersRequest()
        rootVolumeServer = PostPaidServerRootVolume(
            volumetype="ESSD"
        )
        listNicsServer = [
            PostPaidServerNic(
                subnet_id="aa1f5883-50f8-4ab4-83ea-9c11d4ec5ee3"
            )
        ]
        serverbody = PostPaidServer(
            flavor_ref="c7.large.2",
            image_ref="02a17486-1214-4e42-8da7-7d200cac585e",
            name=name,
            nics=listNicsServer,
            root_volume=rootVolumeServer,
            vpcid="ec9940c9-7453-427a-a0eb-0186ca34fe34"
        )
        request.body = CreatePostPaidServersRequestBody(
            server=serverbody
        )
        response = client.create_post_paid_servers(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

def get_all(client, filename):
    try:
        request = ListCloudServersRequest()
        response = client.list_cloud_servers(request)
        with open(filename, "w") as f:
            f.write(json.dumps(str(response)))
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

def get_ecs(name, filename):
    try:
        request = ListCloudServersRequest()
        response = client.list_cloud_servers(request)
        res = json.loads(str(response))
        for ecs in res["servers"]:
            if ecs["name"] == name:
                with open(filename, "w") as f:
                    f.write(json.dumps(ecs))

    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

def delete_ecs(client, name):
    try:
        # 通过姓名获取云服务器ID
        serverid = ""
        request = ListCloudServersRequest()
        response = client.list_cloud_servers(request)
        res = json.loads(str(response))
        for ecs in res["servers"]:
            if ecs["name"] == name:
                serverid= ecs["id"]


        request = DeleteServersRequest()
        listServersbody = [
            ServerId(
                id=serverid
            )
        ]
        request.body = DeleteServersRequestBody(
            servers=listServersbody
        )
        response = client.delete_servers(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)


# 设定参数
def args(parser):
    parser.add_argument("command", type=str)
    parser.add_argument("-i", "--input", type=str)
    parser.add_argument("-n", "--name", type=str)
    parser.add_argument("-o", "--output", type=str)

if __name__ == "__main__":

    ak = "A7LZK8ISISCRGGVZG9CD"
    sk = "huzsKTsMbWgDB114l6ZLNOh4WYI95gXfozcK6ScC"
    credentials = BasicCredentials(ak, sk)

    client = EcsClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(EcsRegion.value_of("cn-north-4")) \
        .build()

    parser = argparse.ArgumentParser()
    args(parser)
    arg = parser.parse_args()
    if arg.command == "getall":
        filename = arg.output
        get_all(client, filename)

    elif arg.command == "create":
        userinfo = json.loads(arg.input)
        create_ecs(client, userinfo["name"])

    elif arg.command == "get":
        name = arg.name
        filename = arg.output
        get_ecs(name, filename)
    elif arg.command == "delete":
        name = arg.name
        delete_ecs(client, name)

云容器引擎CCE
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkcce.v3.region.cce_region import CceRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcce.v3 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = "9FFXTCVCH2XBTAD5FY29"
    sk = "47OgSQvpBozT9CzTvLThWJSSO4Dg3uzr7nDFOOvP"

    credentials = BasicCredentials(ak, sk)

    client = CceClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(CceRegion.value_of("cn-east-3")) \
        .build()

    try:
        request = CreateClusterRequest()
        containerNetworkSpec = ContainerNetwork(
            mode="vpc-router"
        )
        hostNetworkSpec = HostNetwork(
            vpc="6be70986-a4aa-4b72-8c77-8df3872b9ec0",
            subnet="864d4c21-e811-4769-9cf2-30226bc01925"
        )
        specbody = ClusterSpec(
            flavor="cce.s1.small",
            host_network=hostNetworkSpec,
            container_network=containerNetworkSpec,
            billing_mode=0,
            deletion_protection=False
        )
        metadatabody = ClusterMetadata(
            name="chinaskillscce2022"
        )
        request.body = Cluster(
            spec=specbody,
            metadata=metadatabody,
            api_version="v3",
            kind="Cluster"
        )
        response = client.create_cluster(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)


华为ecs_server
# coding: utf-8
import json
import yaml
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkecs.v2.region.ecs_region import EcsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkecs.v2 import *
import flask
from flask import request, Response

app = flask.Flask(__name__)

ak = "A7LZK8ISISCRGGVZG9CD"
sk = "huzsKTsMbWgDB114l6ZLNOh4WYI95gXfozcK6ScC"

credentials = BasicCredentials(ak, sk) \

client = EcsClient.new_builder() \
    .with_credentials(credentials) \
    .with_region(EcsRegion.value_of("cn-north-4")) \
    .build()

def create_ecs(name):
    try:
        request = CreatePostPaidServersRequest()
        rootVolumeServer = PostPaidServerRootVolume(
            volumetype="ESSD"
        )
        listNicsServer = [
            PostPaidServerNic(
                subnet_id="aa1f5883-50f8-4ab4-83ea-9c11d4ec5ee3"
            )
        ]
        serverbody = PostPaidServer(
            flavor_ref="c7.large.2",
            image_ref="02a17486-1214-4e42-8da7-7d200cac585e",
            name=name,
            nics=listNicsServer,
            root_volume=rootVolumeServer,
            vpcid="ec9940c9-7453-427a-a0eb-0186ca34fe34"
        )
        request.body = CreatePostPaidServersRequestBody(
            server=serverbody
        )
        response = client.create_post_paid_servers(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

def get_ecs(name):
    try:
        request = ListCloudServersRequest()
        response = client.list_cloud_servers(request)
        res = json.loads(str(response))
        for ecs in res["servers"]:
            if ecs["name"] == name:
               print(ecs)
               return ecs
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

def delete_ecs(name):
    try:
        # 通过姓名获取云服务器ID
        serverid = ""
        request = ListCloudServersRequest()
        response = client.list_cloud_servers(request)
        res = json.loads(str(response))
        for ecs in res["servers"]:
            if ecs["name"] == name:
                serverid= ecs["id"]


        request = DeleteServersRequest()
        listServersbody = [
            ServerId(
                id=serverid
            )
        ]
        request.body = DeleteServersRequestBody(
            servers=listServersbody
        )
        response = client.delete_servers(request)
        print(response)
        return response
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

#========================================
'''
创建云主机
'''
@app.route("/ecs/server",methods=['POST'])
def do_post():
    data = json.loads(request.data);
    servername = data['name'];
    response = create_ecs(servername)
    return Response(json.dumps(response))

@app.route('/ecs/server/<name>', methods=['GET'])
def do_get(name):
    #截取名称
    #获取云主机信息
    response = get_ecs(name);
    return Response(yaml.dump(response), mimetype='application/yaml')

@app.route('/ecs/server/<name>', methods=['DELETE'])   #注解
def do_delete(name):
    response = delete_ecs(name)
    return Response(yaml.dump(response), mimetype='application/yaml')

#===============启动端口========================================
if __name__ == "__main__":
   app.run(host='localhost', port=8888)

【版权声明】本文为华为云社区用户原创内容,未经允许不得转载,如需转载请自行联系原作者进行授权。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。