コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string     username    = textBox1.Text;
            string     password    = textBox2.Text;
            string     email       = textBox3.Text;
            string     project     = textBox4.Text;
            string     domain      = textBox5.Text;
            string     description = textBox6.Text;
            IOpenStack ios         = new OpenstackController();
            int        num         = ios.AddUser(url, auth, project, domain, username, password, description, email);

            if (num == 404)
            {
                MessageBox.Show("404 NOT FOUND 没有找到网页", "Error", MessageBoxButtons.OK);
            }
            else if (num == 401)
            {
                MessageBox.Show("用户信息或者权限错误请检查", "Error", MessageBoxButtons.OK);
            }
            else if (num == 403)
            {
                MessageBox.Show("用户无权访问", "Error", MessageBoxButtons.OK);
            }
            else
            {
                MessageBox.Show("错误的返回代码", "Error", MessageBoxButtons.OK);
            }
            return;
        }
コード例 #2
0
 private void button18_Click(object sender, EventArgs e)
 {
     if (user_combox.SelectedIndex == -1)
     {
         return;
     }
     if (osui == null)
     {
         MessageBox.Show("没有数据", "Warning", MessageBoxButtons.OK);
         return;
     }
     if (button18.Text == "启动" || button18.Text == "禁用")
     {
         string name   = user_combox.SelectedItem.ToString();
         var    result = osui.users.SingleOrDefault(m => m.name == name);
         if (button18.Text == "启动")
         {
             IOpenStack iso = new OpenstackController();
             int        num = iso.StartUser(useOpenstackhttp, openstackloginauth, result.id);
             CheckHttpCode(num);
         }
         else if (button18.Text == "禁用")
         {
             IOpenStack iso = new OpenstackController();
             int        num = iso.StopUser(useOpenstackhttp, openstackloginauth, result.id);
             CheckHttpCode(num);
         }
         else
         {
             MessageBox.Show("错误的程序内容", "Error", MessageBoxButtons.OK);
         }
         button15_Click(sender, e);
         button16_Click(sender, e);
     }
     else
     {
         if (button18.Text == "不能删除")
         {
             return;
         }
         else
         {
             string     name   = user_combox.SelectedItem.ToString();
             var        result = imagelist.SingleOrDefault(m => m.name == name);
             IOpenStack ios    = new OpenstackController();
             int        num    = ios.DelImage(useOpenstackhttp, openstackloginauth, result.id);
             CheckHttpCode(num);
             button22_Click(sender, e);
             button16_Click(sender, e);
         }
     }
 }
コード例 #3
0
        private void button22_Click(object sender, EventArgs e)
        {
            button18.Text = "开启";
            user_combox.Items.Clear();
            IOpenStack ios    = new OpenstackController();
            var        images = ios.GetImageList(useOpenstackhttp, openstackloginauth);

            imagelist = images.images;
            foreach (var item in imagelist)
            {
                user_combox.Items.Add(item.name);
            }
        }
コード例 #4
0
        private void Button14_Click(object sender, EventArgs e)
        {
            int num = comboBox2.SelectedIndex;

            if (num == -1)
            {
                return;
            }
            List <string> getconnopk = OpenstackConnectionStrs[num];

            useOpenstackhttp = getconnopk[2];
            useOpenstackuser = getconnopk[3];
            useOpenstackpass = getconnopk[4];
            IOpenStack ios = new OpenstackController();

            openstackloginauth = ios.GetAuth(useOpenstackhttp, useOpenstackuser, useOpenstackpass, "default");
            if (!string.IsNullOrEmpty(openstackloginauth))
            {
                label4.Text = "成功连接";
            }
        }
コード例 #5
0
        private void button15_Click(object sender, EventArgs e)
        {
            button18.Text = "启动";
            if (string.IsNullOrEmpty(useOpenstackhttp) || string.IsNullOrEmpty(openstackloginauth))
            {
                MessageBox.Show("未连接至任何服务", "Error", MessageBoxButtons.OK);
                return;
            }
            IOpenStack iso = new OpenstackController();

            osui = iso.GetUserList(useOpenstackhttp, openstackloginauth);
            if (osui == null)
            {
                return;
            }
            user_combox.Items.Clear();
            osusers = osui.users;
            foreach (var item in osusers)
            {
                user_combox.Items.Add(item.name);
            }
        }